File tree Expand file tree Collapse file tree 2 files changed +28
-6
lines changed Expand file tree Collapse file tree 2 files changed +28
-6
lines changed Original file line number Diff line number Diff line change 1+ name : Docker Image CI
2+
3+ on :
4+ push :
5+ branches : [ "main" ]
6+ pull_request :
7+ branches : [ "main" ]
8+
9+ jobs :
10+
11+ build :
12+
13+ runs-on : ubuntu-latest
14+
15+ steps :
16+ - uses : actions/checkout@v3
17+ - name : Build the Docker image
18+ run : docker build . --file Dockerfile --tag my-image-name:$(date +%s)
Original file line number Diff line number Diff line change 11FROM golang:1.18 as build
22WORKDIR /go/src/app
3+
4+ # Copy the entire source code to the container's workspace
35COPY . .
4- # Static build requires CGO_ENABLED=0
5- RUN mkdir -p /go/bin && CGO_ENABLED=0 go build -ldflags="-w -s" -o /go/bin/app ./...
6+ # Debugging step: Check current directory and contents of the 'cmd' directory
7+ RUN pwd
8+ RUN ls -la /go/src/app/cmd
69
7- # Using a distroless image from https://github.com/GoogleContainerTools/distroless
8- # Image sourced from https://console.cloud.google.com/gcr/images/distroless/global/static
10+ # Static build
11+ RUN CGO_ENABLED=0 go build -ldflags= "-w -s" -o /go/bin/app ./cmd
912FROM gcr.io/distroless/static:nonroot
10- COPY --from=build /go/bin/app /
11- # numeric version of user nonroot:nonroot provided in image
13+ COPY --from=build /go/bin/app /app
14+
1215USER 65532:65532
16+
1317CMD ["/app" ]
You can’t perform that action at this time.
0 commit comments