-
Notifications
You must be signed in to change notification settings - Fork 224
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
Dockerfile failed to build #184
Comments
To make it easier, and keep using the Alpine repo, we could just pull FROM python:3.12-alpine AS base
ENV PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PYTHONUNBUFFERED=1
RUN apk update && \
apk upgrade && \
apk add --no-cache libgcc
FROM python:3.12-alpine AS builder
ENV PIP_DEFAULT_TIMEOUT=100 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1
WORKDIR /app
RUN apk update && \
apk upgrade && \
echo "@edge https://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories && \
apk add cargo@edge && \
apk add gcc libc-dev libffi-dev alpine-sdk bsd-compat-headers openssl-dev python3-dev && \
python -m pip install --upgrade pip && \
pip install poetry
RUN python -m venv /venv
COPY ["pyproject.toml", "./"]
COPY ["poetry.lock", "./"]
RUN poetry export -f requirements.txt | /venv/bin/pip install -r /dev/stdin
COPY . .
RUN poetry build && /venv/bin/pip install dist/*.whl
FROM base AS final
WORKDIR /app
COPY --from=builder /venv /venv
ENV PATH="/venv/bin:${PATH}"
# CMD [ "mitmproxy2swagger" ]
ENTRYPOINT [ "mitmproxy2swagger" ] |
And now that I review it, So I've made a quick test and migrated the Dockerfile to use a Debian base image in combination with Of course, not all are advantages, the image gets a bit bigger. Not some crazy amount, from 160MB it grows to to 230MB. Still smaller than the This is it, just in case you wanna test it: FROM python:3.12-slim-bookworm AS builder
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
ENV UV_HTTP_TIMEOUT=100 \
UV_NO_CACHE=1
WORKDIR /app
RUN uv pip install --system poetry poetry-plugin-export
COPY pyproject.toml poetry.lock ./
RUN uv venv /venv && \
poetry config warnings.export false && \
poetry export -f requirements.txt -o requirements.txt && \
VIRTUAL_ENV=/venv uv pip install -r requirements.txt
COPY . .
RUN poetry build && \
VIRTUAL_ENV=/venv uv pip install dist/*.whl
FROM python:3.12-slim-bookworm AS final
ENV PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PYTHONUNBUFFERED=1
WORKDIR /app
COPY --from=builder /venv /venv
ENV PATH="/venv/bin:${PATH}"
ENTRYPOINT [ "mitmproxy2swagger" ] |
Indeed that's a good idea ! I didn't wanted to have a drastic change of behaviour in my initial proposal but I fully support your rework. It also works flawlessly on my side ! |
Thanks guys for the feedback. @alvarogonzalez-packlink Is it okay if I put your Dockerfile in the project? |
No prob, all yours! If you want it as a PR just let me know, but feel free of just copy-pasting it as you want 😊 |
on Mac OS 14.7 with podman, I failed to build the docker due to mitmproxy-rs requires a newer version of rustc ( [email protected] requires rustc 1.80
[email protected] requires rustc 1.80)
I changed the dockerfile to get latest rust release and it worked fine afterward:
The text was updated successfully, but these errors were encountered: