diff --git a/.github/workflows/docker-back.yaml b/.github/workflows/docker-back.yaml index 60139f5..d18b04e 100644 --- a/.github/workflows/docker-back.yaml +++ b/.github/workflows/docker-back.yaml @@ -45,24 +45,6 @@ jobs: restore-keys: | ${{ runner.os }}-buildx - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version-file: ./back/go.mod - cache: true - cache-dependency-path: ./back/go.sum - - - name: go mod download - run: go mod download - working-directory: ./back - - - name: go build - working-directory: ./back - env: - CGO_ENABLED: 0 - GOOS: linux - run: go build -o server main.go - - name: Build and push Docker images uses: docker/build-push-action@v4.0.0 if: github.event_name != 'release' diff --git a/back-prod.Dockerfile b/back-prod.Dockerfile index 5309257..2d424cb 100644 --- a/back-prod.Dockerfile +++ b/back-prod.Dockerfile @@ -1,11 +1,19 @@ -# run before CGO_ENABLED=0 GOOS=linux go build -o server $ROOT/main.go && chmod +x ./server +FROM golang:1.21 as builder +ENV ROOT=/build +RUN mkdir ${ROOT} +WORKDIR ${ROOT} + +COPY ./back ./ +RUN go get + +RUN CGO_ENABLED=0 GOOS=linux go build -o server main.go && chmod +x ./server FROM alpine:3 WORKDIR /app -COPY back/server ./ -RUN chmod +x ./server -COPY back/zoneinfo/Asia/Tokyo /usr/share/zoneinfo/Asia/Tokyo - +COPY --from=builder /build/server ./ +COPY --from=builder /build/templates/ /app/templates/ +COPY --from=builder /build/assets/ /app/assets/ +COPY --from=builder /usr/share/zoneinfo/Asia/Tokyo /usr/share/zoneinfo/Asia/Tokyo CMD ["./server"] LABEL org.opencontainers.image.source = "https://github.com/walnuts1018/openchokin" \ No newline at end of file diff --git a/back/zoneinfo/Asia/Tokyo b/back/zoneinfo/Asia/Tokyo deleted file mode 100644 index 26f4d34..0000000 Binary files a/back/zoneinfo/Asia/Tokyo and /dev/null differ