diff --git a/Dockerfile b/Dockerfile index 5e6456e08..bcdf117c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,8 @@ FROM --platform=${BUILDPLATFORM} docker.io/node:18 as website-builder COPY ./website /work/website/ ENV NODE_ENV=production -RUN cd /work/website && npm ci && npm run build-docs-only +WORKDIR /work/website +RUN npm ci && npm run build-docs-only # Stage 2: Build webui FROM --platform=${BUILDPLATFORM} docker.io/node:18 as web-builder @@ -13,9 +14,21 @@ COPY ./web /work/web/ COPY ./website /work/website/ ENV NODE_ENV=production -RUN cd /work/web && npm ci && npm run build +WORKDIR /work/web +RUN npm ci && npm run build -# Stage 3: Build go proxy +# Stage 3: Poetry to requirements.txt export +FROM docker.io/python:3.10.4-slim-bullseye AS poetry-locker + +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 FROM docker.io/golang:1.18.1-bullseye AS builder WORKDIR /work @@ -31,7 +44,7 @@ COPY ./go.sum /work/go.sum RUN go build -o /work/authentik ./cmd/server/main.go -# Stage 4: Run +# Stage 5: Run FROM docker.io/python:3.10.4-slim-bullseye LABEL org.opencontainers.image.url https://goauthentik.io @@ -43,19 +56,18 @@ WORKDIR / ARG GIT_BUILD_HASH ENV GIT_BUILD_HASH=$GIT_BUILD_HASH -COPY ./pyproject.toml / -COPY ./poetry.lock / +COPY --from=poetry-locker /work/requirements.txt / +COPY --from=poetry-locker /work/requirements-dev.txt / RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - curl ca-certificates gnupg git runit libpq-dev \ - postgresql-client build-essential libxmlsec1-dev \ - pkg-config libmaxminddb0 && \ - pip install poetry && \ - poetry config virtualenvs.create false && \ - poetry install --no-dev && \ - rm -rf ~/.cache/pypoetry && \ - apt-get remove --purge -y build-essential git && \ + # Required for installing pip packages + apt-get install -y --no-install-recommends build-essential pkg-config libxmlsec1-dev && \ + # Required for runtime + apt-get install -y --no-install-recommends libxmlsec1-openssl libmaxminddb0 && \ + # Required for other things + apt-get install -y --no-install-recommends runit && \ + pip install --no-cache-dir -r /requirements.txt && \ + apt-get remove --purge -y build-essential pkg-config libxmlsec1-dev && \ apt-get autoremove --purge -y && \ apt-get clean && \ rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/ && \ diff --git a/Makefile b/Makefile index 1afa0d2b8..53bbb3e26 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,15 @@ test-e2e-rest: test-go: go test -timeout 0 -v -race -cover ./... +test-docker: + echo "PG_PASS=$(openssl rand -base64 32)" >> .env + echo "AUTHENTIK_SECRET_KEY=$(openssl rand -base64 32)" >> .env + docker-compose pull -q + docker-compose up --no-start + docker-compose start postgresql redis + docker-compose run -u root server test + rm -f .env + test: coverage run manage.py test authentik coverage html diff --git a/lifecycle/ak b/lifecycle/ak index 5367d02fb..7a3f6b668 100755 --- a/lifecycle/ak +++ b/lifecycle/ak @@ -54,9 +54,7 @@ elif [[ "$1" == "flower" ]]; then elif [[ "$1" == "bash" ]]; then /bin/bash elif [[ "$1" == "test" ]]; then - # https://github.com/python-poetry/poetry/issues/4493 - pip install platformdirs - poetry install + pip install --no-cache-dir -r /requirements-dev.txt touch /unittest.xml chown authentik:authentik /unittest.xml check_if_root "python -m manage test authentik" diff --git a/website/developer-docs/setup/full-dev-environment.md b/website/developer-docs/setup/full-dev-environment.md index 9f8f16353..84a68d8df 100644 --- a/website/developer-docs/setup/full-dev-environment.md +++ b/website/developer-docs/setup/full-dev-environment.md @@ -10,7 +10,7 @@ To create a local development setup for authentik, you need the following: - Python 3.10 - poetry, which is used to manage dependencies, and can be installed with `pip install poetry` -- Go 1.16 +- Go 1.18 - PostgreSQL (any recent version will do) - Redis (any recent version will do)