FROM python:3 # 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 APP_HOME=/app RUN mkdir $APP_HOME WORKDIR $APP_HOME # install dependencies RUN apt-get update && apt-get install -y --no-install-recommends netcat-openbsd gcc COPY ./requirements.txt . RUN pip install -r requirements.txt # copy entrypoint.sh COPY ./entrypoint.sh $APP_HOME # copy project COPY . $APP_HOME # chown all the files to the app user RUN chown -R app:app $APP_HOME # change to the app user USER app # run entrypoint.sh ENTRYPOINT ["./entrypoint.sh"]