forked from antoniopaya22/go-rest-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
36 lines (24 loc) · 772 Bytes
/
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
FROM golang:1.15.3-alpine AS build_base
ENV CGO_ENABLED=1
ENV GO111MODULE=on
RUN apk add --no-cache git git gcc g++
# Set the Current Working Directory inside the container
WORKDIR /src
# We want to populate the module cache based on the go.{mod,sum} files.
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
# Build the Go app
RUN go build -o ./out/app ./cmd/api/main.go
# Start fresh from a smaller image
FROM alpine:3.12
RUN apk add ca-certificates
WORKDIR /app
COPY --from=build_base /src/out/app /app/restapi
COPY --from=build_base /src/data /app/data
RUN chmod +x restapi
# This container exposes port 8080 to the outside world
EXPOSE 3000
# Run the binary program produced by `go install`
ENTRYPOINT ./restapi