Skip to content

Commit

Permalink
update docker context (#309)
Browse files Browse the repository at this point in the history
* update docker context

* bump ubuntu image to 24.04
  • Loading branch information
nstoik authored Mar 19, 2024
1 parent 5a515b5 commit 29875d6
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
6 changes: 3 additions & 3 deletions 1wire/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:22.04
FROM ubuntu:24.04

RUN apt-get update && \
apt-get upgrade -y && \
Expand All @@ -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

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/)
4 changes: 2 additions & 2 deletions device/.devcontainer/devcontainer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions device/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 .

Expand Down Expand Up @@ -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

Expand All @@ -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=
Expand Down
7 changes: 4 additions & 3 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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}"]
}
4 changes: 2 additions & 2 deletions docker-compose.devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand Down

0 comments on commit 29875d6

Please sign in to comment.