-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
58 lines (45 loc) · 1.78 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Use the offical golang image to create a binary.
# This is based on Debian and sets the GOPATH to /go.
# https://hub.docker.com/_/golang
FROM golang:1.19-buster as builder
ENV TZ=UTC
RUN set -x \
&& apt-get update \
&& apt-get install -y build-essential ca-certificates git-core zip \
&& rm -rf /var/lib/apt/lists/*
RUN set -x \
&& go install github.com/AlekSi/[email protected] \
&& go install github.com/axw/gocov/[email protected] \
&& go install github.com/t-yuki/gocover-cobertura@latest \
&& go install github.com/tebeka/[email protected]
# Create and change to the app directory.
WORKDIR /go/src/github.com/insighted4/correios-cep
# Retrieve application dependencies.
# This allows the container build to reuse cached dependencies.
# Expecting to copy go.mod and if present go.sum.
COPY go.* ./
RUN go mod download
# Copy local code to the container image.
COPY . ./
# Build the binary.
RUN set -x \
&& make testall \
&& make release-binary \
&& mkdir -p /usr/share/correios-cep \
&& cp -r ./release/bin /usr/share/correios-cep/. \
&& cp -r ./results /usr/share/correios-cep/. \
&& echo "Build complete."
# Use the official Debian slim image for a lean production container.
# https://hub.docker.com/_/debian
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
FROM debian:buster-slim
ENV TZ=UTC
RUN set -x \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy the binary to the production image from the builder stage.
COPY --from=builder /usr/share/correios-cep /usr/share/correios-cep
RUN ln -s /usr/share/correios-cep/bin/admin /usr/bin/admin
# Run the web service on container startup.
CMD ["admin", "version"]