forked from Jagadeeshftw/grainlify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (22 loc) · 744 Bytes
/
Dockerfile
File metadata and controls
37 lines (22 loc) · 744 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
# syntax=docker/dockerfile:1
FROM golang:1.24-alpine AS build
WORKDIR /src
# Dependencies for module download (git) and CA certs for HTTPS module fetches.
RUN apk add --no-cache git ca-certificates
# Copy only go.{mod,sum} first to leverage Docker layer caching.
COPY backend/go.mod backend/go.sum ./backend/
WORKDIR /src/backend
RUN go mod download
# Copy the backend source and build the API binary.
COPY backend/ ./
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -trimpath -ldflags="-s -w" -o /out/api ./cmd/api
FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata \
&& adduser -D -H -u 10001 appuser
WORKDIR /app
COPY --from=build /out/api /app/api
USER appuser
ENV PORT=8080
EXPOSE 8080
CMD ["/app/api"]