Skip to content

Commit

Permalink
ci: DockerfileLocalを追加し、ビルドと実行の環境を設定しました。
Browse files Browse the repository at this point in the history
  • Loading branch information
KinjiKawaguchi committed Feb 12, 2024
1 parent 83d8176 commit b9d7151
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions backend/DockerfileLocal
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"]

0 comments on commit b9d7151

Please sign in to comment.