@@ -78,8 +78,20 @@ RUN set -euo pipefail \
78
78
python${PYTHON_VERSION} \
79
79
&& dnf clean all --installroot="${ROOTFS_PATH}"
80
80
81
+ # ----------------------------------------------------------------------------
82
+ # Create `python3` symlink in the rootfs for compatibility
83
+ # ----------------------------------------------------------------------------
84
+ RUN ln -s /usr/bin/python${PYTHON_VERSION} ${ROOTFS_PATH}/usr/bin/python3
85
+
86
+ # ----------------------------------------------------------------------------
87
+ # Copy application directory into the rootfs and fix permissions for non-root
88
+ # ----------------------------------------------------------------------------
89
+ RUN cp -r /app ${ROOTFS_PATH}/app \
90
+ && chown -R 1001:0 ${ROOTFS_PATH}/app \
91
+ && chmod -R g=u ${ROOTFS_PATH}/app
92
+
81
93
###########################
82
- # Runtime stage
94
+ # Final runtime (squashed)
83
95
###########################
84
96
FROM scratch AS runtime
85
97
@@ -95,24 +107,18 @@ LABEL maintainer="Mihai Criveti" \
95
107
org.opencontainers.image.licenses="Apache-2.0"
96
108
97
109
# ----------------------------------------------------------------------------
98
- # Populate the scratch filesystem
99
- # - Copy in the minimal Python runtime
100
- # - Copy in the application directory
110
+ # Copy the entire prepared root filesystem from the builder stage
101
111
# ----------------------------------------------------------------------------
102
112
COPY --from=builder ${ROOTFS_PATH}/ /
103
- COPY --from=builder /app /app
104
113
105
114
# ----------------------------------------------------------------------------
106
- # Create `python3` symlink for compatibility
115
+ # Ensure our virtual environment binaries have priority in PATH
107
116
# ----------------------------------------------------------------------------
108
- RUN ln -s /usr/bin/python${PYTHON_VERSION} /usr/bin/python3
117
+ ENV PATH="/app/.venv/bin:${PATH}"
109
118
110
119
# ----------------------------------------------------------------------------
111
- # Fix permissions for non-root user (1001) and OpenShift compatibility
112
- # ----------------------------------------------------------------------------
113
- RUN chown -R 1001:0 /app && chmod -R g=u /app
114
-
115
120
# Application working directory
121
+ # ----------------------------------------------------------------------------
116
122
WORKDIR /app
117
123
118
124
# ----------------------------------------------------------------------------
@@ -121,15 +127,10 @@ WORKDIR /app
121
127
EXPOSE 4444
122
128
123
129
# ----------------------------------------------------------------------------
124
- # Run as non-root user
130
+ # Run as non-root user (1001)
125
131
# ----------------------------------------------------------------------------
126
132
USER 1001
127
133
128
- # ----------------------------------------------------------------------------
129
- # Ensure our virtual environment binaries have priority in PATH
130
- # ----------------------------------------------------------------------------
131
- ENV PATH="/app/.venv/bin:${PATH}"
132
-
133
134
# ----------------------------------------------------------------------------
134
135
# Entrypoint
135
136
# ----------------------------------------------------------------------------
0 commit comments