-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
45 lines (26 loc) · 982 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
37
38
39
40
41
42
43
44
45
FROM golang:1.20.5-alpine AS base
# Build golang healthcheck binary
FROM base AS healthcheck
ARG VERSION=0.1.0
RUN wget -O - https://github.com/hibare/go-docker-healthcheck/archive/refs/tags/v${VERSION}.tar.gz | tar zxf -
WORKDIR /go/go-docker-healthcheck-${VERSION}
RUN CGO_ENABLED=0 go build -o /bin/healthcheck
# Build main app
FROM base AS build
ARG GIT_VERSION_TAG=dev
WORKDIR /src/
COPY . /src/
RUN apk --no-cache add ca-certificates
RUN CGO_ENABLED=0 go build -ldflags "-X github.com/hibare/GoGeoIP/cmd.Version=$GIT_VERSION_TAG" -o /bin/go_geo_ip ./main.go
# Generate final image
FROM alpine
ENV API_LISTEN_ADDR 0.0.0.0
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /bin/go_geo_ip /bin/go_geo_ip
COPY --from=healthcheck /bin/healthcheck /bin/healthcheck
HEALTHCHECK \
--interval=30s \
--timeout=3s \
CMD ["healthcheck","http://localhost:5000/api/v1/health/"]
EXPOSE 5000
CMD ["/bin/go_geo_ip", "serve"]