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
LABEL maintainer="David Trattnig <david.trattnig@subsquare.at>"
FROM python:3.10-slim as base
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 \
apt-utils \
build-essential \
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
RUN mkdir -p /srv/src
RUN mkdir -p /srv/config
RUN mkdir -p /var/log/aura
# Base Structure
RUN mkdir -p /srv/src/aura_engine_api /srv/config /srv/logs /etc/aura
COPY pyproject.toml poetry.lock README.md Makefile /srv/
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.engine-api.docker.ini /srv/config/engine-api.ini
COPY pyproject.toml /srv
COPY poetry.lock /srv
COPY README.md /srv
COPY Makefile /srv
RUN poetry install --no-interaction --no-ansi
WORKDIR /srv
RUN poetry install --without dev --no-interaction
# Update Permissions
RUN set -e \
&& adduser --home /srv --no-create-home --system --uid ${UID} --group ${USER} \
&& chown -R ${UID}:${GID} /srv /etc/aura
# Start Service
EXPOSE 8008
ENTRYPOINT ["make"]
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