3

I'm trying build deploy a app in GCP Cloud run using GCP Cloud Build.

I already build, push and deploy the service using Dockerfile, but i need use the Dockerfile of the project. My dockerfile run in Docker desktop perfectly, but i am not finding documentation for docker-compose using GCP Artifact registry.

My dockerfile:

FROM python:3.10.5-slim-bullseye

#docker build -t cloud_app .
#docker image ls
#docker run -p 81:81 cloud_app

RUN mkdir wd
WORKDIR /wd

RUN apt-get update
RUN apt-get install ffmpeg libsm6 libxext6  -y

COPY requirements.txt .
RUN pip install -r requirements.txt

COPY ./ ./

CMD python3 main.py

My docker-compose:

version: "3.3"

services:
  web:
    build:
      context: ./destripa_frame/
      dockerfile: ./Docker_files/Dockerfile
    image: bank_anon_web_dev_build
    restart: always
    expose:
      - 8881
      - 80
      - 2222
      - 22
    ports:
      - "2222:2222"
      - "80:80"
    environment:
      - TZ=America/Chicago

My cloud-build configuration:

steps:
- name: 'docker/compose:1.28.2'
  args: ['up', '--build', '-f', './cloud_run/docker-compose.devapp.yml', '-d']
- name: 'docker/compose:1.28.2'
  args: ['-f', './cloud_run/docker-compose.devapp.yml', 'up', 'docker-build']
images: ['us-central1-docker.pkg.dev/${PROJECT_ID}/app-destripador/job_app:$COMMIT_SHA']

The cloud build commit execution succeed: Cloud build execution

¿How can modify the cloud build for deploy the Docker-compose in Artifact registry?

EDIT: Find the correct method to push the image in artifact registry using cloudbuild and Docker-compose.

Modify my cloud-build.yml configuration for build the image and then rename the Docker-compose image to the Artifact registry image. Cloud build automatically push the image in the repository (if the image name it's not a URL then push it in Docker.io).

My new Cloud-build.yml:

steps:
- name: 'docker/compose:1.28.2'
  args: [
    '-p', 'us-central1-docker.pkg.dev/${PROJECT_ID}/app-destripador',
    '-f', './cloud_run/docker-compose.devapp.yml',
    'up', '--build', 'web'
  ]
- name: 'gcr.io/cloud-builders/docker'
  args: [
    'tag',
    'bank_anon_web_dev_build',
    'us-central1-docker.pkg.dev/${PROJECT_ID}/app-destripador/bank_anon_web_dev_build'
  ]
images: ['us-central1-docker.pkg.dev/${PROJECT_ID}/app-destripador/bank_anon_web_dev_build']

Hope anyone need undestand GCP Cloud build using docker-compose can help it, because every guide in the web not explicate this last part.

Johan Valero
  • 51
  • 1
  • 5
  • 2
    Artifact Registry is a place to store container images, not to run them. Anyway, Cloud Run also cannot run Docker compose. You need to deploy every image in different Cloud Run services. Please check https://stackoverflow.com/questions/67185073/how-to-run-docker-compose-on-google-cloud-run – Puteri Jul 27 '22 at 05:13
  • I find the method is only build the image with --no-start and then the image in the docker-file need to be same to the artifact registry, then automatic cloud build push the image to the artifact registry. – Johan Valero Jul 27 '22 at 05:25

0 Answers0