45 lines
998 B
Docker
45 lines
998 B
Docker
FROM node:24-alpine AS css
|
|
|
|
WORKDIR /src
|
|
|
|
RUN npm install --global pnpm@11.13.1 \
|
|
&& mkdir -p public internal/web
|
|
|
|
COPY package.json pnpm-lock.yaml ./
|
|
COPY tailwind.config.js ./tailwind.config.js
|
|
COPY public/tailwind.css ./public/tailwind.css
|
|
COPY internal/web/*.templ ./internal/web/
|
|
|
|
RUN pnpm install --frozen-lockfile \
|
|
&& pnpm run css:build
|
|
|
|
FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS build
|
|
|
|
WORKDIR /src
|
|
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
COPY --from=css /src/internal/web/tailwind.css ./internal/web/tailwind.css
|
|
|
|
RUN go run github.com/a-h/templ/cmd/templ@v0.3.960 generate
|
|
|
|
ARG TARGETOS
|
|
ARG TARGETARCH
|
|
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -trimpath -ldflags="-s -w" -o /out/authenticator .
|
|
|
|
FROM alpine:3.23
|
|
|
|
RUN apk add --no-cache ca-certificates tzdata \
|
|
&& addgroup -S app \
|
|
&& adduser -S -G app app
|
|
|
|
COPY --from=build /out/authenticator /usr/local/bin/authenticator
|
|
|
|
USER app
|
|
|
|
EXPOSE 8080
|
|
|
|
ENTRYPOINT ["authenticator"]
|