-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (25 loc) · 774 Bytes
/
Dockerfile
File metadata and controls
37 lines (25 loc) · 774 Bytes
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
# syntax=docker/dockerfile:experimental
FROM golang:1.22-alpine3.20 AS base
RUN apk add --no-cache git
WORKDIR /app
COPY go.* ./
RUN go mod download
COPY . .
RUN go mod tidy
FROM base as lint
RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.0
RUN /go/bin/golangci-lint run --timeout 10m0s ./... || true
FROM base as test
RUN go test -v -coverprofile=cover.out ./... || true
RUN go tool cover -func=cover.out
FROM base as builder
RUN CGO_ENABLED=0 GOOS=linux go build -o main cmd/server/main.go
FROM alpine:3.20
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
WORKDIR /app
RUN touch .env && chown appuser:appgroup .env
COPY --from=builder /app/main .
RUN chown appuser:appgroup main
USER appuser
HEALTHCHECK NONE
CMD ["./main"]