Use official Docker images for Python instead of installing via Alpine Linux

Signed-off-by: Andrei Jiroh Halili <ajhalili2006@andreijiroh.eu.org>
This commit is contained in:
Andrei Jiroh Halili 2023-10-18 23:29:31 +08:00
parent 137a9f99b7
commit dbd0334da0
No known key found for this signature in database
GPG key ID: 67BFC91B3DA12BE8

View file

@ -1,15 +1,14 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
# Since we're building against edge at risk, it is important to note # Instead of using Alpine base image and then installing Python from pkgs.al.o,
# that anything might go wrong. # we'll go with the official images instead.
FROM alpine:edge AS buildkit FROM python:3.12-alpine AS buildkit
# Since hadolint isn't in the package repos for Alpine yet, we'll copying from the offical # Since hadolint isn't in the package repos for Alpine yet, we'll copying from the offical
# Docker image instead. # Docker image instead.
COPY --from=ghcr.io/hadolint/hadolint:latest-alpine /bin/hadolint /usr/bin/hadolint COPY --from=ghcr.io/hadolint/hadolint:latest-alpine /bin/hadolint /usr/bin/hadolint
ENV PACKAGES=/usr/local/lib/python3.11/site-packages ENV PACKAGES=/usr/local/lib/python3.11/site-packages PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/bin PYTHONDONTWRITEBYTECODE=1
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/bin LABEL org.opencontainers.image.description="GitLab CI image for custom mkdocs-material Docker image, alongside tools @ajhalili2006 use."
ENV PYTHONDONTWRITEBYTECODE=1
# https://squidfunk.github.io/mkdocs-material/setup/setting-up-social-cards/#linux but for Alpine # https://squidfunk.github.io/mkdocs-material/setup/setting-up-social-cards/#linux but for Alpine
# Also installs Doppler CLI for accessing secrets securely within CI # Also installs Doppler CLI for accessing secrets securely within CI
@ -23,10 +22,6 @@ RUN apk add --no-cache \
zlib-dev \ zlib-dev \
bash \ bash \
coreutils \ coreutils \
python3 \
py3-pip \
pipx \
py3-wheel \
shellcheck \ shellcheck \
gcc \ gcc \
libffi-dev \ libffi-dev \
@ -46,9 +41,8 @@ RUN apk add --no-cache \
| sh | sh
# See https://www.jeffgeerling.com/blog/2023/how-solve-error-externally-managed-environment-when-installing-pip3 # See https://www.jeffgeerling.com/blog/2023/how-solve-error-externally-managed-environment-when-installing-pip3
# for context behind removing the EXTERNALLY-MANAGED file # for context behind removing the EXTERNALLY-MANAGED file on distribution-built CPython binary releases
RUN rm -rv /usr/lib/python3*/EXTERNALLY-MANAGED \ RUN pip install --no-cache \
&& pip install --no-cache \
mkdocs-material \ mkdocs-material \
mkdocs-git-committers-plugin-2 \ mkdocs-git-committers-plugin-2 \
mkdocs-git-revision-date-localized-plugin \ mkdocs-git-revision-date-localized-plugin \
@ -57,7 +51,8 @@ RUN rm -rv /usr/lib/python3*/EXTERNALLY-MANAGED \
mkdocs-rss-plugin \ mkdocs-rss-plugin \
pillow \ pillow \
cairosvg \ cairosvg \
pipenv pipenv \
pipx
# Trust directory, required for git >= 2.35.2 # Trust directory, required for git >= 2.35.2
# Follows the docs for the Docker-based site build setup # Follows the docs for the Docker-based site build setup