-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
executable file
·81 lines (55 loc) · 1.75 KB
/
Dockerfile
File metadata and controls
executable file
·81 lines (55 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
FROM python:3.13.3-slim-bookworm AS python-base
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=1.8.2 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1 \
PYSETUP_PATH="/opt/pysetup" \
VENV_PATH="/opt/pysetup/.venv" \
PROJECT_PATH="/server"
ENV PATH="$VENV_PATH/bin:$PATH"
FROM python-base AS builder-base
WORKDIR $PYSETUP_PATH
COPY poetry.lock pyproject.toml ./
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
build-essential \
curl \
git \
libpq-dev \
libseccomp2 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN --mount=type=cache,target=/root/.cache/pip \
pip install "poetry==$POETRY_VERSION";
RUN --mount=type=cache,target=/root/.cache/poetry \
poetry install --only main --no-root --no-interaction
FROM python-base AS production
WORKDIR $PROJECT_PATH
COPY --from=builder-base $VENV_PATH $VENV_PATH
RUN adduser --disabled-password --gecos '' appuser
COPY --chown=appuser:appuser app app
USER appuser
EXPOSE 8000
ENTRYPOINT ["uvicorn"]
CMD ["app.main:app", "--host", "0.0.0.0", "--port", "8000", "--lifespan", "on"]
FROM builder-base AS development
WORKDIR $PYSETUP_PATH
RUN poetry install --no-root --no-interaction
WORKDIR $PROJECT_PATH
COPY app app
COPY tests tests
COPY scripts scripts
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--lifespan", "on"]
FROM builder-base AS scanapi-test
WORKDIR $PYSETUP_PATH
RUN poetry install --no-root --no-interaction
WORKDIR $PROJECT_PATH
COPY poetry.lock pyproject.toml ./
COPY app app
COPY scanapi scanapi
COPY scanapi.conf ./
CMD ["poetry", "run", "scanapi", "run"]