mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-08-08 02:45:59 +00:00
Refactor Docker configuration and API endpoints
- Merged production and development Docker configurations - Updated Dockerfile to use multi-stage build - Removed separate Dockerfile.prod - Modified docker-compose.yml for production settings - Added new API endpoints for user filtering by ID card - Updated serializers and views for Atoll and Island management - Enhanced user and atoll-related filters and views
This commit is contained in:
65
Dockerfile
65
Dockerfile
@@ -1,5 +1,9 @@
|
||||
###########
|
||||
# BUILDER #
|
||||
###########
|
||||
|
||||
# pull official base image
|
||||
FROM python:3.11.4-slim-buster
|
||||
FROM python:3.11.4-slim-buster AS builder
|
||||
|
||||
# set work directory
|
||||
WORKDIR /app
|
||||
@@ -9,20 +13,59 @@ ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
# install system dependencies
|
||||
RUN apt-get update && apt-get install -y netcat
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends gcc
|
||||
|
||||
# lint
|
||||
RUN pip install --upgrade pip
|
||||
COPY . /app/
|
||||
|
||||
# install python dependencies
|
||||
COPY ./requirements.txt .
|
||||
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt
|
||||
|
||||
|
||||
#########
|
||||
# FINAL #
|
||||
#########
|
||||
|
||||
# pull official base image
|
||||
FROM python:3.11.4-slim-buster
|
||||
|
||||
# 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/api
|
||||
RUN mkdir $APP_HOME
|
||||
RUN mkdir $APP_HOME/staticfiles
|
||||
RUN chmod -R 777 $APP_HOME/staticfiles
|
||||
WORKDIR $APP_HOME
|
||||
|
||||
# install dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends netcat
|
||||
COPY --from=builder /app/wheels /wheels
|
||||
COPY --from=builder /app/requirements.txt .
|
||||
RUN pip install --upgrade pip
|
||||
COPY ./requirements.txt .
|
||||
RUN pip install -r requirements.txt
|
||||
RUN pip install --no-cache /wheels/*
|
||||
|
||||
# copy entrypoint.sh
|
||||
COPY ./entrypoint.sh .
|
||||
RUN sed -i 's/\r$//g' /app/entrypoint.sh
|
||||
RUN chmod +x /app/entrypoint.sh
|
||||
# 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 . .
|
||||
COPY . $APP_HOME
|
||||
|
||||
# run entrypoint.sh
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
# 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/api/entrypoint.prod.sh"]
|
||||
|
Reference in New Issue
Block a user