-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
43 lines (30 loc) · 1.23 KB
/
Dockerfile
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
FROM python:3.11.4-slim-buster AS osbase
RUN apt-get update && \
apt-get upgrade --yes && \
apt-get install gcc libgl1 libglib2.0-0 --yes
RUN useradd --create-home fastapi
USER fastapi
WORKDIR /home/fastapi
FROM osbase AS pythonbase
ENV VIRTUALENV=/home/fastapi/venv
RUN python3 -m venv $VIRTUALENV
ENV PATH="$VIRTUALENV/bin:$PATH"
COPY --chown=fastapi:fastapi requirements.txt .
RUN pip install --upgrade pip setuptools && \
pip install --no-cache-dir -r requirements.txt
FROM pythonbase AS builder
COPY --chown=fastapi:fastapi requirements-dev.txt ./
RUN pip install --no-cache-dir -r requirements-dev.txt
COPY --chown=fastapi:fastapi pyproject.toml README.md LICENSE.txt ./
COPY --chown=fastapi:fastapi src/ src/
COPY --chown=fastapi:fastapi tests/ tests/
RUN python -m pip install . && \
python -m pytest tests/ && \
python -m ruff src/ && \
python -m black src/ --check && \
python -m bandit -r src/ --quiet && \
python -m pip wheel --wheel-dir dist/ . -r requirements.txt
FROM pythonbase AS app
COPY --chown=fastapi:fastapi --from=builder /home/fastapi/dist/feather*.whl /home/fastapi/
RUN pip install --no-cache-dir feather*.whl
CMD ["uvicorn", "feather_spotter.app:app", "--host", "0.0.0.0", "--port", "8000"]