Skip to content

Commit

Permalink
Merge pull request #102 from YukiOnishi1129/feature/fix-cloud-build
Browse files Browse the repository at this point in the history
Feature/fix cloud build
  • Loading branch information
YukiOnishi1129 authored Jun 10, 2024
2 parents d604819 + 1b36e1c commit 46c5691
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 68 deletions.
24 changes: 24 additions & 0 deletions batch-service/cmd/trend-article-crawler/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM golang:1.22-alpine3.18 AS go-builder

RUN apk update && apk add git

WORKDIR /app

COPY ./batch-service/go.mod ./
COPY ./batch-service/go.sum ./
COPY ./batch-service/cmd/trend-article-crawler ./cmd/trend-article-crawler
COPY ./batch-service/database/init_db.go ./database/init_db.go
COPY ./batch-service/domain ./domain
COPY ./batch-service/entity ./entity
COPY ./batch-service/infrastructure/api ./infrastructure/api
COPY ./batch-service/infrastructure/rss ./infrastructure/rss
COPY ./batch-service/internal ./internal

RUN go mod download \
&& go build -o main /app/cmd/trend-article-crawler/main.go

FROM alpine:3.18
WORKDIR /app
COPY --from=go-builder /app/main .

CMD ["/app/main"]
26 changes: 26 additions & 0 deletions batch-service/cmd/trend-article-crawler/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# staging environment
substitutions:
_IMAGE: 'trend-article-crawler/latest'
_JOB_NAME: 'trend-article-crawler'
steps:
# Build the container image
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', '$_REGION-docker.pkg.dev/$PROJECT_ID/$_IMAGE','-f', 'batch-service/Dockerfile.trend-article-crawler', '.']
# Push the container image to Container Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', '$_REGION-docker.pkg.dev/$PROJECT_ID/$_IMAGE']
# Deploy container image to Cloud Run Jobs
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
- 'run'
- 'jobs'
- 'deploy'
- '$_JOB_NAME'
- '--image'
- '$_REGION-docker.pkg.dev/$PROJECT_ID/$_IMAGE'
- '--region'
- '$_REGION'
# - '--execute-now'
images:
- $_REGION-docker.pkg.dev/$PROJECT_ID/$_IMAGE
34 changes: 0 additions & 34 deletions web/client/cloudbuild-production.yaml

This file was deleted.

34 changes: 0 additions & 34 deletions web/client/cloudbuild-staging.yaml

This file was deleted.

0 comments on commit 46c5691

Please sign in to comment.