github.com/segakazzz/buffalo@v0.16.22-0.20210119082501-1f52048d3feb/genny/docker/templates/multi/Dockerfile.tmpl (about)

     1  # This is a multi-stage Dockerfile and requires >= Docker 17.05
     2  # https://docs.docker.com/engine/userguide/eng-image/multistage-build/
     3  FROM gobuffalo/buffalo:{{.opts.Version}} as builder
     4  
     5  ENV GO111MODULE on
     6  ENV GOPROXY http://proxy.golang.org
     7  
     8  RUN mkdir -p /src/{{.opts.App.PackagePkg}}
     9  WORKDIR /src/{{.opts.App.PackagePkg}}
    10  
    11  {{if .opts.App.WithWebpack -}}
    12  # this will cache the npm install step, unless package.json changes
    13  ADD package.json .
    14  {{if .opts.App.WithYarn -}}
    15  ADD yarn.lock .
    16  RUN yarn install --no-progress
    17  {{else -}}
    18  RUN npm install --no-progress
    19  {{end -}}
    20  {{end -}}
    21  
    22  # Copy the Go Modules manifests
    23  COPY go.mod go.mod
    24  COPY go.sum go.sum
    25  # cache deps before building and copying source so that we don't need to re-download as much
    26  # and so that source changes don't invalidate our downloaded layer
    27  RUN go mod download
    28  
    29  ADD . .
    30  RUN buffalo build --static -o /bin/app
    31  
    32  FROM alpine
    33  RUN apk add --no-cache bash
    34  RUN apk add --no-cache ca-certificates
    35  
    36  WORKDIR /bin/
    37  
    38  COPY --from=builder /bin/app .
    39  
    40  # Uncomment to run the binary in "production" mode:
    41  # ENV GO_ENV=production
    42  
    43  # Bind the app to 0.0.0.0 so it can be seen from outside the container
    44  ENV ADDR=0.0.0.0
    45  
    46  EXPOSE 3000
    47  
    48  # Uncomment to run the migrations before running the binary:
    49  # CMD /bin/app migrate; /bin/app
    50  CMD exec /bin/app