2021-12-24 22:25:38 +00:00
|
|
|
# Stage 1: Build website
|
2023-09-06 10:22:25 +00:00
|
|
|
FROM --platform=${BUILDPLATFORM} docker.io/node:20.5 as website-builder
|
2021-07-13 09:06:51 +00:00
|
|
|
|
2021-11-26 13:19:57 +00:00
|
|
|
COPY ./website /work/website/
|
2022-07-31 16:10:21 +00:00
|
|
|
COPY ./blueprints /work/blueprints/
|
2022-11-28 23:05:39 +00:00
|
|
|
COPY ./SECURITY.md /work/
|
2021-07-13 09:06:51 +00:00
|
|
|
|
|
|
|
ENV NODE_ENV=production
|
2022-05-07 19:22:33 +00:00
|
|
|
WORKDIR /work/website
|
2023-05-16 10:45:10 +00:00
|
|
|
RUN npm ci --include=dev && npm run build-docs-only
|
2021-07-13 09:06:51 +00:00
|
|
|
|
2021-12-24 22:25:38 +00:00
|
|
|
# Stage 2: Build webui
|
2023-09-06 10:22:25 +00:00
|
|
|
FROM --platform=${BUILDPLATFORM} docker.io/node:20.5 as web-builder
|
2021-05-02 22:49:16 +00:00
|
|
|
|
2021-11-26 13:19:57 +00:00
|
|
|
COPY ./web /work/web/
|
|
|
|
COPY ./website /work/website/
|
2021-05-02 22:49:16 +00:00
|
|
|
|
|
|
|
ENV NODE_ENV=production
|
2022-05-07 19:22:33 +00:00
|
|
|
WORKDIR /work/web
|
2023-05-16 10:45:10 +00:00
|
|
|
RUN npm ci --include=dev && npm run build
|
2021-05-02 22:49:16 +00:00
|
|
|
|
2022-05-07 19:22:33 +00:00
|
|
|
# Stage 3: Poetry to requirements.txt export
|
2023-08-28 08:56:55 +00:00
|
|
|
FROM docker.io/python:3.11.5-slim-bookworm AS poetry-locker
|
2022-05-07 19:22:33 +00:00
|
|
|
|
|
|
|
WORKDIR /work
|
|
|
|
COPY ./pyproject.toml /work
|
|
|
|
COPY ./poetry.lock /work
|
|
|
|
|
|
|
|
RUN pip install --no-cache-dir poetry && \
|
|
|
|
poetry export -f requirements.txt --output requirements.txt && \
|
|
|
|
poetry export -f requirements.txt --dev --output requirements-dev.txt
|
|
|
|
|
|
|
|
# Stage 4: Build go proxy
|
2023-09-07 10:00:34 +00:00
|
|
|
FROM docker.io/golang:1.21.1-bookworm AS go-builder
|
2021-05-02 22:49:16 +00:00
|
|
|
|
|
|
|
WORKDIR /work
|
|
|
|
|
2021-11-26 13:19:57 +00:00
|
|
|
COPY --from=web-builder /work/web/robots.txt /work/web/robots.txt
|
|
|
|
COPY --from=web-builder /work/web/security.txt /work/web/security.txt
|
2021-05-02 22:49:16 +00:00
|
|
|
|
|
|
|
COPY ./cmd /work/cmd
|
2023-08-26 19:02:57 +00:00
|
|
|
COPY ./authentik/lib /work/authentik/lib
|
2021-05-02 22:49:16 +00:00
|
|
|
COPY ./web/static.go /work/web/static.go
|
|
|
|
COPY ./internal /work/internal
|
|
|
|
COPY ./go.mod /work/go.mod
|
|
|
|
COPY ./go.sum /work/go.sum
|
|
|
|
|
2023-08-26 19:42:36 +00:00
|
|
|
RUN go build -o /work/bin/authentik ./cmd/server/
|
2021-05-02 22:49:16 +00:00
|
|
|
|
2022-12-20 21:09:30 +00:00
|
|
|
# Stage 5: MaxMind GeoIP
|
2023-07-13 10:51:37 +00:00
|
|
|
FROM ghcr.io/maxmind/geoipupdate:v6.0 as geoip
|
2022-12-20 21:09:30 +00:00
|
|
|
|
|
|
|
ENV GEOIPUPDATE_EDITION_IDS="GeoLite2-City"
|
2023-01-09 13:29:08 +00:00
|
|
|
ENV GEOIPUPDATE_VERBOSE="true"
|
2023-07-13 10:51:37 +00:00
|
|
|
ENV GEOIPUPDATE_ACCOUNT_ID_FILE="/run/secrets/GEOIPUPDATE_ACCOUNT_ID"
|
|
|
|
ENV GEOIPUPDATE_LICENSE_KEY_FILE="/run/secrets/GEOIPUPDATE_LICENSE_KEY"
|
2022-12-20 21:09:30 +00:00
|
|
|
|
2023-05-08 11:46:42 +00:00
|
|
|
USER root
|
2022-12-20 21:09:30 +00:00
|
|
|
RUN --mount=type=secret,id=GEOIPUPDATE_ACCOUNT_ID \
|
|
|
|
--mount=type=secret,id=GEOIPUPDATE_LICENSE_KEY \
|
|
|
|
mkdir -p /usr/share/GeoIP && \
|
2023-07-13 10:51:37 +00:00
|
|
|
/bin/sh -c "/usr/bin/entry.sh || echo 'Failed to get GeoIP database, disabling'; exit 0"
|
2022-12-20 21:09:30 +00:00
|
|
|
|
|
|
|
# Stage 6: Run
|
2023-08-28 08:56:55 +00:00
|
|
|
FROM docker.io/python:3.11.5-slim-bookworm AS final-image
|
2019-12-30 09:34:31 +00:00
|
|
|
|
2023-06-23 22:10:27 +00:00
|
|
|
ARG GIT_BUILD_HASH
|
|
|
|
ARG VERSION
|
|
|
|
ENV GIT_BUILD_HASH=$GIT_BUILD_HASH
|
|
|
|
|
2021-12-30 15:33:13 +00:00
|
|
|
LABEL org.opencontainers.image.url https://goauthentik.io
|
|
|
|
LABEL org.opencontainers.image.description goauthentik.io Main server image, see https://goauthentik.io for more info.
|
|
|
|
LABEL org.opencontainers.image.source https://github.com/goauthentik/authentik
|
2023-06-23 22:10:27 +00:00
|
|
|
LABEL org.opencontainers.image.version ${VERSION}
|
|
|
|
LABEL org.opencontainers.image.revision ${GIT_BUILD_HASH}
|
2021-12-30 15:33:13 +00:00
|
|
|
|
2020-09-09 22:14:59 +00:00
|
|
|
WORKDIR /
|
2019-12-30 09:34:31 +00:00
|
|
|
|
2022-05-07 19:22:33 +00:00
|
|
|
COPY --from=poetry-locker /work/requirements.txt /
|
|
|
|
COPY --from=poetry-locker /work/requirements-dev.txt /
|
2022-12-20 21:09:30 +00:00
|
|
|
COPY --from=geoip /usr/share/GeoIP /geoip
|
2021-12-24 22:25:38 +00:00
|
|
|
|
2019-12-30 09:34:31 +00:00
|
|
|
RUN apt-get update && \
|
2022-05-07 19:22:33 +00:00
|
|
|
# Required for installing pip packages
|
2023-08-02 09:48:30 +00:00
|
|
|
apt-get install -y --no-install-recommends build-essential pkg-config libxmlsec1-dev zlib1g-dev libpq-dev python3-dev && \
|
2022-05-07 19:22:33 +00:00
|
|
|
# Required for runtime
|
2023-08-02 09:48:30 +00:00
|
|
|
apt-get install -y --no-install-recommends libpq5 openssl libxmlsec1-openssl libmaxminddb0 && \
|
2022-05-20 22:49:15 +00:00
|
|
|
# Required for bootstrap & healtcheck
|
2023-04-20 16:46:49 +00:00
|
|
|
apt-get install -y --no-install-recommends runit && \
|
2022-05-07 19:22:33 +00:00
|
|
|
pip install --no-cache-dir -r /requirements.txt && \
|
2023-08-02 09:48:30 +00:00
|
|
|
apt-get remove --purge -y build-essential pkg-config libxmlsec1-dev libpq-dev python3-dev && \
|
2020-09-27 19:07:29 +00:00
|
|
|
apt-get autoremove --purge -y && \
|
2021-05-09 22:38:58 +00:00
|
|
|
apt-get clean && \
|
2023-04-24 07:40:16 +00:00
|
|
|
rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/ /root/.cache && \
|
2020-12-05 21:08:42 +00:00
|
|
|
adduser --system --no-create-home --uid 1000 --group --home /authentik authentik && \
|
2022-08-01 21:05:58 +00:00
|
|
|
mkdir -p /certs /media /blueprints && \
|
2021-12-25 18:18:47 +00:00
|
|
|
mkdir -p /authentik/.ssh && \
|
2022-03-09 20:56:18 +00:00
|
|
|
chown authentik:authentik /certs /media /authentik/.ssh
|
2019-02-11 17:01:29 +00:00
|
|
|
|
2021-06-09 14:04:17 +00:00
|
|
|
COPY ./authentik/ /authentik
|
|
|
|
COPY ./pyproject.toml /
|
2023-03-06 18:39:08 +00:00
|
|
|
COPY ./schemas /schemas
|
2022-11-22 20:32:48 +00:00
|
|
|
COPY ./locale /locale
|
2021-06-09 14:04:17 +00:00
|
|
|
COPY ./tests /tests
|
|
|
|
COPY ./manage.py /
|
2022-08-07 17:27:03 +00:00
|
|
|
COPY ./blueprints /blueprints
|
2021-06-09 14:04:17 +00:00
|
|
|
COPY ./lifecycle/ /lifecycle
|
2023-08-26 19:42:36 +00:00
|
|
|
COPY --from=go-builder /work/bin/authentik /bin/authentik
|
2021-12-01 20:25:01 +00:00
|
|
|
COPY --from=web-builder /work/web/dist/ /web/dist/
|
|
|
|
COPY --from=web-builder /work/web/authentik/ /web/authentik/
|
|
|
|
COPY --from=website-builder /work/website/help/ /website/help/
|
2019-10-07 19:23:38 +00:00
|
|
|
|
2022-07-30 20:41:29 +00:00
|
|
|
USER 1000
|
2021-10-05 18:45:18 +00:00
|
|
|
|
2020-11-18 23:53:33 +00:00
|
|
|
ENV TMPDIR /dev/shm/
|
2021-09-14 10:06:47 +00:00
|
|
|
ENV PYTHONUNBUFFERED 1
|
2021-08-23 12:54:02 +00:00
|
|
|
ENV PATH "/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/lifecycle"
|
2021-10-05 18:45:18 +00:00
|
|
|
|
2021-10-06 07:18:01 +00:00
|
|
|
HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 CMD [ "/lifecycle/ak", "healthcheck" ]
|
2021-10-05 18:45:18 +00:00
|
|
|
|
2022-07-30 20:41:29 +00:00
|
|
|
ENTRYPOINT [ "/usr/local/bin/dumb-init", "--", "/lifecycle/ak" ]
|