Files
games/Dockerfile
Ryan Hamamura c77c491b64
All checks were successful
CI / Deploy / test (pull_request) Successful in 15s
CI / Deploy / lint (pull_request) Successful in 26s
CI / Deploy / deploy (pull_request) Has been skipped
feat: display app version in UI footer
- Add version package with build-time variables
- Inject version via ldflags in Dockerfile using git describe
- Show version in footer on every page
- Log version and commit on server startup
2026-03-03 09:23:37 -10:00

22 lines
677 B
Docker

FROM docker.io/golang:1.25.4-alpine AS build
RUN apk add --no-cache upx git
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go tool templ generate
RUN go tool gotailwind -i assets/css/input.css -o assets/css/output.css --minify
RUN --mount=type=cache,target=/root/.cache/go-build \
VERSION=$(git describe --tags --always) && \
COMMIT=$(git rev-parse --short HEAD) && \
CGO_ENABLED=0 go build -ldflags="-s -X github.com/ryanhamamura/games/version.Version=$VERSION -X github.com/ryanhamamura/games/version.Commit=$COMMIT" -o /bin/games .
RUN upx -9 -k /bin/games
FROM scratch
ENV PORT=8080
COPY --from=build /bin/games /
ENTRYPOINT ["/games"]