-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
52 lines (40 loc) · 1.33 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
FROM python:3.10-bullseye
LABEL [email protected]
RUN echo "Building project... Relax and get some 🍺"
# Root user credentials
ARG ROOT_USER=python_user
# Environment Project Variables
ENV POETRY_VIRTUALENVS_CREATE=false
ENV PYTHONUNBUFFERED=0
# Creating custom user
RUN useradd -ms /bin/bash ${ROOT_USER}
RUN usermod -aG sudo ${ROOT_USER}
# Initializing working directory
WORKDIR /project/dir/${ROOT_USER}
# copying project source
COPY ./deployment ./deployment
COPY ./src ./src
COPY ./proj_requirements/prod_requirements.txt ./
COPY ./poetry.lock ./
COPY ./pyproject.toml ./
COPY ./definitions.py ./
COPY ./rest ./rest
COPY ./tests ./tests
COPY ./experiments ./experiments
COPY ./constants ./constants
COPY __init__.py ./__init__.py
COPY deployment/entrypoint.sh ./
COPY ./tox.ini ./
# updating pip installer and installing gcc lib for more reliable project
# compilation
RUN pip install --upgrade pip && apt-get install gcc
# installing poetry package manager
RUN pip install poetry
RUN poetry install --no-dev && poetry export --format=requirements.txt \
--output=prod_requirements.txt --without-hashes
RUN pip install -r prod_requirements.txt && pip install 'fastapi[all]' --upgrade
RUN chmod +x definitions.py
RUN chmod +x entrypoint.sh
RUN chmod +x definitions.py
RUN python definitions.py
ENTRYPOINT ["sh", "entrypoint.sh"]