Created
September 23, 2020 05:03
-
-
Save utamori/14a93df3d2bd0a5dd446445fc2ac667a to your computer and use it in GitHub Desktop.
go言語用dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM golang:1.15-buster AS debug | |
| WORKDIR /app | |
| COPY . . | |
| RUN curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin | |
| CMD air | |
| FROM golang:1.15-buster AS build | |
| WORKDIR /app | |
| ENV CGO_ENABLED=0 | |
| COPY go.* ./ | |
| RUN go mod download | |
| COPY . ./ | |
| RUN GOOS=linux go build -mod=readonly -v -o server | |
| # k8s、cloud-run用ビルド --target deploy | |
| FROM alpine:3 AS deploy | |
| RUN apk --no-cache add tzdata && \ | |
| cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime | |
| RUN apk add --no-cache ca-certificates | |
| COPY --from=build /app/server /server | |
| CMD ["/server"] |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
マルチステージビルドで、
開発用のdebugにはAirを導入