Skip to content

Commit

Permalink
add cloud build
Browse files Browse the repository at this point in the history
  • Loading branch information
YukiOnishi1129 committed May 7, 2024
1 parent 90eb1bc commit 2db1195
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 18 deletions.
19 changes: 10 additions & 9 deletions batch-service/Dockerfile.article-company-crawler
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ RUN apk update && apk add git

WORKDIR /app

COPY go.mod go.sum ./
COPY ./cmd/article-company-crawler ./cmd/article-company-crawler
COPY ./database/init_db.go ./database/init_db.go
COPY ./domain ./domain
COPY ./entity ./entity
COPY ./infrastructure/api ./infrastructure/api
COPY ./infrastructure/rss ./infrastructure/rss
COPY ./internal ./internal
COPY ./batch-service/go.mod ./
COPY ./batch-service/go.sum ./
COPY ./batch-service/cmd/article-company-crawler ./cmd/article-company-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/article-company-crawler/main.go
&& go build -o main /app/cmd/article-company-crawler/main.go


FROM alpine:3.18
Expand Down
17 changes: 9 additions & 8 deletions batch-service/Dockerfile.article-site-and-summary-crawler
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ RUN apk update && apk add git

WORKDIR /app

COPY go.mod go.sum ./
COPY ./cmd/article-site-and-summary-crawler ./cmd/article-site-and-summary-crawler
COPY ./database/init_db.go ./database/init_db.go
COPY ./domain ./domain
COPY ./entity ./entity
COPY ./infrastructure/api ./infrastructure/api
COPY ./infrastructure/rss ./infrastructure/rss
COPY ./internal ./internal
COPY ./batch-service/go.mod ./
COPY ./batch-service/go.sum ./
COPY ./batch-service/cmd/article-site-and-summary-crawler ./cmd/article-site-and-summary-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/article-site-and-summary-crawler/main.go
Expand Down
26 changes: 26 additions & 0 deletions batch-service/cloudbuild-article-company-crawler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
substitutions:
_IMAGE: 'article-company-crawler/latest'
_JOB_NAME: 'article-company-crawler'
_REGION: 'asia-northeast1'
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.article-company-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
- 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
26 changes: 26 additions & 0 deletions batch-service/cloudbuild-article-site-and-summary-crawler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
substitutions:
_IMAGE: 'article-site-and-summary-crawler/latest'
_JOB_NAME: 'article-site-and-summary-crawler'
_REGION: 'asia-northeast1'
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.article-site-and-summary-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
- 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
2 changes: 1 addition & 1 deletion batch-service/cloudbuild-trend-article-crawler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ steps:
- '$_REGION-docker.pkg.dev/$PROJECT_ID/$_IMAGE'
- '--region'
- '$_REGION'
- '--execute-now'
# - '--execute-now'
images:
- $_REGION-docker.pkg.dev/$PROJECT_ID/$_IMAGE

0 comments on commit 2db1195

Please sign in to comment.