From 29875d690bd0e9b64a9d2253273c4f8a2a4dabaa Mon Sep 17 00:00:00 2001 From: Nelson Stoik Date: Mon, 18 Mar 2024 23:48:12 -0600 Subject: [PATCH] update docker context (#309) * update docker context * bump ubuntu image to 24.04 --- 1wire/Dockerfile | 6 +++--- README.md | 5 +++-- device/.devcontainer/devcontainer.Dockerfile | 4 ++-- device/Dockerfile | 8 ++++---- docker-bake.hcl | 7 ++++--- docker-compose.devcontainer.yml | 4 ++-- docker-compose.yml | 8 ++++---- 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/1wire/Dockerfile b/1wire/Dockerfile index 0ce2890..3bc7009 100644 --- a/1wire/Dockerfile +++ b/1wire/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:22.04 +FROM ubuntu:24.04 RUN apt-get update && \ apt-get upgrade -y && \ @@ -7,11 +7,11 @@ RUN apt-get update && \ apt-get autoclean && \ rm -rf /var/lib/apt/lists/* -COPY start.sh /start.sh +COPY 1wire/start.sh /start.sh RUN ["chmod", "+x", "/start.sh"] -COPY owfs.conf /etc/owfs.conf +COPY 1wire/owfs.conf /etc/owfs.conf EXPOSE 2121 diff --git a/README.md b/README.md index eab7580..e655e38 100644 --- a/README.md +++ b/README.md @@ -121,9 +121,9 @@ docker build {PATH} --file {PATH}/Dockerfile --no-cache --pull --build-arg {ENV ``` An example command for building the fd_device container version 1.0.0-rc is: ```bash -docker build device --file device/Dockerfile --no-cache --pull --tag nstoik/fd_device:1.0.0-rc +docker build . --file device/Dockerfile --no-cache --pull --tag nstoik/fd_device:1.0.0-rc ``` -- {PATH} is the submodule path +- {PATH} is the context of the build - --build-arg is optional and can pass in environment variables to docker build. It can be repeated for multiple variables. - {ENV NAME} is the name of the environment variable - {ENV VALUE} is the value of the environment variable @@ -179,3 +179,4 @@ A few additional comments on the `docker-bake.hcl` file: - push will push the built images to the registry - --load is optional and will load the image into docker - When using --load, only a sinle platform can be specified. An example of overriding the platform for 'linux/amd64' is `--set default.platform=linux/amd64` + - Is no longer an issue if using containerd as the backend (https://www.docker.com/blog/extending-docker-integration-with-containerd/) diff --git a/device/.devcontainer/devcontainer.Dockerfile b/device/.devcontainer/devcontainer.Dockerfile index 6335dcd..9e95142 100644 --- a/device/.devcontainer/devcontainer.Dockerfile +++ b/device/.devcontainer/devcontainer.Dockerfile @@ -52,8 +52,8 @@ RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhisto # Change to the newly created user USER $USER_UID:$USER_GID -COPY --chown=${USER_UID}:${USER_GID} . $WORKING_DIR/ -COPY --chown=${USER_UID}:${USER_GID} Pipfile* setup.py $WORKING_DIR/ +COPY --chown=${USER_UID}:${USER_GID} device/. $WORKING_DIR/ +COPY --chown=${USER_UID}:${USER_GID} device/Pipfile* device/setup.py $WORKING_DIR/ WORKDIR $WORKING_DIR # Set up the dev environment (this is run manually inside the container instead for dev) diff --git a/device/Dockerfile b/device/Dockerfile index f3ee99c..a46fde1 100644 --- a/device/Dockerfile +++ b/device/Dockerfile @@ -27,7 +27,7 @@ RUN pip install -U pip && pip install pipenv && \ # Change to the newly created user USER $USER_UID:$USER_GID -COPY --chown=${USER_UID}:${USER_GID} Pipfile* setup.py $WORKING_DIR/ +COPY --chown=${USER_UID}:${USER_GID} device/Pipfile* device/setup.py $WORKING_DIR/ WORKDIR $WORKING_DIR RUN pipenv install --deploy --ignore-pipfile @@ -38,7 +38,7 @@ FROM build-stage as dev-stage ARG USER_UID=1000 ARG USER_GID=$USER_UID -COPY --chown=${USER_UID}:${USER_GID} . $WORKING_DIR/ +COPY --chown=${USER_UID}:${USER_GID} device/. $WORKING_DIR/ RUN pipenv sync --dev # RUN pipenv run pip install -e . @@ -83,7 +83,7 @@ RUN pip install -U pip && pip install pipenv && \ # Change to the newly created user USER $USER_UID:$USER_GID -COPY --chown=${USER_UID}:${USER_GID} . $WORKING_DIR/ +COPY --chown=${USER_UID}:${USER_GID} device/. $WORKING_DIR/ # here we copy the venv from the dev stage to the prod stage COPY --from=build-stage /home/${USERNAME}/.local/share /home/${USERNAME}/.local/share @@ -92,7 +92,7 @@ RUN pipenv run pip install -e . ENV SCRIPT_WORKING_DIR=$WORKING_DIR -COPY --chown=${USER_UID}:${USER_GID} --chmod=+x start.sh $WORKING_DIR/start.sh +COPY --chown=${USER_UID}:${USER_GID} --chmod=+x device/start.sh $WORKING_DIR/start.sh # Switch back to dialog for any ad-hoc use of apt-get ENV DEBIAN_FRONTEND= diff --git a/docker-bake.hcl b/docker-bake.hcl index c54e76b..6f7c3d1 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -10,20 +10,21 @@ group "default" { } target "default" { - dockerfile = "Dockerfile" platforms = ["linux/amd64", "linux/arm64", "linux/arm/v7"] pull = true } target "fd_device" { inherits = ["default"] - context = "device" + context = "." + dockerfile = "device/Dockerfile" tags = ["nstoik/fd_device:${TAG}"] target = "${MULTI_STAGE_TARGET}" } target "fd_1wire" { inherits = ["default"] - context = "1wire" + context = "." + dockerfile = "1wire/Dockerfile" tags = ["nstoik/fd_1wire:${TAG}"] } \ No newline at end of file diff --git a/docker-compose.devcontainer.yml b/docker-compose.devcontainer.yml index 88eb411..5a1b17e 100644 --- a/docker-compose.devcontainer.yml +++ b/docker-compose.devcontainer.yml @@ -4,8 +4,8 @@ services: device: image: nstoik/fd_device:devcontainer build: - context: ./device - dockerfile: .devcontainer/devcontainer.Dockerfile + context: . + dockerfile: device/.devcontainer/devcontainer.Dockerfile volumes: # this is for vs code file editing inside the container from a local host - .:/workspaces:cached diff --git a/docker-compose.yml b/docker-compose.yml index 9ce156d..d7c7894 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,8 @@ services: image: nstoik/fd_device:${FD_DEVICE} container_name: fd_device build: - context: ./device - dockerfile: Dockerfile + context: . + dockerfile: device/Dockerfile environment: FD_DEVICE_CONFIG: ${FD_DEVICE_CONFIG} FD_DEVICE_LOG_LEVEL: ${FD_DEVICE_LOG_LEVEL} @@ -25,10 +25,10 @@ services: image: nstoik/fd_1wire:${FD_1WIRE} container_name: fd_1wire build: - context: ./1wire - dockerfile: Dockerfile devices: - "/dev/i2c-1:/dev/i2c-1" + context: . + dockerfile: 1wire/Dockerfile networks: - farm_device restart: unless-stopped