-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (35 loc) · 1.14 KB
/
Dockerfile
File metadata and controls
44 lines (35 loc) · 1.14 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
FROM python:3.10-slim AS base_stage
ENV ROOT_DIR=/PythonProject-Template
ARG MODE=release
# MODE: 'release' or 'it' (will be interpreted as debug). This is used in the docker_entrypoint.sh script
ENV MODE=${MODE}
# Build stage
FROM base_stage AS build_stage
ARG DEBIAN_FRONTEND=noninteractive
# System dependencies
RUN apt update -y && \
apt install -y --no-install-recommends build-essential git dos2unix && \
rm -rf /var/lib/apt/lists/*
# Files
WORKDIR "$ROOT_DIR"
COPY *_requirements.txt requirements.txt *.toml *.lock *.py ./
COPY src src
COPY dist dist
COPY docker_files docker_files
RUN dos2unix docker_files/*.sh
# Virtual environment
RUN python3 -m venv ./venv && \
. ./venv/bin/activate && \
pip install --upgrade pip && \
pip install poetry && \
poetry install --no-interaction --no-ansi
# rm unnecessary files
RUN rm -rf *_requirements.txt requirements.txt *.toml *.lock setup.py run_pytests.py src/*.egg-info dist
# Main stage
FROM base_stage AS main_stage
# Files
WORKDIR $ROOT_DIR
COPY --from=build_stage $ROOT_DIR ./
# Entrypoint
ENV PATH="venv/bin:$PATH"
ENTRYPOINT ["bash", "docker_files/docker_entrypoint.sh"]