Skip to content

Commit 6b04ecd

Browse files
authored
feat: Adding new docker build paramameters (#134)
This PR adds new build parameters that make it easy to modify the creation of a FIREWHEEL docker container and corresponding documentation to help override the default configuration options. Additionally, this moves the docker container to use port 2222 by default as this will prevent conflicts with host systems. This convention is used by other virtualization systems, such as Vagrant.
1 parent 740ef8d commit 6b04ecd

File tree

3 files changed

+55
-25
lines changed

3 files changed

+55
-25
lines changed

docker/README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,26 @@ Rather than describing them here, we refer to the following places:
7272
* minimega settings are provided in both [start-minimega.sh](./start-minimega.sh) and [minimega](./fsroot/etc/default/minimega).
7373
* miniweb settings are provided in both [start-minimega.sh](./start-minimega.sh).
7474

75+
Currently, the pre-built FIREWHEEL container contains several hard-coded options to work for *most* users.
7576
The minimega configuration values can be overwritten either by passing environment variables to Docker when starting the container or by binding a file to `/etc/default/minimega` in the container that contains updated values.
7677

77-
> [!NOTE]
78-
> Currently, the FIREWHEEL configuration options are hard-coded to work with this configuration.
79-
> Flexibility in setting these values may be provided in a future release.
80-
> overwritten via Docker environment variables.
78+
Users can also add an additional layer to the docker container to help adjust these values as needed (see: [docker build variables](https://docs.docker.com/build/building/variables)).
79+
An example of how to do this is shown below:
80+
81+
```docker
82+
# This new container enables users to build the container
83+
# with an alternative minimega files path
84+
FROM ghcr.io/sandialabs/firewheel:main AS firewheel
85+
86+
# Take in an optional build argument
87+
ARG MM_FILEPATH=/tmp/minimega/files
8188
89+
RUN echo -e "\nMM_FILEPATH=${MM_FILEPATH}" >> /etc/default/minimega
90+
91+
RUN bash -c "source /fwpy/bin/activate && \
92+
mkdir -p ${MM_FILEPATH} \
93+
firewheel config set -s minimega.files_dir ${MM_FILEPATH}"
94+
```
8295

8396
## Technical Details
8497
As with most docker containers, the default user is `root`.

docker/firewheel.dockerfile

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,27 @@ FROM ghcr.io/sandia-minimega/minimega:master AS minimega
22

33
# --#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-- #
44

5-
## Package dependencies
6-
ENV MM_INSTALL_DIR=/opt/minimega
7-
ENV MINIMEGA_CONFIG=/etc/default/minimega
8-
ENV MM_BASE=/tmp/minimega
9-
ENV USER=firewheel
10-
ENV USER_UID=1001750000
11-
ENV GRPC_HOSTNAME=localhost
12-
ENV EXPERIMENT_INTERFACE=lo
5+
## User Arguments
6+
ARG USER=firewheel
7+
ARG USER_UID=1001750000
8+
9+
## Minimega Arguments
10+
ARG MM_BASE=/tmp/minimega
11+
ARG MM_RUN_PATH=/tmp/minimega
12+
ARG MM_FILEPATH=/tmp/minimega/files
13+
ARG MM_PORT=9000
14+
ARG MM_DEGREE=1
15+
ARG MM_CONTEXT=firewheel
16+
ARG MM_FORCE=true
17+
ARG MM_LOGLEVEL=debug
18+
19+
## FIREWHEEL Arguments
20+
ARG GRPC_HOSTNAME=localhost
21+
ARG EXPERIMENT_INTERFACE=lo
22+
ARG OUTPUT_DIR=/scratch/firewheel
23+
ARG LOGGING_ROOT_DIR=/scratch/firewheel
24+
25+
# --#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-- #
1326

1427
# Install dependencies
1528
RUN export DEBIAN_FRONTEND=noninteractive && \
@@ -61,15 +74,16 @@ RUN bash -c "python3.10 -m venv /fwpy \
6174
# Configure Firewheel
6275
RUN bash -c "source /fwpy/bin/activate && \
6376
mkdir -p /var/log/minimega && \
64-
mkdir -p /scratch/firewheel && \
65-
firewheel config set -s system.default_group $USER && \
66-
firewheel config set -s minimega.experiment_interface lo && \
67-
firewheel config set -s system.default_output_dir /scratch/firewheel && \
77+
mkdir -p ${OUTPUT_DIR} && \
78+
firewheel config set -s system.default_group ${USER} && \
79+
firewheel config set -s minimega.experiment_interface ${EXPERIMENT_INTERFACE} && \
80+
firewheel config set -s system.default_output_dir ${OUTPUT_DIR} && \
6881
firewheel config set -s minimega.base_dir /tmp/minimega && \
69-
firewheel config set -s minimega.files_dir /tmp/minimega/files && \
82+
firewheel config set -s minimega.files_dir ${MM_FILEPATH} && \
7083
firewheel config set -s python.venv /fwpy && \
7184
firewheel config set -s python.bin python3 && \
72-
firewheel config set -s logging.root_dir /scratch/firewheel" \
85+
firewheel config set -s grpc.hostname ${GRPC_HOSTNAME} && \
86+
firewheel config set -s logging.root_dir ${LOGGING_ROOT_DIR}" \
7387
|| { echo "Firewheel configuration failed"; exit 1; }
7488

7589
# Set up Bash completion
@@ -82,6 +96,9 @@ RUN bash -c "source /fwpy/bin/activate && \
8296

8397
RUN firewheel repository install -s -i || { echo "Repository installation failed"; exit 1; }
8498

99+
# Switch SSHD to use 2222 to prevent conflicts with host system
100+
RUN echo "Port 2222" >> /etc/ssh/sshd_config
101+
85102
RUN cp /usr/bin/sudo /usr/bin/sudo-old && \
86103
cp /usr/bin/chgrp /usr/bin/chgrp-old
87104

docker/fsroot/usr/local/bin/entry

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,30 @@ function yl() {
1111
echo -e "\033[33;1m" "$@" "\033[m"
1212
}
1313

14+
15+
HN="$(hostname)"
16+
1417
# Let the SSH server run without systemd
1518
mkdir /var/run/sshd
1619

1720
# Start the SSH server
18-
/usr/sbin/sshd
21+
/usr/sbin/sshd -E /var/log/auth.log
1922
ssh-keygen -f ~/.ssh/id_rsa -N "" &>/dev/null
2023
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
2124
if [ -e ~/.ssh/config ];
2225
then
2326
yl "SSH config already existed, not modifying it";
2427
else
2528
cat << EOF > ~/.ssh/config
26-
Host *
29+
Host $HN
2730
StrictHostKeyChecking no
31+
Port 2222
2832
EOF
2933
fi
3034

3135
export HOME=/root
3236

33-
HN="$(hostname)"
34-
35-
FILEPATH="/tmp/minimega/files"
37+
FILEPATH="$(firewheel config get minimega.files_dir)"
3638
mkdir -p $FILEPATH
3739

3840
grn "Starting minimega... "
@@ -45,9 +47,7 @@ firewheel config set -s cluster.control "$HN" &>/dev/null
4547
firewheel config set -s cluster.compute "" &>/dev/null
4648
firewheel config set -s cluster.compute "$HN" &>/dev/null
4749
firewheel config set -s discovery.hostname localhost &>/dev/null
48-
firewheel config set -s grpc.hostname localhost &>/dev/null
4950
firewheel config set -s minimega.use_gre True
50-
firewheel config set -s minimega.files_dir $FILEPATH
5151

5252
firewheel init &>/dev/null
5353
firewheel sync &>/dev/null

0 commit comments

Comments
 (0)