Skip to content

Commit

Permalink
dev: cleanup devcontainer (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
fstreun authored Aug 19, 2024
1 parent d3b0c97 commit e79269f
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 12 deletions.
14 changes: 12 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../docker/lf.Dockerfile"
"dockerfile": "../docker/lf.Dockerfile",
// Update 'args' to add any environment variables.
"args": {"DPDK_MINIMAL_BUILD": "true"}
},

"containerEnv": {
"SHELL": "/bin/bash"
},

// Arguments:
Expand All @@ -15,7 +21,11 @@

// Mounts:
// - Hugepages
"mounts": ["source=/dev/hugepages,target=/dev/hugepages,type=bind"]
// - Docker socket for docker-from-docker support
"mounts": [
"source=/dev/hugepages,target=/dev/hugepages,type=bind",
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
]

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
# This job runs the devcontainer/ci action to build and run the dev container
# and execute the tests in the container. Because building the container is
# time-consuming, we only run this job nightly.
docker_dev:
devcontainer_test:
needs: check_change
if: ${{ needs.check_change.outputs.main_changed != 'false' }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Start dev container
run: cd docker && ./docker.sh dev_create && ./docker.sh dev_up
- name: Run tests in dev container
run: cd docker && ./docker.sh dev_exec ls -al lightning-filter && ./docker.sh dev_exec bash lightning-filter/tests.sh
run: cd docker && ./docker.sh dev_exec bash tests.sh
- name: Upload artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ build-base-image:
@echo "Building $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):$(TAG_BASE)"
docker build --target lf-base -t $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):$(TAG_BASE) \
--build-arg DPDK_MINIMAL_BUILD=$(DPDK_MINIMAL_BUILD) \
-f base.Dockerfile .
-f lf.Dockerfile .

pull-base-image:
@echo "Pulling $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME) by SHA256 digest"
Expand All @@ -47,7 +47,7 @@ build-dev-image:
@echo "Building $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):$(TAG_DEV)"
docker build --target lf-dev -t $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):$(TAG_DEV) \
--build-arg DPDK_MINIMAL_BUILD=$(DPDK_MINIMAL_BUILD) \
-f base.Dockerfile .
-f lf.Dockerfile .

pull-dev-image:
@echo "Pulling $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):$(TAG_DEV) by SHA256 digest"
Expand Down
2 changes: 1 addition & 1 deletion docker/dev.digest
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sha256:92445ec8907ca98871fb2f2ceae1898e5bbb0106c61cfc98481473624a5ab1d3
sha256:0d335796397f08d0883a9996ecaba77aadc44758f1f5083ef81cd031f3715415
3 changes: 2 additions & 1 deletion docker/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ base_dir=$script_dir/..

cmd_dev_create() {
DEV_VERSION=$(cat dev.version)
# XXX: We should create the dev container defined in .devconainter/devcontainer.json
docker create --name lf-dev-container --privileged --net=host \
-v $base_dir:/home/lf/lightning-filter/ \
-v $base_dir:/home/lf/lightning-filter/ -w /home/lf/lightning-filter/ \
-v /dev/hugepages:/dev/hugepages -v /sys/bus/pci/devices:/sys/bus/pci/devices \
streun/lightning-filter:$DEV_VERSION sleep infinity
}
Expand Down
13 changes: 9 additions & 4 deletions docker/lf.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

FROM ubuntu:jammy AS lf-base


# With DPDK_MINIMAL_BUILD set to true, DPDK is build without host machine optimization, e.g., SSE2,
# providing better compatibility with different systems (useful for CI pipelines).
ARG DPDK_MINIMAL_BUILD="false"
Expand All @@ -25,7 +24,7 @@ RUN apt-get update && \
RUN curl -LO https://golang.org/dl/go1.21.2.linux-amd64.tar.gz && \
echo "f5414a770e5e11c6e9674d4cd4dd1f4f630e176d1828d3427ea8ca4211eee90d go1.21.2.linux-amd64.tar.gz" | sha256sum -c && \
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.2.linux-amd64.tar.gz
ENV PATH /usr/local/go/bin:$PATH
ENV PATH=/usr/local/go/bin:$PATH

# Install DPDK
RUN curl -LO https://fast.dpdk.org/rel/dpdk-23.11.tar.xz && \
Expand All @@ -43,12 +42,12 @@ ARG USER=lf

# Allow the lf-build user to use sudo without a password
RUN groupadd --gid $GID --non-unique $USER && \
useradd $USER --create-home --shell /bin/bash --non-unique --uid $UID --gid $GID && \
useradd $USER --create-home --shell /bin/bash --uid $UID --gid $GID && \
echo "$USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Set the default user for the container
USER $USER
ENV USER $USER
ENV USER=$USER
# Set the working directory for the user
WORKDIR /home/$USER

Expand All @@ -73,3 +72,9 @@ RUN git clone https://github.com/scionproto/scion.git && \
go build -o ./bin/ ./scion-pki/cmd/scion-pki
ENV SCION_DIR=/home/$USER/scion
ENV SCION_BIN=/home/$USER/scion/bin

# Install docker (with convenience scripts)
RUN curl -fsSL https://get.docker.com -o get-docker.sh && \
sudo sh get-docker.sh && \
sudo usermod -aG docker $USER && \
sudo rm get-docker.sh

0 comments on commit e79269f

Please sign in to comment.