forked from copilot-example-voting-app/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
27 lines (22 loc) · 843 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
FROM golang:1.15.2 as builder
# Copy all the source files for the api service.
RUN mkdir /svc
ADD . /svc
# We specify that we now wish to execute any further commands inside the /svc directory.
WORKDIR /svc
# Build the binary
ENV GOPROXY=direct
RUN go build -o api ./cmd/api
# Target used by our compose file, we have to port wait-for-postgres.sh so that the containers come up in the proper order.
FROM builder as local
EXPOSE 8080
HEALTHCHECK --interval=15s --timeout=10s --start-period=30s \
CMD curl -f http://localhost:8080/_healthcheck || exit 1
CMD ["./api"]
# For the real image, we'll only copy the binaryso that the image size is small.
FROM builder
COPY --from=builder /svc/api /
EXPOSE 8080
HEALTHCHECK --interval=15s --timeout=10s --start-period=30s \
CMD curl -f http://localhost:8080/_healthcheck || exit 1
CMD ["/api"]