github.com/joao-fontenele/go-url-shortener@v1.3.4/Dockerfile (about)

     1  # dev image
     2  FROM golang:1.14-alpine as dev
     3  
     4  RUN apk add --update --no-cache bash inotify-tools curl git make
     5  
     6  ENV CODE=/usr/src/app
     7  
     8  RUN mkdir -p ${CODE}/.gopath
     9  
    10  # allows static linking for alpine
    11  ENV CGO_ENABLED=0
    12  ENV GOPATH="${CODE}/.gopath"
    13  ENV GOCACHE="/tmp/go-build"
    14  ENV PATH="${PATH}:${GOPATH}/bin"
    15  
    16  WORKDIR ${CODE}
    17  
    18  CMD ["air", "-c", "air.toml"]
    19  
    20  # build image
    21  FROM dev as build
    22  
    23  COPY . ${CODE}/
    24  RUN make compile
    25  
    26  # production image
    27  FROM alpine as production
    28  
    29  RUN apk --no-cache add ca-certificates
    30  
    31  EXPOSE 8080
    32  
    33  ENV CODE=/usr/src/app
    34  
    35  WORKDIR ${CODE}
    36  
    37  RUN mkdir -p ${CODE}/config
    38  
    39  COPY --from=build ${CODE}/bin/server ${CODE}/server
    40  COPY ./config/default.yml ./config/production.yml ${CODE}/config/
    41  
    42  CMD ["/usr/src/app/server"]