60 lines
1.5 KiB
Docker
60 lines
1.5 KiB
Docker
# First stage: build the Python app
|
|
FROM python:3.13.3-bookworm
|
|
|
|
# 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
|
|
ENV APP_HOME=/home/app/web
|
|
RUN mkdir $APP_HOME
|
|
RUN mkdir $APP_HOME/staticfiles
|
|
RUN mkdir $APP_HOME/mediafiles
|
|
WORKDIR $APP_HOME
|
|
|
|
# set environment variables
|
|
ENV PYTHONDONTWRITEBYTECODE 1
|
|
ENV PYTHONUNBUFFERED 1
|
|
|
|
# install system dependencies
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends gcc
|
|
|
|
# lint
|
|
RUN pip install --upgrade pip
|
|
# RUN pip install flake8==6.0.0
|
|
# COPY . /usr/src/app/
|
|
# RUN flake8 --ignore=E501,F401 .
|
|
|
|
# install python dependencies
|
|
COPY ./requirements.txt .
|
|
# RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt
|
|
RUN pip install -r requirements.txt
|
|
|
|
# install dependencies
|
|
# RUN apt-get update && apt-get install -y --no-install-recommends netcat
|
|
# 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/*
|
|
|
|
# copy entrypoint.prod.sh
|
|
# COPY ./entrypoint.prod.sh .
|
|
# RUN sed -i 's/\r$//g' $APP_HOME/entrypoint.prod.sh
|
|
# RUN chmod +x $APP_HOME/entrypoint.prod.sh
|
|
|
|
# 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.prod.sh
|
|
# ENTRYPOINT ["/home/app/web/entrypoint.prod.sh"]
|
|
ENTRYPOINT ["sh", "/entrypoint.sh"] |