Created
November 17, 2021 07:16
-
-
Save keitakn/c43b85c939e7f1f295a48b9892f02c11 to your computer and use it in GitHub Desktop.
GoでDocker
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.17-alpine3.14 as build | |
| LABEL maintainer="https://github.com/keitakn" | |
| WORKDIR /go/app | |
| COPY . . | |
| ARG GOLANGCI_LINT_VERSION=v1.42.1 | |
| ARG AIR_VERSION=v1.27.3 | |
| ARG DLV_VERSION=v1.7.1 | |
| ARG OAPI_CODEGEN_VERSION=v1.8.2 | |
| ARG MIGRATE_VERSION=v4.15.0 | |
| RUN set -eux && \ | |
| apk update && \ | |
| apk add --no-cache git curl make && \ | |
| go install github.com/cosmtrek/air@${AIR_VERSION} && \ | |
| go install github.com/go-delve/delve/cmd/dlv@${DLV_VERSION} && \ | |
| go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@${OAPI_CODEGEN_VERSION} && \ | |
| go install -tags 'mysql' github.com/golang-migrate/migrate/v4/cmd/migrate@${MIGRATE_VERSION} && \ | |
| curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} && \ | |
| go install golang.org/x/tools/cmd/goimports@latest | |
| RUN set -eux && \ | |
| go build -o myapp ./cmd/rest/main.go | |
| ENV CGO_ENABLED 0 | |
| FROM alpine:3.14 | |
| WORKDIR /app | |
| COPY --from=build /go/app/myapp . | |
| RUN set -x && \ | |
| addgroup go && \ | |
| adduser -D -G go go && \ | |
| chown -R go:go /app/myapp | |
| CMD ["./myapp"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment