-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: DockerfileLocalを追加し、ビルドと実行の環境を設定しました。
- Loading branch information
1 parent
83d8176
commit b9d7151
Showing
1 changed file
with
30 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# First stage: build environment | ||
FROM golang:1.21.5 AS builder | ||
|
||
WORKDIR /srv/grpc | ||
COPY . . | ||
# .env ファイルをイメージ内にコピー | ||
COPY .env / | ||
RUN go mod download | ||
|
||
ARG VERS="3.11.4" | ||
ARG ARCH="linux-x86_64" | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux \ | ||
go build -a -installsuffix cgo \ | ||
-o /go/bin/server \ | ||
github.com/GreenTeaProgrammers/WhereChildBus/backend/cmd/server | ||
|
||
# Final stage: runtime environment | ||
# CA証明書が必要なので、alpineをベースにする | ||
FROM alpine:latest | ||
|
||
# 必要なパッケージをインストール | ||
RUN apk --no-cache add ca-certificates | ||
|
||
# ビルドステージからバイナリと.envファイルをコピー | ||
COPY --from=builder /go/bin/server /server | ||
COPY --from=builder /srv/grpc/.env / | ||
|
||
# アプリケーションの起動 | ||
ENTRYPOINT ["/server"] |