Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,23 @@

# Unified AuthBridge binary (Envoy + authbridge in one container)
# Drop-in replacement for envoy-with-processor
# DEPRECATED: use authbridge-envoy instead

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authbridge-unified is deprecated here but will keep getting built until explicitly removed. Consider adding a comment referencing a follow-up issue (e.g. # TODO: remove in vX.Y — track in #NNN) so this doesn't get forgotten.

- name: authbridge-unified
context: ./authbridge
dockerfile: cmd/authbridge/Dockerfile

# AuthBridge with Envoy (envoy-sidecar mode)
# New canonical name for authbridge-unified
- name: authbridge-envoy
context: ./authbridge
dockerfile: cmd/authbridge/Dockerfile

# Lightweight AuthBridge (Go binary only, no Envoy)
# Used for waypoint and proxy-sidecar modes
- name: authbridge-light
context: ./authbridge
dockerfile: cmd/authbridge/Dockerfile.light

# Demo application for testing
- name: demo-app
context: ./authbridge/authproxy/quickstart/demo-app
Expand Down Expand Up @@ -102,7 +115,7 @@
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6
with:
images: ghcr.io/${{ github.repository }}/${{ matrix.image_config.name }}
tags: |

Check warning on line 118 in .github/workflows/build.yaml

View workflow job for this annotation

GitHub Actions / YAML Lint

118:151 [line-length] line too long (189 > 150 characters)
# Always use the computed tag
type=raw,value=${{ steps.tag.outputs.tag }}
# Add 'latest' tag for version tags, workflow_dispatch, and pushes to main
Expand Down
25 changes: 13 additions & 12 deletions authbridge/cmd/authbridge/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# AuthBridge unified image — Envoy + authbridge binary in one container.
# Drop-in replacement for envoy-with-processor (Dockerfile.envoy).
#
# Uses UBI9-micro base (~24 MB) instead of UBI9-minimal (~134 MB)
# for a ~42% smaller image while remaining glibc-compatible for Envoy.
# Total image size: ~140 MB (24 MB base + 87 MB Envoy + 26 MB authbridge).
#
# Build context: ./authbridge (needs access to both authlib/ and cmd/authbridge/)

# Stage 1: Build authbridge binary
FROM golang:1.24-alpine AS builder
FROM golang:1.24-alpine@sha256:8bee1901f1e530bfb4a7850aa7a479d17ae3a18beb6e09064ed54cfd245b7191 AS builder

RUN apk add --no-cache git

Expand All @@ -18,23 +22,20 @@
# In Docker the layout is /app/authlib and /app/cmd/authbridge, so the
# relative path ../../authlib resolves to /app/authlib. Correct.
ENV GOWORK=off
RUN cd cmd/authbridge && CGO_ENABLED=0 GOOS=linux go build -o /authbridge .

Check failure on line 25 in authbridge/cmd/authbridge/Dockerfile

View workflow job for this annotation

GitHub Actions / Dockerfile Lint (Hadolint)

DL3003 warning: Use WORKDIR to switch to a directory

# Stage 2: Get Envoy binary
FROM docker.io/envoyproxy/envoy:v1.37.1 AS envoy-source

# Stage 3: Runtime — same base as Dockerfile.envoy
FROM registry.access.redhat.com/ubi9/ubi-minimal@sha256:83006d535923fcf1345067873524a3980316f51794f01d8655be55d6e9387183

RUN microdnf install -y ca-certificates && microdnf clean all

COPY --from=envoy-source /usr/local/bin/envoy /usr/local/bin/envoy
COPY --from=builder /authbridge /usr/local/bin/authbridge
COPY cmd/authbridge/entrypoint.sh /usr/local/bin/entrypoint.sh
# Stage 3: Runtime — UBI9-micro (glibc-compatible, ~24 MB)
# UBI9-micro has no package manager and no CA certificates.
# CA certs are copied from the Alpine builder for HTTPS (JWKS, Keycloak).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice — copying CA certs from the Alpine builder is the correct way to handle UBI9-micro (no microdnf, no CA bundle pre-installed). The inline comment explaining why makes this easy to understand later.

FROM registry.access.redhat.com/ubi9/ubi-micro@sha256:2173487b3b72b1a7b11edc908e9bbf1726f9df46a4f78fd6d19a2bab0a701f38

RUN chmod 755 /usr/local/bin/entrypoint.sh \
/usr/local/bin/envoy \
/usr/local/bin/authbridge
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=envoy-source --chmod=755 /usr/local/bin/envoy /usr/local/bin/envoy
COPY --from=builder --chmod=755 /authbridge /usr/local/bin/authbridge
COPY --chmod=755 cmd/authbridge/entrypoint.sh /usr/local/bin/entrypoint.sh

# Envoy writes hot-restart lock files and admin socket here
RUN mkdir -p /tmp/envoy && chmod 775 /tmp/envoy
Expand Down
33 changes: 33 additions & 0 deletions authbridge/cmd/authbridge/Dockerfile.light
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# AuthBridge lightweight image — Go binary only, no Envoy.
# Used for waypoint and proxy-sidecar modes where Envoy is not needed.
# For envoy-sidecar mode, use the main Dockerfile which includes Envoy.
#
# Uses distroless base (~2 MB) for minimal attack surface.
# The binary is statically linked (CGO_ENABLED=0), so no glibc needed.
# No shell — debug via kubectl logs, not kubectl exec.
#
# Build context: ./authbridge (needs access to both authlib/ and cmd/authbridge/)

# Stage 1: Build authbridge binary
FROM golang:1.24-alpine@sha256:8bee1901f1e530bfb4a7850aa7a479d17ae3a18beb6e09064ed54cfd245b7191 AS builder

RUN apk add --no-cache git

WORKDIR /app

# Copy both modules with Docker-compatible layout
COPY authlib/ authlib/
COPY cmd/authbridge/ cmd/authbridge/

ENV GOWORK=off
RUN cd cmd/authbridge && CGO_ENABLED=0 GOOS=linux go build -o /authbridge .

Check failure on line 23 in authbridge/cmd/authbridge/Dockerfile.light

View workflow job for this annotation

GitHub Actions / Dockerfile Lint (Hadolint)

DL3003 warning: Use WORKDIR to switch to a directory

# Stage 2: Runtime — distroless static (~2 MB, includes CA certs)
FROM gcr.io/distroless/static-debian12:nonroot@sha256:a9329520abc449e3b14d5bc3a6ffae065bdde0f02667fa10880c49b35c109fd1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good choice of distroless/static-debian12:nonroot — statically linked binary, non-root by default from the image tag, and CA certs are included in the static variant. No explicit COPY needed.


COPY --from=builder --chmod=755 /authbridge /usr/local/bin/authbridge

# ext_authz/ext_proc (9090), forward proxy (8080), reverse proxy (8081)
EXPOSE 9090 8080 8081

ENTRYPOINT ["/usr/local/bin/authbridge"]
Loading