2023-08-17 18:19:46 +02:00
|
|
|
# syntax=docker/dockerfile:1
|
|
|
|
|
|
|
|
FROM python:alpine
|
|
|
|
|
|
|
|
# Install cron daemon and supervisord
|
|
|
|
RUN apk add --no-cache dcron supervisor
|
|
|
|
|
|
|
|
# Create non-root user
|
|
|
|
ARG CUSTOM_UID
|
|
|
|
ARG CUSTOM_GID
|
|
|
|
ENV CUSTOM_USERNAME=django
|
|
|
|
ENV CUSTOM_GROUPNAME=django
|
|
|
|
RUN addgroup --gid ${CUSTOM_GID:-1000} ${CUSTOM_GROUPNAME} && \
|
|
|
|
adduser --uid ${CUSTOM_UID:-1000} --shell /bin/ash ${CUSTOM_USERNAME} --ingroup ${CUSTOM_GROUPNAME} --disabled-password && \
|
2023-08-17 20:14:34 +02:00
|
|
|
mkdir /app && chown ${CUSTOM_UID:-1000}:${CUSTOM_GID:-1000} /app && chmod 700 /app && \
|
|
|
|
mkdir -p /srv/static && chown ${CUSTOM_UID:-1000}:${CUSTOM_GID:-1000} /srv/static && chmod 700 /srv/static
|
2023-08-17 18:19:46 +02:00
|
|
|
ENV PATH "$PATH:/home/${CUSTOM_GROUPNAME}/.local/bin"
|
|
|
|
|
|
|
|
# Add supervisord conf
|
|
|
|
COPY production.supervisord.conf /etc/supervisord.conf
|
|
|
|
|
|
|
|
# Add cron job
|
|
|
|
COPY --chmod=600 django.crontab /etc/crontabs/django
|
|
|
|
|
|
|
|
# Copy source files
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --chown=${CUSTOM_USERNAME}:${CUSTOM_GROUPNAME} app/ /app/
|
|
|
|
|
|
|
|
# Install dependencies
|
|
|
|
RUN pip install -r requirements.txt
|
|
|
|
|
|
|
|
# Run supervisord
|
|
|
|
EXPOSE 8000/tcp
|
|
|
|
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]
|
2023-08-17 20:14:34 +02:00
|
|
|
#CMD ["uvicorn", "core.asgi:application", "--host", "0.0.0.0", "--port", "8000", "--access-log"]
|