-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
executable file
·72 lines (47 loc) · 1.38 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
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
# syntax=docker/dockerfile:1.2
#############################
# Prepare base environment
#############################
FROM python:3.10-slim as base
ARG DEBIAN_FRONTEND=noninteractive
ARG FASTAPI_ENV
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV FASTAPI_ENV=${FASTAPI_ENV}
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get clean
WORKDIR /app
###########################
# Install Python dependencies
###########################
FROM base as build-image
ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=1.1.15
# RUN apt-get update -qq && apt-get install -qqy --no-install-recommends \
# python3-dev
RUN pip install "poetry==$POETRY_VERSION"
COPY pyproject.toml .
RUN poetry export -o requirements.txt
RUN python -m venv .venv && \
.venv/bin/pip install -r requirements.txt
###########################
# Install app dependencies
###########################
FROM base AS build-app
COPY . /app
RUN rm -rf app/tests
#############################
# Prepare runtime environment
#############################
FROM base AS env
ENV PATH=/app/.venv/bin:$PATH
COPY --from=build-image /app/.venv /app/.venv
COPY --from=build-app /app /app
EXPOSE 5000
ENTRYPOINT ["bash", "./run_app.sh"]