Skip to content

Commit 49c83f3

Browse files
authored
DOC: Added Go dockerfile template (#553)
* sample-docker-templates added * go dockerfile-template added
1 parent 8f87dd1 commit 49c83f3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
################################# Build Container ###############################
2+
3+
FROM golang:1.16 as builder
4+
5+
# Setup the working directory
6+
WORKDIR /app
7+
8+
# Add source code
9+
ADD . /app/
10+
11+
# Build the source
12+
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main app.go
13+
14+
15+
################################# Prod Container #################################
16+
17+
# Use a minimal alpine image
18+
FROM alpine:3.7
19+
20+
# Add ca-certificates in case you need them
21+
RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
22+
23+
# Set working directory
24+
WORKDIR /root
25+
26+
# Copy the binary from builder
27+
COPY --from=builder /app/. .
28+
29+
# Run the binary
30+
CMD ["./main"]
31+
32+
33+
34+

0 commit comments

Comments
 (0)