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

refact: improve docker build with user & poetry

parent 401e6e06
No related branches found
No related tags found
No related merge requests found
Pipeline #2813 passed
FROM python:3.10-slim FROM python:3.10-slim as base
LABEL maintainer="David Trattnig <david.trattnig@subsquare.at>" LABEL maintainer="David Trattnig <david.trattnig@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 \
libpq-dev \ libpq-dev \
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 /srv/config /srv/logs /var/audio /etc/aura
RUN mkdir -p /srv/config COPY pyproject.toml poetry.lock README.md Makefile .env /srv/
COPY src /srv/src
COPY config/sample.engine.docker.ini /etc/aura/engine.ini
COPY pyproject.toml /srv
COPY poetry.lock /srv
COPY README.md /srv
COPY Makefile /srv
WORKDIR /srv WORKDIR /srv
RUN poetry install --without dev --no-interaction
# Start Service # Init Application
COPY ./src/aura_engine /srv/src/aura_engine
COPY config/sample.engine.docker.ini /etc/aura/engine.ini
RUN poetry install --no-interaction --no-ansi
# Update Permissions
RUN set -e \
&& adduser --home /srv --no-create-home --system --uid ${UID} --group ${USER} \
&& chown -R ${UID}:${GID} /srv /etc/aura /var/audio
ENTRYPOINT ["make"] ENTRYPOINT ["make"]
CMD ["run"] CMD ["run"]
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment