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

docker: slim image, use rustup, build deps only on armv7 #352

Merged
merged 1 commit into from
Mar 1, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ jobs:
TAG_NAME=${GITHUB_REF##*/}
# Change slashes to hyphens
TAG_NAME=${TAG_NAME//\//-}
docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 -t flyte/mqtt-io:${TAG_NAME} -t flyte/mqtt-io:latest --push --build-arg BUILDX_QEMU_ENV=true .
docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 -t flyte/mqtt-io:${TAG_NAME} -t flyte/mqtt-io:latest --push .
- if: github.event_name == 'push'
run: |
# Remove prefix push
TAG_NAME=${GITHUB_REF##*/}
# Change slashes to hyphens
TAG_NAME=${TAG_NAME//\//-}
docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 -t flyte/mqtt-io:${TAG_NAME} --push --build-arg BUILDX_QEMU_ENV=true .
docker buildx build --platform linux/arm/v7,linux/arm64/v8,linux/amd64 -t flyte/mqtt-io:${TAG_NAME} --push .

generate_docs:
name: Generate Documentation
Expand Down
32 changes: 15 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,29 @@
# when building multiarch using buildx, then try this:
# https://github.com/docker/buildx/issues/495#issuecomment-761562905

FROM python:3.8-buster AS base
FROM python:3.8-slim-buster AS base

ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8


FROM base AS requirements

ARG BUILDX_QEMU_ENV
RUN apt-get update && \
apt-get install -y lsb-release rustc libssl-dev libffi-dev python3-venv && \
apt-get clean && \
rm -rf /var/lib/apt-/lists/*
# On linux/arm/v7 the cryptography package has no binary wheel, so we need its build
# dependencies. For rust, install the latest from rustup to avoid issues.
ARG TARGETPLATFORM
RUN if [ "${TARGETPLATFORM}" = "linux/arm/v7" ]; then \
apt-get update && \
apt-get install -y lsb-release curl g++ pkg-config libssl-dev libffi-dev && \
\
(curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y) \
fi
ENV PATH="/root/.cargo/bin:${PATH}"

# This nonsense is required for this reason:
# https://github.com/JonasAlfredsson/docker-nginx-certbot/issues/30

RUN pip install --no-cache-dir wheel setuptools-rust && \
if [ "${BUILDX_QEMU_ENV}" = "true" -a "$(getconf LONG_BIT)" = "32" ]; then \
pip install --no-cache-dir cryptography==3.3.2; \
fi && \
pip install --no-cache-dir poetry

COPY pyproject.toml ./
RUN poetry export -o /requirements.txt && \
RUN pip install --no-cache-dir poetry && \
poetry export -o /requirements.txt && \
mkdir -p /home/mqtt_io && \
python -m venv /home/mqtt_io/venv && \
/home/mqtt_io/venv/bin/pip install wheel
Expand All @@ -41,8 +39,8 @@ WORKDIR /home/mqtt_io

COPY --from=requirements --chown=mqtt_io /home/mqtt_io/venv ./venv
COPY --from=requirements /requirements.txt ./
RUN venv/bin/python -m pip install --upgrade pip
RUN venv/bin/pip install -r requirements.txt
RUN venv/bin/python -m pip install --no-cache-dir --upgrade pip
RUN venv/bin/pip install --no-cache-dir -r requirements.txt

COPY --chown=mqtt_io mqtt_io mqtt_io

Expand Down
Loading