Skip to content
Snippets Groups Projects
Commit 46963c85 authored by David Trattnig's avatar David Trattnig
Browse files

refact: improve docker build with Poetry & perms

parent 6555c51d
No related branches found
No related tags found
No related merge requests found
Pipeline #2815 passed
FROM python:3.9-slim FROM python:3.10-slim as base
LABEL maintainer="David Trattnig <david.trattnig@subsquare.at>" LABEL maintainer="David Trattnig <david@subsquare.at>"
# System Dependencies ENV UID=1000
ENV GID=1000
ENV USER=app
# Configure Poetry
ENV POETRY_VERSION=1.3.2
ENV POETRY_HOME=/opt/poetry
ENV POETRY_VENV=/opt/poetry-venv
ENV POETRY_CACHE_DIR=/opt/.cache
# System Dependencies
RUN apt-get update && apt-get -y install \ RUN apt-get update && apt-get -y install \
apt-utils \ apt-utils \
build-essential \ build-essential \
pip pip
RUN python3 -m pip install --upgrade pip
RUN pip install poetry
# Construct Image # Setup Poetry
RUN python3 -m venv $POETRY_VENV \
&& $POETRY_VENV/bin/pip install -U pip setuptools \
&& $POETRY_VENV/bin/pip install poetry==${POETRY_VERSION}
ENV PATH="${PATH}:${POETRY_VENV}/bin"
RUN mkdir -p /srv # Base Structure
RUN mkdir -p /srv/src RUN mkdir -p /srv/src/aura_engine_api /srv/config /srv/logs /etc/aura
RUN mkdir -p /srv/config COPY pyproject.toml poetry.lock README.md Makefile /srv/
RUN mkdir -p /var/log/aura
COPY src /srv/src WORKDIR /srv
# Init Application
COPY ./src/aura_engine_api /srv/src/aura_engine_api
COPY ./config/sample/gunicorn/sample-docker.gunicorn.conf.py /srv/config/gunicorn.conf.py COPY ./config/sample/gunicorn/sample-docker.gunicorn.conf.py /srv/config/gunicorn.conf.py
COPY ./config/sample.engine-api.docker.ini /srv/config/engine-api.ini COPY ./config/sample.engine-api.docker.ini /srv/config/engine-api.ini
COPY pyproject.toml /srv RUN poetry install --no-interaction --no-ansi
COPY poetry.lock /srv
COPY README.md /srv
COPY Makefile /srv
WORKDIR /srv # Update Permissions
RUN poetry install --without dev --no-interaction RUN set -e \
&& adduser --home /srv --no-create-home --system --uid ${UID} --group ${USER} \
&& chown -R ${UID}:${GID} /srv /etc/aura
# Start Service # Start Service
EXPOSE 8008 EXPOSE 8008
ENTRYPOINT ["make"] ENTRYPOINT ["make"]
CMD ["run"] CMD ["run"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment