########### # BUILDER # ########### # pull official base image FROM python:3.10 as builder # set work directory WORKDIR /usr/src/app # set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # install system dependencies RUN apt-get update && \ apt-get install -y --no-install-recommends gcc # install python dependencies COPY ./requirements.txt . RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt ######### # FINAL # ######### # pull official base image FROM python:3.10 # create directory for the app user RUN mkdir -p /home/app # create the app user RUN addgroup --system app && adduser --system --group app # create the appropriate directories ENV HOME=/home/app WORKDIR $HOME # install dependencies RUN apt-get update && apt-get install -y --no-install-recommends netcat-traditional 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/* RUN apt install libgl1 -y RUN apt install libglib2.0-0 -y # copy project COPY . $HOME RUN chown -R app:app $HOME # USER app ENV NO_AVX=1