From a9d0a065d78e51ca5d27fa657db36c0bdf36e50d Mon Sep 17 00:00:00 2001 From: YukiOnishi <58220747+YukiOnishi1129@users.noreply.github.com> Date: Mon, 10 Jun 2024 17:06:09 +0900 Subject: [PATCH 1/2] fix cloud build --- web/client/cloudbuild-production.yaml | 34 --------------------------- web/client/cloudbuild-staging.yaml | 34 --------------------------- 2 files changed, 68 deletions(-) delete mode 100644 web/client/cloudbuild-production.yaml delete mode 100644 web/client/cloudbuild-staging.yaml diff --git a/web/client/cloudbuild-production.yaml b/web/client/cloudbuild-production.yaml deleted file mode 100644 index 62db6a14..00000000 --- a/web/client/cloudbuild-production.yaml +++ /dev/null @@ -1,34 +0,0 @@ -substitutions: - _IMAGE: "web-client-application/latest" - _SERVICE_NAME: "web-client-application" - _REGION: "us-west1" -steps: - # Build the container image - - name: "gcr.io/cloud-builders/docker" - args: - [ - "build", - "-t", - "$_REGION-docker.pkg.dev/$PROJECT_ID/$_IMAGE", - "-f", - "web/client/Dockerfile", - ".", - ] - # Push the container image to Artifact 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", - "deploy", - "$_SERVICE_NAME", - "--image", - "$_REGION-docker.pkg.dev/$PROJECT_ID/$_IMAGE", - "--region", - "$_REGION", - ] -images: - - $_REGION-docker.pkg.dev/$PROJECT_ID/$_IMAGE diff --git a/web/client/cloudbuild-staging.yaml b/web/client/cloudbuild-staging.yaml deleted file mode 100644 index d3a618e3..00000000 --- a/web/client/cloudbuild-staging.yaml +++ /dev/null @@ -1,34 +0,0 @@ -substitutions: - _IMAGE: "web-client-application/latest" - _SERVICE_NAME: "web-client-application" - _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", - "web/client/Dockerfile", - ".", - ] - # Push the container image to Artifact 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", - "deploy", - "$_SERVICE_NAME", - "--image", - "$_REGION-docker.pkg.dev/$PROJECT_ID/$_IMAGE", - "--region", - "$_REGION", - ] -images: - - $_REGION-docker.pkg.dev/$PROJECT_ID/$_IMAGE From 1b36e1cabe9577aaeb357b9c24744e87ba1635bc Mon Sep 17 00:00:00 2001 From: YukiOnishi <58220747+YukiOnishi1129@users.noreply.github.com> Date: Mon, 10 Jun 2024 17:08:04 +0900 Subject: [PATCH 2/2] fix batch trend --- .../cmd/trend-article-crawler/Dockerfile | 24 +++++++++++++++++ .../cmd/trend-article-crawler/cloudbuild.yaml | 26 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 batch-service/cmd/trend-article-crawler/Dockerfile create mode 100644 batch-service/cmd/trend-article-crawler/cloudbuild.yaml diff --git a/batch-service/cmd/trend-article-crawler/Dockerfile b/batch-service/cmd/trend-article-crawler/Dockerfile new file mode 100644 index 00000000..ccf54e62 --- /dev/null +++ b/batch-service/cmd/trend-article-crawler/Dockerfile @@ -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"] \ No newline at end of file diff --git a/batch-service/cmd/trend-article-crawler/cloudbuild.yaml b/batch-service/cmd/trend-article-crawler/cloudbuild.yaml new file mode 100644 index 00000000..63d1e92f --- /dev/null +++ b/batch-service/cmd/trend-article-crawler/cloudbuild.yaml @@ -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 \ No newline at end of file