Skip to content

Instantly share code, notes, and snippets.

@utamori
Created September 23, 2020 05:03
Show Gist options
  • Select an option

  • Save utamori/14a93df3d2bd0a5dd446445fc2ac667a to your computer and use it in GitHub Desktop.

Select an option

Save utamori/14a93df3d2bd0a5dd446445fc2ac667a to your computer and use it in GitHub Desktop.
go言語用dockerfile
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"]
@utamori
Copy link
Copy Markdown
Author

utamori commented Sep 23, 2020

マルチステージビルドで、
開発用のdebugにはAirを導入

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment