Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
walnuts1018 committed Oct 31, 2023
1 parent 4ce0754 commit 4c9af7f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/docker-back.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
if: github.event_name != 'release'
Expand Down
18 changes: 13 additions & 5 deletions back-prod.Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
Binary file removed back/zoneinfo/Asia/Tokyo
Binary file not shown.

0 comments on commit 4c9af7f

Please sign in to comment.