29 lines
673 B
Docker
29 lines
673 B
Docker
FROM python:3.12
|
||
|
||
# Prevents Python from writing pyc files to disk
|
||
ENV PYTHONDONTWRITEBYTECODE=1
|
||
#Prevents Python from buffering stdout and stderr
|
||
ENV PYTHONUNBUFFERED=1
|
||
|
||
# User
|
||
RUN useradd -m -r appuser && \
|
||
mkdir /opt/app && \
|
||
chown -R appuser /opt/app
|
||
|
||
WORKDIR /opt/app
|
||
|
||
# Copy the Django project and install dependencies
|
||
COPY requirements.txt /opt/app/
|
||
# run this command to install all dependencies
|
||
RUN pip install --no-cache-dir -r requirements.txt
|
||
|
||
COPY --chown=appuser:appuser . /opt/app/
|
||
|
||
RUN chmod -R 755 /opt
|
||
RUN chown -R appuser:appuser /opt
|
||
|
||
USER appuser
|
||
|
||
# Run Django’s server & workers
|
||
CMD ["sh", "-c", "/opt/app/initialize.sh && /opt/app/run.sh"]
|