diff --git a/.gitignore b/.gitignore index baa01c9..b00d8eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ # Binaries +authelia-api +src/authelia-api src/server # Dependency directories diff --git a/Dockerfile b/Dockerfile index e3f9858..a4ae1c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,10 @@ # Authelia + Authelia-API combined container # =========================================== # Runs both Authelia (auth portal, port 9091) and Authelia-API -# (user management API, port 8080) in a single container. +# (user management + policy management API, port 8080) in a single container. +# +# Build: +# docker build -t git24hcom/authelia-api:latest . # # Volumes: # /config — Authelia config + user DB + notification templates @@ -16,7 +19,6 @@ FROM alpine:3.21 AS authelia-dl ARG AUTHELIA_VERSION=4.39.20 ARG TARGETARCH=amd64 -ARG TARGETPLATFORM=linux/amd64 WORKDIR /tmp ADD https://github.com/authelia/authelia/releases/download/v${AUTHELIA_VERSION}/authelia-v${AUTHELIA_VERSION}-linux-${TARGETARCH}.tar.gz /tmp/authelia.tar.gz @@ -24,7 +26,15 @@ RUN tar -xzf /tmp/authelia.tar.gz && \ mv authelia /usr/local/bin/authelia && \ chmod +x /usr/local/bin/authelia -# --- Stage 2: runtime image (glibc-based for Authelia binary) --- +# --- Stage 2: build Authelia-API from source --- +FROM golang:1.22-bookworm AS go-build + +WORKDIR /build +COPY src/ . +RUN go mod download && \ + CGO_ENABLED=0 go build -ldflags="-s -w" -o authelia-api ./cmd/server + +# --- Stage 3: runtime image --- FROM debian:bookworm-slim RUN apt-get update && apt-get install -y --no-install-recommends \ @@ -34,9 +44,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ netcat-openbsd \ && rm -rf /var/lib/apt/lists/* -# Copy binaries +# Copy binaries from build stages COPY --from=authelia-dl /usr/local/bin/authelia /usr/local/bin/authelia -COPY authelia-api /usr/local/bin/authelia-api +COPY --from=go-build /build/authelia-api /usr/local/bin/authelia-api # Create directories RUN mkdir -p /config /data /certs && \ diff --git a/authelia-api b/authelia-api deleted file mode 100644 index c23bfd7..0000000 Binary files a/authelia-api and /dev/null differ diff --git a/docker-compose.yml b/docker-compose.yml index 3187b17..d8180b1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,9 +11,12 @@ # ============================================================================= services: - authelia: - image: git24hcom/authelia:latest - container_name: authelia + authelia-api: + image: git24hcom/authelia-api:latest + container_name: authelia-api + build: + context: . + dockerfile: Dockerfile restart: unless-stopped ports: - "9091:9091" # Authelia web portal