Skip to content

Commit

Permalink
add: Google Cloud のデプロイに必要なファイルを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
YKhm20020 committed Nov 14, 2024
1 parent 6e49237 commit 60f7d7f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Deploy to Google Cloud Run

on:
push:
branches:
- main

# 下記は適宜書き換えてください
env:
GCP_PROJECT_ID: tacktail
GCP_REGION: asia-northeast1
IMAGE_NAME: gcr.io/tacktail/tacktail-backend

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1

- name: Authenticate with Google Cloud
uses: google-github-actions/[email protected]
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}

- name: Configure Docker
run: gcloud auth configure-docker

- name: Build and push Docker image
run: |
TAG=$(echo $GITHUB_SHA | head -c7)
docker build -t ${IMAGE_NAME}:${TAG} .
docker push ${IMAGE_NAME}:${TAG}
- name: Deploy to Cloud Run
run: |
TAG=$(echo $GITHUB_SHA | head -c7)
gcloud run deploy web-push-demo \
--image ${IMAGE_NAME}:${TAG} \
--platform managed \
--region ${GCP_REGION} \
--allow-unauthenticated
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM golang:1.23.1-alpine3.20

COPY ./app /go/app/

WORKDIR /go/app/

RUN go mod download && go mod tidy
RUN go build -o main .

EXPOSE 8080

CMD ["/app/main"]

0 comments on commit 60f7d7f

Please sign in to comment.