-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
43 lines (26 loc) · 1.01 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
FROM golang:1.14.3-alpine3.11 AS BUILD
RUN apk add curl
WORKDIR /opt
# download db if arg is not empty
ARG MAXMIND_LICENSE_KEY
ADD /sample/download-geolite2-city.sh /opt/
RUN /opt/download-geolite2-city.sh $MAXMIND_LICENSE_KEY
#city state csv for Brazil
RUN curl https://raw.githubusercontent.com/chandez/Estados-Cidades-IBGE/master/Municipios.sql --output Municipios.sql
RUN awk -F ',' '{print "BR," $4 "," $5}' Municipios.sql | sed -e "s/''/#/g" | sed -e "s/'//g" | sed -e "s/)//g" | sed -e "s/;//g" | sed -e s/", "/,/g | sed -e "s/#/'/g" > /opt/city-state.csv
WORKDIR /ruller/sample
ADD /go.mod /ruller/
ADD /go.sum /ruller/
ADD /sample/go.mod /ruller/sample/
ADD /sample/go.sum /ruller/sample/
# ENV GO111MODULE on
RUN go mod download
COPY / /ruller/
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags="-w -s" -o /ruller-sample
FROM alpine:3.11.5
ENV LOG_LEVEL "info"
COPY --from=BUILD /ruller-sample /bin/
COPY --from=BUILD /opt/ /opt/
ADD /sample/startup.sh /
EXPOSE 3000
CMD [ "/startup.sh" ]