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

feat(docker): use slim Debian-based Python 3.10 base image #83

Closed
wants to merge 4 commits into from
Closed
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
44 changes: 20 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
FROM quay.io/cdis/python:3.10-alpine-master as base
FROM quay.io/cdis/python:3.10-slim-buster

FROM base as builder
RUN apk add --no-cache --virtual .build-deps gcc musl-dev libffi-dev openssl-dev make postgresql-dev git curl
RUN pip install --upgrade pip
COPY pyproject.toml /src/pyproject.toml
COPY poetry.lock /src/poetry.lock
WORKDIR /src
RUN python -m venv /env \
&& . /env/bin/activate \
&& pip install --upgrade pip poetry==1.3.2 \
&& poetry install --without dev --no-interaction
ENV appname=src

# include code and run poetry again (this split allows for faster local builds when changing code and using docker cache):
COPY src /src/src
RUN . /env/bin/activate \
&& poetry install --without dev --no-interaction
RUN pip install --no-cache-dir --upgrade pip poetry==1.3.2

WORKDIR /$appname

# copy ONLY poetry artifact, install the dependencies but not indexd
# this will make sure than the dependencies is cached
COPY poetry.lock pyproject.toml /$appname/
RUN poetry config virtualenvs.create false \
&& poetry install -vv --no-root --only main --no-interaction \
&& poetry show -v

# copy source code ONLY after installing dependencies
COPY . /$appname

# install argo-wrapper
RUN poetry config virtualenvs.create false \
&& poetry install -vv --only main --no-interaction \
&& poetry show -v

FROM base
RUN apk add --no-cache postgresql-libs
COPY --from=builder /env /env
COPY --from=builder /src /src
WORKDIR /src
COPY config.ini .
ENV PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=UTF-8
CMD ["/env/bin/gunicorn", "src.argowrapper.asgi:app", "-b", "0.0.0.0:8000", "-k", "uvicorn.workers.UvicornWorker"]
#CMD ["sleep", "100000"]