-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
40 lines (29 loc) · 1.2 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
###############################################################################
# Build stage
###############################################################################
FROM golang:latest AS builder
# Create and/or change our directory to /build
WORKDIR /build
# Copy go mod & go.sum files so we can verify they haven't been tampered with
COPY go.mod go.sum ./
RUN go mod download && go mod verify
# Copy everything from our root into /build
COPY . .
# Create and/or change our directory to /new-project-monitor
WORKDIR /build/cmd/new-project-monitor
# Create the binary for the app
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app-binary
###############################################################################
# Production stage
###############################################################################
# Start a new stage from scratch so that our final image is way smaller
# We use alpine instead of stratch since we need OS packages
FROM alpine:latest
# Create and/or change our directory to /app
WORKDIR /app
# Copy the binary from the build stage to the final stage
COPY --from=builder /build/cmd/new-project-monitor .
# Expose Port
EXPOSE 8080
# Run the app
CMD ["/app/app-binary"]