-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (50 loc) · 1.84 KB
/
Copy pathDockerfile
File metadata and controls
65 lines (50 loc) · 1.84 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
# syntax=docker/dockerfile:1.7
FROM python:3.11-slim AS builder
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_DEFAULT_TIMEOUT=180
ARG INSTALL_ML=false
WORKDIR /app
RUN --mount=type=cache,target=/var/cache/apt,id=apt-builder,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
bash \
gcc \
make \
lua5.3 \
liblua5.3-dev \
luarocks \
ca-certificates && \
LUA_INCDIR=/usr/include/lua5.3 luarocks --lua-version=5.3 install luacheck && \
apt-get clean && rm -rf /var/lib/apt/lists/*
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements-heavy.txt ./
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --prefer-binary --retries 20 -r requirements-heavy.txt
COPY requirements-ml.txt ./
RUN --mount=type=cache,target=/root/.cache/pip \
if [ "$INSTALL_ML" = "true" ]; then pip install --prefer-binary --retries 20 -r requirements-ml.txt; fi
COPY requirements.txt ./
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --prefer-binary --retries 20 -r requirements.txt
FROM python:3.11-slim AS runtime
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PATH="/opt/venv/bin:$PATH"
WORKDIR /app
RUN --mount=type=cache,target=/var/cache/apt,id=apt-runtime,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends \
bash \
lua5.3 \
ca-certificates && \
apt-get clean && rm -rf /var/lib/apt/lists/*
COPY --from=builder /opt/venv /opt/venv
COPY --from=builder /usr/local/bin/luacheck /usr/local/bin/luacheck
COPY --from=builder /usr/local/share/lua /usr/local/share/lua
COPY --from=builder /usr/local/lib/lua /usr/local/lib/lua
COPY . .
EXPOSE 8080
WORKDIR /app
CMD uvicorn api.main:app --host 0.0.0.0 --port 8080