github.com/JarrahG/buffalocli@v0.0.0-20230801092127-b85bfd5d395a/internal/genny/docker/templates/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 GOPROXY http://proxy.golang.org
     6  
     7  RUN mkdir -p /src/{{.opts.App.PackagePkg}}
     8  WORKDIR /src/{{.opts.App.PackagePkg}}
     9  
    10  {{if .opts.App.WithWebpack -}}
    11  # this will cache the npm install step, unless package.json changes
    12  ADD package.json .
    13  {{if .opts.App.WithYarn -}}
    14  ADD yarn.lock .yarnrc.yml ./
    15  RUN mkdir .yarn
    16  COPY .yarn .yarn
    17  RUN yarn install
    18  {{else -}}
    19  RUN npm install --no-progress
    20  {{end -}}
    21  {{end -}}
    22  
    23  # Copy the Go Modules manifests
    24  COPY go.mod go.mod
    25  COPY go.sum go.sum
    26  # cache deps before building and copying source so that we don't need to re-download as much
    27  # and so that source changes don't invalidate our downloaded layer
    28  RUN go mod download
    29  
    30  ADD . .
    31  RUN buffalo build --static -o /bin/app
    32  
    33  FROM alpine
    34  RUN apk add --no-cache bash
    35  RUN apk add --no-cache ca-certificates
    36  
    37  WORKDIR /bin/
    38  
    39  COPY --from=builder /bin/app .
    40  
    41  # Uncomment to run the binary in "production" mode:
    42  # ENV GO_ENV=production
    43  
    44  # Bind the app to 0.0.0.0 so it can be seen from outside the container
    45  ENV ADDR=0.0.0.0
    46  
    47  EXPOSE 3000
    48  
    49  # Uncomment to run the migrations before running the binary:
    50  # CMD /bin/app migrate; /bin/app
    51  CMD exec /bin/app