52 lines
1.2 KiB
Docker
52 lines
1.2 KiB
Docker
FROM python:3.12.2-slim-buster as builder
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PIP_NO_CACHE_DIR=1
|
|
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends gcc
|
|
|
|
RUN pip install --upgrade pip
|
|
RUN pip install flake8==6.0.0
|
|
COPY . /usr/src/app/
|
|
RUN flake8 --ignore=E501,F401 .
|
|
|
|
COPY ./requirements.txt .
|
|
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt
|
|
|
|
|
|
FROM python:3.12.2-alpine3.21
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PIP_NO_CACHE_DIR=1 \
|
|
HOME=/home/app \
|
|
APP_HOME=/home/app/web
|
|
|
|
RUN mkdir -p $HOME && \
|
|
mkdir $APP_HOME && \
|
|
addgroup --system app && \
|
|
adduser --system --group app
|
|
|
|
WORKDIR $APP_HOME
|
|
|
|
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 && \
|
|
pip install --no-cache /wheels/*
|
|
|
|
COPY . $APP_HOME
|
|
RUN sed -i 's/\r$//g' $APP_HOME/entrypoint.sh && \
|
|
chmod +x $APP_HOME/entrypoint.sh
|
|
|
|
RUN chown -R app:app $APP_HOME
|
|
|
|
USER app
|
|
|
|
ENTRYPOINT ["/home/app/web/entrypoint.sh"]
|