chore: 3-stage Docker build from source, rename image to authelia-api
- Dockerfile builds Go source in stage 2 (golang:1.22) instead of copying pre-built binary - Image renamed to git24hcom/authelia-api:latest - docker-compose.yml: updated image name, added build directive - .gitignore: ignore root-level authelia-api binary - Removed pre-built binary from git tracking (now built in Docker)
This commit is contained in:
parent
4ab00e0761
commit
00165e9fef
4 changed files with 23 additions and 8 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,4 +1,6 @@
|
|||
# Binaries
|
||||
authelia-api
|
||||
src/authelia-api
|
||||
src/server
|
||||
|
||||
# Dependency directories
|
||||
|
|
|
|||
20
Dockerfile
20
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 && \
|
||||
|
|
|
|||
BIN
authelia-api
BIN
authelia-api
Binary file not shown.
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue