|
| 1 | +FROM python:3.9-slim-buster |
| 2 | + |
| 3 | +ENV PYTHONUNBUFFERED 1 |
| 4 | +ENV PYTHONDONTWRITEBYTECODE 1 |
| 5 | + |
| 6 | +RUN apt-get update \ |
| 7 | + # dependencies for building Python packages |
| 8 | + && apt-get install -y build-essential \ |
| 9 | + # psycopg2 dependencies |
| 10 | + && apt-get install -y libpq-dev \ |
| 11 | + # Additional dependencies |
| 12 | + && apt-get install -y telnet netcat \ |
| 13 | + # cleaning up unused files |
| 14 | + && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ |
| 15 | + && rm -rf /var/lib/apt/lists/* |
| 16 | + |
| 17 | +RUN addgroup --system flask \ |
| 18 | + && adduser --system --ingroup flask flask |
| 19 | + |
| 20 | +# Requirements are installed here to ensure they will be cached. |
| 21 | +COPY ./requirements.txt /requirements.txt |
| 22 | +RUN pip install -r /requirements.txt |
| 23 | + |
| 24 | +COPY ./compose/production/flask/entrypoint /entrypoint |
| 25 | +RUN sed -i 's/\r$//g' /entrypoint |
| 26 | +RUN chmod +x /entrypoint |
| 27 | +RUN chown flask /entrypoint |
| 28 | + |
| 29 | +COPY ./compose/production/flask/start /start |
| 30 | +RUN sed -i 's/\r$//g' /start |
| 31 | +RUN chmod +x /start |
| 32 | +RUN chown flask /start |
| 33 | + |
| 34 | +COPY ./compose/production/flask/celery/worker/start /start-celeryworker |
| 35 | +RUN sed -i 's/\r$//g' /start-celeryworker |
| 36 | +RUN chmod +x /start-celeryworker |
| 37 | +RUN chown flask /start-celeryworker |
| 38 | + |
| 39 | +COPY ./compose/production/flask/celery/beat/start /start-celerybeat |
| 40 | +RUN sed -i 's/\r$//g' /start-celerybeat |
| 41 | +RUN chmod +x /start-celerybeat |
| 42 | +RUN chown flask /start-celerybeat |
| 43 | + |
| 44 | +COPY ./compose/production/flask/celery/flower/start /start-flower |
| 45 | +RUN sed -i 's/\r$//g' /start-flower |
| 46 | +RUN chmod +x /start-flower |
| 47 | + |
| 48 | +RUN mkdir /app |
| 49 | +RUN mkdir /app/upload |
| 50 | +RUN mkdir /app/flower_db |
| 51 | +WORKDIR /app |
| 52 | + |
| 53 | +# copy project code |
| 54 | +COPY . . |
| 55 | + |
| 56 | +RUN chown -R flask:flask /app |
| 57 | + |
| 58 | +USER flask |
| 59 | + |
| 60 | +ENTRYPOINT ["/entrypoint"] |
0 commit comments