go-guess/Dockerfile
Daniel Noulet 5449cd3d8d feat: avatar, account menu, and single sign-on from Go Loose
Signing in now starts at the sign-in screen and one button that hands the
browser to Go Loose, which returns to the welcome page. Nothing redirects to the
identity provider on its own any more: that fired on every anonymous visit and
read as a redirect loop rather than as a choice to sign in. The password form
remains only where the API reports that Go Loose login is not configured for the
host, because otherwise the application is unreachable on a bare localhost.

A person's picture is carried through from the Go Loose identity and rendered in
the account menu and on the profile page, with their initials as the fallback.
Two things make that fallback necessary rather than decorative: Go Loose retires a
picture key when a picture is replaced, so a link cached in a browser can be dead,
and most people have not uploaded one. The URL is deliberately not persisted
locally, since a stored key would keep failing after the picture changed.

The account menu is a disclosure rather than a hover menu: a real button with
aria-expanded, Escape and outside clicks closing it, and focus returning to the
trigger. It is not an ARIA menu, because its actions are a link and a button and
menuitem roles would strip the link semantics from one of them for no gain.

The account URL of the Go Loose identity is resolved on each sign-in and is read
from the live identity provider every time, which is also what makes it correct
after a picture change.

Depends on the Go Loose revision that serves avatar_url through
/connect/userinfo, so the picture URL reaches this application at all.
2026-10-05 21:50:06 +02:00

49 lines
1.7 KiB
Docker

# Build the React frontend.
FROM node:26-alpine AS frontend
WORKDIR /src/frontend
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build
# Compile the API and seed binaries.
FROM golang:1.27.1-alpine AS backend
WORKDIR /src/backend
COPY backend/go.mod backend/go.sum ./
RUN go mod download
COPY backend/ ./
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/api ./cmd/api \
&& CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/seed ./cmd/seed
# Build the migration CLI separately so its dependencies stay out of the app layer.
FROM golang:1.27.1-alpine AS tools
RUN GOBIN=/out go install github.com/pressly/goose/v3/cmd/goose@v3.26.0
# Run the frontend and API behind one HTTP endpoint.
FROM alpine:3.22
RUN apk add --no-cache ca-certificates nginx tzdata \
&& addgroup -S app \
&& adduser -S -G app -u 10001 app \
&& mkdir -p /app/frontend /app/migrations /tmp/nginx \
&& chown -R app:app /app /tmp/nginx
WORKDIR /app
COPY --from=frontend --chown=app:app /src/frontend/dist/ ./frontend/
COPY --from=backend /out/api /usr/local/bin/api
COPY --from=backend /out/seed /usr/local/bin/seed
COPY --from=tools /out/goose /usr/local/bin/goose
COPY --chown=app:app backend/migrations/ ./migrations/
COPY docker/nginx.conf /etc/nginx/nginx.conf
COPY docker/entrypoint.sh /usr/local/bin/go-guess-entrypoint
USER app
USER 1000
EXPOSE 8080
ENV ADDRESS=:8081 \
APP_ENV=production \
FRONTEND_URL=http://localhost:8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s \
CMD wget -qO- http://127.0.0.1:8080/api/health >/dev/null || exit 1
ENTRYPOINT ["/usr/local/bin/go-guess-entrypoint"]