Skip to content

Commit 4251966

Browse files
authored
Merge pull request #3 from ndejong/ndejong-dockerfile-improvement-20230515
Dockerfile improvement
2 parents 590e66d + fcd9125 commit 4251966

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,7 @@ venv.bak/
102102

103103
# mypy
104104
.mypy_cache/
105+
106+
# IDEs
107+
.idea/
108+
.vscode/

Diff for: Dockerfile

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
# Use the official Golang image as the base image
2-
FROM golang:1.16-alpine
1+
# Use the official Golang image as the base image - https://hub.docker.com/_/golang/tags
2+
FROM golang:1.20-alpine as builder
33

44
# Set the working directory
55
WORKDIR /app
66

7-
# Copy go.mod and go.sum files to the container
8-
COPY go.mod go.sum ./
7+
# Copy source to this builder container
8+
COPY . /app
99

10-
# Download dependencies
11-
RUN go mod download
12-
13-
# Copy the source code to the container
14-
COPY . .
10+
# Download build dependencies
11+
RUN go get github.com/codingo/dorky
1512

1613
# Build the application
1714
RUN go build -o main .
1815

19-
# Set the entrypoint for the container
16+
# Bump the application with --help to know it was built
17+
RUN /app/main --help
18+
19+
20+
# Use an Alpine container to deploy/run the application from - https://hub.docker.com/_/alpine/tags
21+
FROM alpine:3.18
22+
23+
WORKDIR /app
24+
COPY --from=builder /app/main /app/main
25+
2026
ENTRYPOINT ["/app/main"]

0 commit comments

Comments
 (0)