diamond/api/Dockerfile

38 lines
723 B
Docker

###########
# BUILDER #
###########
FROM python:3.10 as builder
RUN apt-get update && \
apt-get install -y --no-install-recommends gcc
WORKDIR /usr/src/app
COPY ./requirements.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt
#########
# FINAL #
#########
FROM python:3.10
RUN mkdir -p /home/app
RUN addgroup --system app && adduser --system --group app
ENV HOME=/home/app
WORKDIR $HOME
RUN apt-get update && apt-get install -y libgl1-mesa-glx
COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /usr/src/app/requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache /wheels/*
COPY . $HOME
RUN chown -R app:app $HOME
USER app