-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile.dev
More file actions
42 lines (36 loc) · 1.5 KB
/
Dockerfile.dev
File metadata and controls
42 lines (36 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# syntax=docker/dockerfile:1
#
# Dockerfile for compose / local development. Builds the SPA, builds the
# Go binary, and ships it in a distroless static image. Slower than the
# goreleaser-shaped Dockerfile (which expects a pre-built binary), but
# self-contained: `docker compose build` Just Works.
FROM node:22-alpine AS ui
WORKDIR /src/ui
COPY ui/package.json ui/pnpm-lock.yaml ./
RUN corepack enable && pnpm install --frozen-lockfile
COPY ui/ ./
RUN pnpm build
FROM golang:1.26-alpine AS build
WORKDIR /src
RUN apk add --no-cache git ca-certificates
COPY go.mod go.sum ./
RUN go mod download
COPY . .
COPY --from=ui /src/ui/dist /src/internal/ui/dist
ARG VERSION=dev
ARG COMMIT=unknown
ARG DATE=unknown
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags "-s -w -X github.com/plexara/api-test/pkg/build.Version=${VERSION} -X github.com/plexara/api-test/pkg/build.Commit=${COMMIT} -X github.com/plexara/api-test/pkg/build.Date=${DATE}" \
-o /out/api-test ./cmd/api-test
FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=build /out/api-test /usr/local/bin/api-test
COPY configs/api-test.example.yaml /app/configs/api-test.yaml
USER nonroot:nonroot
EXPOSE 8080
# Distroless has no shell so we use the binary itself for healthcheck.
# /healthz returns 200 from the unauthenticated health endpoint.
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD ["/usr/local/bin/api-test", "--healthcheck"] || exit 1
ENTRYPOINT ["/usr/local/bin/api-test"]
CMD ["--config", "/app/configs/api-test.yaml"]