Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent unused files to end up in docker images #630

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 9 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 @@ -8,19 +8,22 @@ WORKDIR /app
RUN <<EOF bash
set -ex

# Install only runtime dependencies
apt-get update -q
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
libatomic1 \
usbutils

pip3 install \
# Install Python dependencies using only pre-built wheels
pip3 install --only-binary=:all: \
cffi==1.17.1 \
cryptography==42.0.8 \
esptool

CLI_VERSION="3.24.0"
# Install Particle CLI
CLI_VERSION="3.29.1"
ARCH="$(dpkg --print-architecture)"
if [ "\${ARCH}" = "amd64" ]; then
CLI_ARCH="x64"
Expand All @@ -37,10 +40,12 @@ RUN <<EOF bash
chmod +x ./particle
mv ./particle /usr/local/bin/

# Clean up
apt-get autoremove -y
apt-get clean
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
2 changes: 1 addition & 1 deletion brewblox_devcon_spark/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async def wait_acknowledged(self) -> Literal[True]:

def set_synchronized(self):
if not self._acknowledged_ev.is_set():
raise RuntimeError('Failed to set synchronized status: ' 'service is not acknowledged')
raise RuntimeError('Failed to set synchronized status: service is not acknowledged')

self._status_desc.connection_status = 'SYNCHRONIZED'

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
2 changes: 1 addition & 1 deletion test/test_connection_cbox_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def expected_events():


def expected_data():
return ['0A' '00' '01' '28C80E9A0300009C', '34234']
return ['0A' + '00' + '01' + '28C80E9A0300009C', '34234']


def test_parser():
Expand Down