-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
64 lines (48 loc) · 1.35 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
# Base Image for Python 3.11
FROM ubuntu:jammy as build-base
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_HOME="/opt/poetry" \
POETRY_VIRTUALENVS_IN_PROJECT=true \
POETRY_NO_INTERACTION=1 \
PYSETUP_PATH="/opt/pysetup" \
VENV_PATH="/opt/pysetup/.venv"
# Install system dependencies
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
curl \
python3-dev \
libpq-dev \
build-essential \
libgl1-mesa-glx \
libglib2.0-0
# Install poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
# Separate docker stage to avoid re-installing poetry & build essentials on every change
FROM build-base as final-stage
# set work directory
WORKDIR $PYSETUP_PATH
# install dependencies
COPY poetry.lock ./
COPY pyproject.toml ./
RUN poetry install --no-root --only main --sync
# copy project
WORKDIR /home/etlas
COPY ./ ./
# run entrypoint.sh
COPY entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
# run server
CMD uvicorn api.asgi:application --host 0.0.0.0 --port 8000 \
--app-dir /home/etlas \
--reload \
--reload-dir /home/etlas
# expose port
EXPOSE 8000