mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-06-28 15:53:57 +00:00
Refactor Docker and Django configuration
- Update Dockerfile to use Python 3.11-slim and optimize build steps - Remove Dockerfile.prod and update docker-compose.yml - Remove entrypoint.sh and twilio dependency - Modify Django settings for production security and configuration - Update user serializer to include group permissions - Enhance CSRF and SSL configuration settings
This commit is contained in:
30
Dockerfile
30
Dockerfile
@ -3,7 +3,7 @@
|
||||
###########
|
||||
|
||||
# pull official base image
|
||||
FROM python:3.11.4-slim-buster AS builder
|
||||
FROM python:3.11-slim AS builder
|
||||
|
||||
# set work directory
|
||||
WORKDIR /app
|
||||
@ -14,7 +14,9 @@ ENV PYTHONUNBUFFERED 1
|
||||
|
||||
# install system dependencies
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends gcc
|
||||
apt-get install -y --no-install-recommends gcc && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# lint
|
||||
RUN pip install --upgrade pip
|
||||
@ -30,7 +32,7 @@ RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.t
|
||||
#########
|
||||
|
||||
# pull official base image
|
||||
FROM python:3.11.4-slim-buster
|
||||
FROM python:3.11-slim
|
||||
|
||||
# create directory for the app user
|
||||
RUN mkdir -p /home/app
|
||||
@ -39,15 +41,15 @@ RUN mkdir -p /home/app
|
||||
RUN addgroup --system app && adduser --system --group app
|
||||
|
||||
# create the appropriate directories
|
||||
ENV HOME=/home/app
|
||||
ENV APP_HOME=/home/app/api
|
||||
RUN mkdir $APP_HOME
|
||||
RUN mkdir $APP_HOME/staticfiles
|
||||
RUN chmod -R 777 $APP_HOME/staticfiles
|
||||
WORKDIR $APP_HOME
|
||||
RUN mkdir -p /home/app/api/staticfiles
|
||||
RUN chmod -R 777 /home/app/api/staticfiles
|
||||
WORKDIR /home/app/api
|
||||
|
||||
# install dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends netcat
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends netcat-openbsd && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=builder /app/wheels /wheels
|
||||
COPY --from=builder /app/requirements.txt .
|
||||
RUN pip install --upgrade pip
|
||||
@ -55,14 +57,14 @@ 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
|
||||
RUN sed -i 's/\r$//g' /home/app/api/entrypoint.prod.sh
|
||||
RUN chmod +x /home/app/api/entrypoint.prod.sh
|
||||
|
||||
# copy project
|
||||
COPY . $APP_HOME
|
||||
COPY . /home/app/api
|
||||
|
||||
# chown all the files to the app user
|
||||
RUN chown -R app:app $APP_HOME
|
||||
RUN chown -R app:app /home/app/api
|
||||
|
||||
# change to the app user
|
||||
USER app
|
||||
|
Reference in New Issue
Block a user