-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
126 lines (91 loc) · 3.02 KB
/
Copy pathDockerfile
File metadata and controls
126 lines (91 loc) · 3.02 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Dockerfile
# syntax=docker/dockerfile:1
# =========================================================
# ➤ BASE STAGE
# =========================================================
# =========================
# 💿 Base image
# =========================
# Use official Python image
FROM python:3.14-slim AS base
# =========================
# 🔡 Environment
# =========================
# Prevent Python from writing pyc files
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# =========================
# 📁 Working directory (WORKSPACE)
# =========================
# Set working directory
WORKDIR /workspace
# =========================
# 📦 SYSTEM DEPENDENCIES
# =========================
RUN apt-get update && apt-get install -y --no-install-recommends \
make \
&& rm -rf /var/lib/apt/lists/*
# NOTE:
# Don't use like these below when install
# make \
# git \
# # docker.io \
# # docker-cli \
# docker-ce-cli \
# Comments inside a \ continuation can produce unexpected parsing behavior.
# =========================
# 📄 Copy application
# =========================
COPY . .
# =========================
# 🚀 PYTHON SETUP
# =========================
RUN pip install --no-cache-dir --upgrade pip
# Optional PEP 440 version supplied by CI or a reviewed local build. Git metadata
# remains outside the Docker context, so setuptools-scm otherwise uses its
# configured fallback version.
ARG PHS_BUILD_VERSION
# =========================================================
# ➤ DEVELOPMENT STAGE
# =========================================================
# =========================
# 💿 DEVELOPMENT IMAGE
# =========================
FROM base AS development
# =========================
# 📦 Install DEV dependencies
# =========================
RUN if [ -n "$PHS_BUILD_VERSION" ]; then \
SETUPTOOLS_SCM_PRETEND_VERSION="$PHS_BUILD_VERSION" \
pip install --no-cache-dir -e ".[dev]"; \
else \
pip install --no-cache-dir -e ".[dev]"; \
fi
# =========================
# 🚀 Default command
# =========================
ENTRYPOINT ["path-header-scanner"]
CMD ["--help"]
# =========================================================
# ➤ PRODUCTION STAGE
# =========================================================
# =========================
# 💿 PRODUCTION IMAGE
# =========================
FROM base AS production
# =========================
# 📦 INSTALL RUNTIME DEPENDENCIES
# =========================
RUN if [ -n "$PHS_BUILD_VERSION" ]; then \
SETUPTOOLS_SCM_PRETEND_VERSION="$PHS_BUILD_VERSION" \
pip install --no-cache-dir .; \
else \
pip install --no-cache-dir .; \
fi
# Fail the build when runtime imports or CLI startup dependencies are missing.
RUN python -c "from app.cli.main import app"
# =========================
# 🚀 Default command
# =========================
ENTRYPOINT ["path-header-scanner"]
CMD ["--help"]