-
Notifications
You must be signed in to change notification settings - Fork 24
/
Dockerfile
35 lines (25 loc) · 1006 Bytes
/
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
ARG PY_VERSION=3.9
FROM python:$PY_VERSION-slim AS build-env
ARG VERSION
WORKDIR /app
# Install python deps
RUN python -m pip install --upgrade poetry wheel twine
# Install project deps
COPY pyproject.toml .
RUN poetry install --with dev
# Copy code *after* installing deps to avoid unnecessarily invalidating cache
COPY . .
RUN poetry build
RUN PROJECT_VERSION=$(poetry version -s) && cp /app/dist/boaviztapi-$PROJECT_VERSION.tar.gz ./boaviztapi-$VERSION.tar.gz
RUN pip install boaviztapi-$VERSION.tar.gz && cp $(which uvicorn) /app
FROM python:$PY_VERSION-slim AS run-env
# Python 3 surrogate unicode handling
# @see https://click.palletsprojects.com/en/7.x/python3/
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
COPY --from=build-env /app /app
COPY --from=build-env /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages
ENV PYTHONPATH=/usr/local/lib/python3.9/site-packages
WORKDIR /app
EXPOSE 5000
CMD ["./uvicorn", "boaviztapi.main:app", "--host", "0.0.0.0", "--port", "5000"]