2021-12-24 22:25:38 +00:00
|
|
|
# Stage 1: Build website
|
2023-04-21 10:54:23 +00:00
|
|
|
FROM --platform=${BUILDPLATFORM} docker.io/node:20 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
|
|
|
|
RUN npm ci && 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-04-21 10:54:23 +00:00
|
|
|
FROM --platform=${BUILDPLATFORM} docker.io/node:20 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
|
|
|
|
RUN npm ci && 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-04-06 16:03:28 +00:00
|
|
|
FROM docker.io/python:3.11.3-slim-bullseye 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-05-03 09:07:05 +00:00
|
|
|
FROM docker.io/golang:1.20.4-bullseye 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
|
|
|
|
COPY ./web/static.go /work/web/static.go
|
|
|
|
COPY ./internal /work/internal
|
|
|
|
COPY ./go.mod /work/go.mod
|
|
|
|
COPY ./go.sum /work/go.sum
|
|
|
|
|
2022-10-11 10:42:10 +00:00
|
|
|
RUN go build -o /work/authentik ./cmd/server/
|
2021-05-02 22:49:16 +00:00
|
|
|
|
2022-12-20 21:09:30 +00:00
|
|
|
# Stage 5: MaxMind GeoIP
|
2023-05-08 10:02:16 +00:00
|
|
|
FROM docker.io/maxmindinc/geoipupdate:v5.1 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"
|
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 && \
|
|
|
|
/bin/sh -c "\
|
|
|
|
export GEOIPUPDATE_ACCOUNT_ID=$(cat /run/secrets/GEOIPUPDATE_ACCOUNT_ID); \
|
|
|
|
export GEOIPUPDATE_LICENSE_KEY=$(cat /run/secrets/GEOIPUPDATE_LICENSE_KEY); \
|
2023-01-09 13:29:08 +00:00
|
|
|
/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-04-06 16:03:28 +00:00
|
|
|
FROM docker.io/python:3.11.3-slim-bullseye AS final-image
|
2019-12-30 09:34:31 +00:00
|
|
|
|
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
|
|
|
|
|
2020-09-09 22:14:59 +00:00
|
|
|
WORKDIR /
|
2019-12-30 09:34:31 +00:00
|
|
|
|
2021-03-16 13:42:01 +00:00
|
|
|
ARG GIT_BUILD_HASH
|
|
|
|
ENV GIT_BUILD_HASH=$GIT_BUILD_HASH
|
|
|
|
|
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
|
2022-11-21 21:38:22 +00:00
|
|
|
apt-get install -y --no-install-recommends build-essential pkg-config libxmlsec1-dev zlib1g-dev && \
|
2022-05-07 19:22:33 +00:00
|
|
|
# Required for runtime
|
|
|
|
apt-get install -y --no-install-recommends 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 && \
|
|
|
|
apt-get remove --purge -y build-essential pkg-config libxmlsec1-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 && \
|
|
|
|
rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/ && \
|
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-03-30 12:04:38 +00:00
|
|
|
COPY --from=go-builder /work/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" ]
|