Skip to content

Commit

Permalink
prevent unused files to end up in docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
elcojacobs committed Jan 15, 2025
1 parent a5a900b commit ce85cf0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
*.egg-info
brewblox-proto
test
firmware/*.map
firmware/*.lst
8 changes: 4 additions & 4 deletions Dockerfile.flasher
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# syntax=docker.io/docker/dockerfile:1.7-labs
# syntax=docker/dockerfile:1-labs
FROM python:3.11-slim-bookworm

ENV PIP_EXTRA_INDEX_URL=https://www.piwheels.org/simple
Expand All @@ -15,12 +15,12 @@ RUN <<EOF bash
libatomic1 \
usbutils

pip3 install \
pip3 install --no-cache-dir \
cffi==1.17.1 \
cryptography==42.0.8 \
esptool

CLI_VERSION="3.24.0"
CLI_VERSION="3.29.1"
ARCH="$(dpkg --print-architecture)"
if [ "\${ARCH}" = "amd64" ]; then
CLI_ARCH="x64"
Expand All @@ -41,6 +41,6 @@ RUN <<EOF bash
rm -rf /var/cache/apt/archives /var/lib/apt/lists
EOF

COPY --exclude=*.sim ./firmware/* ./
COPY --exclude=*.sim firmware/ ./

ENTRYPOINT [ "/bin/bash" ]
11 changes: 7 additions & 4 deletions Dockerfile.service
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ RUN ARCH="$(dpkg --print-architecture)"; \
set -ex; \
cd /app/firmware; \
if [ "$ARCH" = "amd64" ]; then \
rm -f ./brewblox-{arm32,arm64}.sim; \
echo "Building for amd64"; \
rm -f brewblox-arm32.sim; rm -f brewblox-arm64.sim; \
elif [ "$ARCH" = "armhf" ]; then \
rm -f ./brewblox-{amd64,arm64}.sim; \
echo "Building for armhf"; \
rm -f brewblox-amd64.sim; rm -f brewblox-arm64.sim; \
elif [ "$ARCH" = "arm64" ]; then \
rm -f ./brewblox-{amd64,arm32}.sim; \
fi
echo "Building for arm64"; \
rm -f ./brewblox-amd64.sim; rm -f brewblox-arm32.sim; \
fi;

FROM python:3.11-slim-bookworm
EXPOSE 5000
Expand Down
1 change: 1 addition & 0 deletions brewblox_devcon_spark/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class ResetData(enum.Enum):
LISTENING_MODE_EXIT = '05'
FIRMWARE_UPDATE_SUCCESS = '06'
OUT_OF_MEMORY = '07'
FIRMWARE_UPDATE_TCP_SERVER_FAILED = '08'

def __str__(self):
return self.name
Expand Down
4 changes: 2 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def testclean(ctx: Context):
@task()
def image(ctx: Context, tag='local'):
with ctx.cd(ROOT):
ctx.run(f'docker build -t ghcr.io/brewblox/brewblox-devcon-spark:{tag} -f Dockerfile.service .')
ctx.run(f'docker build --load -t ghcr.io/brewblox/brewblox-devcon-spark:{tag} -f Dockerfile.service .')


@task()
Expand All @@ -121,7 +121,7 @@ def buildx(ctx: Context, tag='local', platform='linux/amd64,linux/arm/v7,linux/a
@task()
def flasher_image(ctx: Context, tag='local'):
with ctx.cd(ROOT):
ctx.run(f'docker build -t ghcr.io/brewblox/brewblox-firmware-flasher:{tag} -f Dockerfile.flasher .')
ctx.run(f'docker build --load -t ghcr.io/brewblox/brewblox-firmware-flasher:{tag} -f Dockerfile.flasher .')


@task()
Expand Down

0 comments on commit ce85cf0

Please sign in to comment.