Skip to content

Commit 368115a

Browse files
authored
Merge pull request #6 from rog-golang-buddies/fix-dockerfile-issue-pallasite99
Fix: Update Dockerfile
2 parents 122d68c + b0e2720 commit 368115a

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

.github/workflows/docker-image.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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)

Dockerfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
FROM golang:1.18 as build
22
WORKDIR /go/src/app
3+
4+
# Copy the entire source code to the container's workspace
35
COPY . .
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
912
FROM 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+
1215
USER 65532:65532
16+
1317
CMD ["/app"]

0 commit comments

Comments
 (0)