-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
42 lines (26 loc) · 1.18 KB
/
Dockerfile
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
FROM golang:1.23-alpine
# Ensure that HEALTHCHECK instructions have been added to container images
# checkov:skip=CKV_DOCKER_2: Since Kubernetes 1.8, the Docker HEALTHCHECK has been disabled explicitly
# Create a non-root user for security purposes
RUN addgroup -S gke-info && adduser -S gke-info -G gke-info
USER gke-info
ARG DD_GIT_REPOSITORY_URL
ARG DD_GIT_COMMIT_SHA
ENV DD_GIT_REPOSITORY_URL=${DD_GIT_REPOSITORY_URL}
ENV DD_GIT_COMMIT_SHA=${DD_GIT_COMMIT_SHA}
# Set the working directory inside the container
WORKDIR /app
# Pre-copy/cache go.mod for pre-downloading dependencies and only re-downloading them in subsequent builds if they change
COPY go.mod go.sum ./
RUN go mod download && go mod verify
# Copy the source code. Note the slash at the end, as explained in
# https://docs.docker.com/reference/dockerfile/#copy
COPY cmd/ /app/cmd/
COPY internal/ /app/internal/
# Build the application
# For Datadog ASM the Go build tag appsec is not necessary if CGO is enabled with CGO_ENABLED=1
RUN GOOS=linux CGO_ENABLED=0 go build -v -tags appsec -o main cmd/http/main.go
# Expose the port your application listens on
EXPOSE 8080
# Define the command to run your application
CMD ["./main"]