Skip to content

Commit 65bcf2d

Browse files
crimethinkingmarcuscruz-percona
authored andcommitted
SEP-1014 Use Debian Python image instead of Alpine for SEP app/frontend (#701)
Currently, SEP app/frontend run on official Python Docker image based on Alpine Linux. Alpine image is very small, which is good, but `musl` C library forces Python library recompilation + potential runtime bugs. Official Python/Node images also publish a Debian-based `-slim` version, which is proven and mostly secure given how popular Debian is
1 parent 900cf62 commit 65bcf2d

2 files changed

Lines changed: 23 additions & 8 deletions

File tree

Containerfile.base

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
###########
44

55
# Use an official Python runtime as a parent image
6-
FROM docker.io/library/python:3.11.14-alpine AS builder
6+
FROM docker.io/library/python:3.11.14-slim AS builder
77

88
# Set work directory
99
WORKDIR /usr/src/sep
@@ -14,7 +14,10 @@ ENV PYTHONUNBUFFERED=1
1414
ENV FASTAPI_ENV=production_docker
1515

1616
# Install dependencies
17-
RUN apk update && apk add --no-cache g++ git
17+
RUN apt-get update && \
18+
apt-get install -y --no-install-recommends g++ git && \
19+
apt-get clean && \
20+
rm -rf /var/lib/apt/lists/*
1821

1922
# Export requirements
2023
RUN pip install --no-cache-dir wheel poetry==2.2.1 poetry-plugin-export

Dockerfile

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ENV FASTAPI_ENV=production_docker
1313
# FRONTEND BUILDER #
1414
####################
1515

16-
FROM node:22-alpine AS frontend-builder
16+
FROM node:22-slim AS frontend-builder
1717

1818
WORKDIR /app
1919

@@ -28,14 +28,23 @@ RUN pnpm install --frozen-lockfile && pnpm build
2828
#########
2929

3030
# Use an official Python runtime as a parent image
31-
FROM docker.io/library/python:3.11.14-alpine
31+
FROM docker.io/library/python:3.11.14-slim
3232

3333
# Install dependencies
34-
RUN apk update && apk add --no-cache g++ pango fontconfig ttf-dejavu
34+
RUN apt-get update && \
35+
apt-get install -y --no-install-recommends \
36+
g++ \
37+
libpango-1.0-0 \
38+
libpangoft2-1.0-0 \
39+
fontconfig \
40+
fonts-dejavu \
41+
shared-mime-info && \
42+
apt-get clean && \
43+
rm -rf /var/lib/apt/lists/*
3544

3645
# Create the sep system user
37-
RUN addgroup --gid 1001 -S sep && \
38-
adduser -G sep --shell /bin/false --disabled-password -h /home/sep --uid 1001 sep
46+
RUN groupadd --gid 1001 sep && \
47+
useradd --gid sep --shell /usr/sbin/nologin --home-dir /home/sep --uid 1001 --create-home sep
3948

4049
# Create the appropriate directories
4150
ENV HOME=/home/sep
@@ -44,7 +53,10 @@ RUN install -d -o 1001 -g 1001 -m 0750 $APP_HOME
4453
WORKDIR $APP_HOME
4554

4655
# Install dependencies
47-
RUN apk update && apk add --no-cache netcat-openbsd
56+
RUN apt-get update && \
57+
apt-get install -y --no-install-recommends netcat-openbsd && \
58+
apt-get clean && \
59+
rm -rf /var/lib/apt/lists/*
4860
COPY --from=builder /usr/src/sep/wheels /wheels
4961
COPY --from=builder /usr/src/sep/requirements.txt .
5062
RUN pip install --no-cache-dir wheel

0 commit comments

Comments
 (0)