-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #477 from traPtitech/refactor/docker
refactor/docker
- Loading branch information
Showing
6 changed files
with
67 additions
and
126 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
.git | ||
.gitignore | ||
.gitmodules | ||
_development/ | ||
.git/ | ||
.github/ | ||
docs/ | ||
.dockerignore | ||
.DS_Store | ||
_development | ||
docs | ||
tmp | ||
.env.example | ||
.gitignore | ||
.golangci.yml | ||
compose.yml | ||
Dockerfile | ||
README.md | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,51 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
# for production | ||
# | ||
# build stage | ||
# | ||
FROM golang:1-alpine as builder | ||
|
||
FROM golang:1-alpine as server-build | ||
|
||
WORKDIR /github.com/traPtitech/knoq | ||
WORKDIR /app | ||
|
||
COPY go.mod go.sum ./ | ||
ENV GO111MODULE=on | ||
RUN go mod download | ||
COPY ./ ./ | ||
ENV GOOS=linux | ||
ENV GOARCH=amd64 | ||
ENV GOCACHE=/root/.cache/go-build | ||
ENV GOMODCACHE=/go/pkg/mod | ||
|
||
RUN go build -o knoq | ||
COPY go.mod go.sum ./ | ||
RUN --mount=type=cache,target=${GOCACHE} \ | ||
--mount=type=cache,target=${GOMODCACHE} \ | ||
go mod download | ||
|
||
FROM alpine:latest | ||
COPY ./ ./ | ||
RUN --mount=type=cache,target=${GOCACHE} \ | ||
--mount=type=cache,target=${GOMODCACHE} \ | ||
go build -o /app/knoq | ||
|
||
# static files | ||
RUN mkdir -p /app/web \ | ||
&& apk add --no-cache curl \ | ||
&& curl -L -Ss https://github.com/traPtitech/knoQ-UI/releases/latest/download/dist.tar.gz \ | ||
| tar zxv -C /app/web | ||
# Google Calendar API needs service.json | ||
RUN touch /app/service.json | ||
|
||
# | ||
# runtime stage | ||
# | ||
FROM gcr.io/distroless/static-debian11:latest | ||
|
||
WORKDIR /app | ||
|
||
RUN apk --update add tzdata \ | ||
&& cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime \ | ||
&& apk add --update ca-certificates \ | ||
&& update-ca-certificates \ | ||
&& rm -rf /var/cache/apk/* | ||
|
||
COPY --from=server-build /github.com/traPtitech/knoq/knoq ./ | ||
# COPY --from=builder /app/knoq /app/web/ /app/service.json /app/ | ||
COPY --from=builder /app/knoq /app/ | ||
COPY --from=builder /app/web/ /app/web/ | ||
COPY --from=builder /app/service.json /app/ | ||
|
||
ARG knoq_version=dev | ||
ARG knoq_revision=local | ||
ENV KNOQ_VERSION=${knoq_version} | ||
ENV KNOQ_REVISION=${knoq_revision} | ||
|
||
ENTRYPOINT ./knoq | ||
CMD ["/app/knoq"] |
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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