-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
41 lines (31 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
# syntax=docker/dockerfile:1
FROM python:3.11-slim as builder
ENV PIPENV_VENV_IN_PROJECT=1
# Copy your application source to the container
# (make sure you create a .dockerignore file if any large files or directories should be excluded)
WORKDIR /usr/src/
ADD . /usr/src/
# Install build deps, then run `pip install`, then remove unneeded build deps all in a single step.
# Correct the path to your production requirements file, if needed.
WORKDIR /usr/src/
RUN set -ex \
&& BUILD_DEPS=" \
build-essential \
curl \
\
" \
&& apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
&& python -m pip install --upgrade pip \
&& pip install pipenv \
&& pipenv sync --dev \
# && pipenv run pytest \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
&& rm -rf /var/lib/apt/lists/*
FROM python:3.11-slim as runtime
COPY --from=builder /usr/src/ /usr/src/
WORKDIR /usr/src/
RUN useradd --create-home --shell /bin/bash opensensor-api
USER opensensor-api
ENV TZ=UTC
# Start opensensor API
CMD ["/usr/src/.venv/bin/uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8010", "--workers", "4", "--timeout-keep-alive", "30", "--log-level", "info"]