mirror of
https://github.com/goauthentik/authentik.git
synced 2026-08-30 18:51:39 -07:00
* ci: pin pnpm 11.20.0 everywhere Every pnpm version reference now agrees on the latest release: packageManager and the engines floor in all four manifests, and the ghcr.io/pnpm/pnpm image in both Dockerfiles. Frozen installs for the root, web, and website workspaces verified clean on 11.20.0. * Update client-ts.
253 lines
10 KiB
Docker
253 lines
10 KiB
Docker
# syntax=docker/dockerfile:1
|
|
|
|
# Tag must track the root package.json `packageManager` version. ${BUILDPLATFORM}
|
|
# keeps the binary's arch aligned with the builder stage on cross-arch builds.
|
|
FROM --platform=${BUILDPLATFORM} ghcr.io/pnpm/pnpm:11.20.0@sha256:d77573aba1649491010d3d252214be47197c0706417793cf393ac47cc324f315 AS pnpm
|
|
|
|
# Stage: Build webui
|
|
FROM --platform=${BUILDPLATFORM} docker.io/library/node:26-trixie-slim@sha256:deae974a69e140f44f434ab29cb519fb5f8fe250fd364b8ca446bd0761acdc6a AS node-builder
|
|
|
|
ARG GIT_BUILD_HASH
|
|
ENV GIT_BUILD_HASH=$GIT_BUILD_HASH
|
|
ENV NODE_ENV=production
|
|
|
|
WORKDIR /work
|
|
|
|
COPY --from=pnpm /opt/pnpm /opt/pnpm
|
|
ENV PATH="/opt/pnpm:${PATH}"
|
|
|
|
RUN --mount=type=bind,target=/work/package.json,src=./package.json \
|
|
--mount=type=bind,target=/work/web/package.json,src=./web/package.json \
|
|
--mount=type=bind,target=/work/web/pnpm-lock.yaml,src=./web/pnpm-lock.yaml \
|
|
--mount=type=bind,target=/work/scripts/node/,src=./scripts/node/ \
|
|
--mount=type=bind,target=/work/packages/logger-js/,src=./packages/logger-js/ \
|
|
node ./scripts/node/lint-runtime.mjs ./web
|
|
|
|
WORKDIR /work/web
|
|
|
|
# These files need to be copied and cannot be mounted as `pnpm install` will build the client's typescript
|
|
COPY ./packages /work/packages
|
|
COPY ./web/packages /work/web/packages
|
|
|
|
RUN --mount=type=bind,target=/work/.npmrc,src=./.npmrc \
|
|
--mount=type=bind,target=/work/web/package.json,src=./web/package.json \
|
|
--mount=type=bind,target=/work/web/pnpm-lock.yaml,src=./web/pnpm-lock.yaml \
|
|
--mount=type=bind,target=/work/web/pnpm-workspace.yaml,src=./web/pnpm-workspace.yaml \
|
|
--mount=type=bind,target=/work/web/packages/sfe/package.json,src=./web/packages/sfe/package.json \
|
|
--mount=type=bind,target=/work/web/scripts,src=./web/scripts \
|
|
--mount=type=cache,id=pnpm-ak,sharing=shared,target=/root/.local/share/pnpm/store \
|
|
pnpm install --frozen-lockfile
|
|
|
|
COPY ./package.json /work
|
|
COPY ./web /work/web/
|
|
# TODO: Update this after moving website to docs
|
|
COPY ./website /work/website/
|
|
|
|
RUN pnpm run build && \
|
|
pnpm run build:sfe
|
|
|
|
# Stage: MaxMind GeoIP
|
|
FROM --platform=${BUILDPLATFORM} ghcr.io/maxmind/geoipupdate:v8.0.0@sha256:51e70dd6f16cd3e4d845ac02d09940b10772a75b9d741427d235a78570923c1d AS geoip
|
|
|
|
ENV GEOIPUPDATE_EDITION_IDS="GeoLite2-City GeoLite2-ASN"
|
|
ENV GEOIPUPDATE_VERBOSE="1"
|
|
ENV GEOIPUPDATE_ACCOUNT_ID_FILE="/run/secrets/GEOIPUPDATE_ACCOUNT_ID"
|
|
|
|
USER root
|
|
RUN --mount=type=secret,id=GEOIPUPDATE_ACCOUNT_ID \
|
|
--mount=type=secret,id=GEOIPUPDATE_LICENSE_KEY \
|
|
mkdir -p /usr/share/GeoIP && \
|
|
/bin/sh -c "GEOIPUPDATE_LICENSE_KEY_FILE=/run/secrets/GEOIPUPDATE_LICENSE_KEY /usr/bin/entry.sh || echo 'Failed to get GeoIP database, disabling'; exit 0"
|
|
|
|
# Stage: download Rust toolchain
|
|
FROM ghcr.io/goauthentik/fips-debian:trixie-slim-fips@sha256:f18dbc487a2c3148b62e46c394445aa87189861bca262e095496dca5b1f0ae39 AS rust-toolchain
|
|
|
|
ARG TARGETARCH
|
|
ARG TARGETVARIANT
|
|
|
|
ENV PATH="/root/.cargo/bin:$PATH"
|
|
SHELL ["/bin/sh", "-o", "pipefail", "-c"]
|
|
RUN --mount=type=bind,target=rust-toolchain.toml,src=rust-toolchain.toml \
|
|
apt-get update && \
|
|
# Required for installing pip packages
|
|
apt-get install -y --no-install-recommends \
|
|
# Build essentials
|
|
build-essential && \
|
|
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain none && \
|
|
rustup install && \
|
|
rustup default "$(sed -n 's/channel = "\(.*\)"/\1/p' rust-toolchain.toml)" && \
|
|
rustc --version && \
|
|
cargo --version
|
|
|
|
# Stage: Download uv
|
|
FROM ghcr.io/astral-sh/uv:0.12.1@sha256:cf4eedcaa81655197f625739489effcbe71b61ceb1506f332c3facae5deceded AS uv
|
|
# Stage: Base python image
|
|
FROM ghcr.io/goauthentik/fips-python:3.14.6-slim-trixie-fips@sha256:adbae5c3ce583686c4dc4943832922b6fd33ab181df0d1a939e73063a614f758 AS python-base
|
|
|
|
ENV VENV_PATH="/ak-root/.venv" \
|
|
PATH="/lifecycle:/ak-root/.venv/bin:$PATH" \
|
|
UV_COMPILE_BYTECODE=1 \
|
|
UV_LINK_MODE=copy \
|
|
UV_NATIVE_TLS=1 \
|
|
UV_PYTHON_DOWNLOADS=0
|
|
|
|
WORKDIR /ak-root/
|
|
|
|
COPY --from=uv /uv /uvx /bin/
|
|
|
|
# Stage: build rust binary
|
|
FROM python-base AS rust-builder
|
|
|
|
ARG TARGETARCH
|
|
ARG TARGETVARIANT
|
|
|
|
WORKDIR /build
|
|
|
|
ENV PATH="/root/.cargo/bin:$PATH"
|
|
COPY --from=rust-toolchain /root/.rustup /root/.rustup
|
|
COPY --from=rust-toolchain /root/.cargo /root/.cargo
|
|
|
|
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
|
|
RUN --mount=type=cache,id=apt-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/apt \
|
|
--mount=type=bind,target=rust-toolchain.toml,src=rust-toolchain.toml \
|
|
apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
# common dependencies
|
|
build-essential \
|
|
# aws-lc deps
|
|
cmake clang golang
|
|
# See https://github.com/aws/aws-lc-rs/issues/569
|
|
ENV AWS_LC_FIPS_SYS_CC=clang
|
|
|
|
COPY --from=node-builder /work/web/robots.txt /build/web/robots.txt
|
|
COPY --from=node-builder /work/web/security.txt /build/web/security.txt
|
|
COPY --from=node-builder /work/web/dist/standalone/loading/startup.html /build/web/dist/standalone/loading/startup.html
|
|
|
|
RUN --mount=type=bind,target=rust-toolchain.toml,src=rust-toolchain.toml \
|
|
--mount=type=bind,target=Cargo.toml,src=Cargo.toml \
|
|
--mount=type=bind,target=Cargo.lock,src=Cargo.lock \
|
|
--mount=type=bind,target=.cargo/,src=.cargo/ \
|
|
--mount=type=bind,target=build.rs,src=build.rs \
|
|
--mount=type=bind,target=src/,src=src/ \
|
|
--mount=type=bind,target=packages/ak-axum,src=packages/ak-axum \
|
|
--mount=type=bind,target=packages/ak-common,src=packages/ak-common \
|
|
--mount=type=bind,target=packages/client-rust,src=packages/client-rust \
|
|
--mount=type=bind,target=authentik/lib/default.yml,src=authentik/lib/default.yml \
|
|
# Required otherwise workspace discovery fails
|
|
--mount=type=bind,target=website/scripts/docsmg/,src=website/scripts/docsmg/ \
|
|
--mount=type=cache,id=cargo-git-db-$TARGETARCH$TARGETVARIANT,target=/root/.cargo/git/db/ \
|
|
--mount=type=cache,id=cargo-registry-$TARGETARCH$TARGETVARIANT,target=/root/.cargo/registry/ \
|
|
--mount=type=cache,id=rust-target-$TARGETARCH$TARGETVARIANT,target=/build/target/ \
|
|
cargo build --package authentik --no-default-features --features core --locked --release && \
|
|
cp ./target/release/authentik /bin/authentik
|
|
|
|
|
|
# Stage: Python dependencies
|
|
FROM python-base AS python-deps
|
|
|
|
ARG TARGETARCH
|
|
ARG TARGETVARIANT
|
|
|
|
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
|
|
RUN --mount=type=cache,id=apt-$TARGETARCH$TARGETVARIANT,sharing=locked,target=/var/cache/apt \
|
|
--mount=type=bind,target=rust-toolchain.toml,src=rust-toolchain.toml \
|
|
apt-get update && \
|
|
# Required for installing pip packages
|
|
apt-get install -y --no-install-recommends \
|
|
# Build essentials
|
|
build-essential pkg-config libffi-dev git \
|
|
# cryptography
|
|
curl \
|
|
# libxml
|
|
libxslt-dev zlib1g-dev \
|
|
# postgresql
|
|
libpq-dev \
|
|
# python-kadmin-rs
|
|
krb5-multidev libkrb5-dev heimdal-multidev libclang-dev \
|
|
# xmlsec
|
|
libltdl-dev
|
|
|
|
ENV PATH="/root/.cargo/bin:$PATH"
|
|
COPY --from=rust-toolchain /root/.rustup /root/.rustup
|
|
COPY --from=rust-toolchain /root/.cargo /root/.cargo
|
|
|
|
ENV UV_NO_BINARY_PACKAGE="cryptography lxml python-kadmin-rs xmlsec"
|
|
RUN --mount=type=bind,target=pyproject.toml,src=pyproject.toml \
|
|
--mount=type=bind,target=uv.lock,src=uv.lock \
|
|
--mount=type=bind,target=packages/ak-guardian,src=packages/ak-guardian \
|
|
--mount=type=bind,target=packages/django-channels-postgres,src=packages/django-channels-postgres \
|
|
--mount=type=bind,target=packages/django-dramatiq-postgres,src=packages/django-dramatiq-postgres \
|
|
--mount=type=bind,target=packages/django-postgres-cache,src=packages/django-postgres-cache \
|
|
--mount=type=bind,target=rust-toolchain.toml,src=rust-toolchain.toml \
|
|
--mount=type=cache,id=uv-python-deps-$TARGETARCH$TARGETVARIANT,target=/root/.cache/uv \
|
|
uv sync --locked --no-install-project --no-dev
|
|
|
|
# Stage: Run
|
|
FROM python-base AS final-image
|
|
|
|
ARG VERSION
|
|
ARG GIT_BUILD_HASH
|
|
ENV GIT_BUILD_HASH=$GIT_BUILD_HASH
|
|
|
|
LABEL org.opencontainers.image.authors="Authentik Security Inc." \
|
|
org.opencontainers.image.source="https://github.com/goauthentik/authentik" \
|
|
org.opencontainers.image.description="goauthentik.io Main server image, see https://goauthentik.io for more info." \
|
|
org.opencontainers.image.documentation="https://docs.goauthentik.io" \
|
|
org.opencontainers.image.licenses="https://github.com/goauthentik/authentik/blob/main/LICENSE" \
|
|
org.opencontainers.image.revision=${GIT_BUILD_HASH} \
|
|
org.opencontainers.image.title="authentik server image" \
|
|
org.opencontainers.image.url="https://goauthentik.io" \
|
|
org.opencontainers.image.vendor="Authentik Security Inc." \
|
|
org.opencontainers.image.version=${VERSION}
|
|
|
|
WORKDIR /
|
|
|
|
# We cannot cache this layer otherwise we'll end up with a bigger image
|
|
RUN apt-get update && \
|
|
apt-get upgrade -y && \
|
|
# Required for runtime
|
|
apt-get install -y --no-install-recommends \
|
|
libpq5 libmaxminddb0 ca-certificates \
|
|
libkadm5clnt-mit12 libkadm5clnt7t64-heimdal \
|
|
libltdl7 libxslt1.1 && \
|
|
apt-get purge -y curl libcurl4t64 && \
|
|
pip3 install --no-cache-dir --upgrade pip && \
|
|
apt-get clean && \
|
|
rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/ && \
|
|
adduser --system --no-create-home --uid 1000 --group --home /authentik authentik && \
|
|
mkdir -p /certs /data /media /blueprints && \
|
|
ln -s /media /data/media && \
|
|
mkdir -p /authentik/.ssh && \
|
|
mkdir -p /ak-root && \
|
|
chown authentik:authentik /certs /data /data/media /media /authentik/.ssh /ak-root
|
|
|
|
COPY ./authentik/ /authentik
|
|
COPY ./pyproject.toml /
|
|
COPY ./uv.lock /
|
|
COPY ./schemas /schemas
|
|
COPY ./locale /locale
|
|
COPY ./tests /tests
|
|
COPY ./manage.py /
|
|
COPY ./blueprints /blueprints
|
|
COPY ./lifecycle/ /lifecycle
|
|
COPY ./authentik/sources/kerberos/krb5.conf /etc/krb5.conf
|
|
COPY --from=rust-builder /bin/authentik /bin/authentik
|
|
COPY ./packages/ /ak-root/packages
|
|
RUN ln -s /ak-root/packages /packages
|
|
COPY --from=python-deps /ak-root/.venv /ak-root/.venv
|
|
COPY --from=node-builder /work/web/dist/ /web/dist/
|
|
COPY --from=node-builder /work/web/authentik/ /web/authentik/
|
|
COPY --from=geoip /usr/share/GeoIP /geoip
|
|
|
|
USER 1000
|
|
|
|
ENV TMPDIR=/dev/shm/ \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
GOFIPS=1 \
|
|
RUST_BACKTRACE=full
|
|
|
|
HEALTHCHECK --interval=30s --timeout=30s --start-period=120s --retries=3 CMD [ "ak", "healthcheck" ]
|
|
|
|
ENTRYPOINT [ "dumb-init", "--", "ak" ]
|