Convert MakeFile docker run to Cloud Build

Viewed 55

I have a repo that contains a Dockerfile and a MakeFile, usually what I do is run make && make mkdocs-serve in the local repo folder and the MakeFile takes care of 1) Building the image, 2) Building MKDocs (static site builder) and 3) Run MKDocs server at 127.0.0.1:8789

Here is what the MakeFile looks like:

#vars
IMAGENAME=my_mkdocs
USER=$(id -u)

.DEFAULT_GOAL := all

docker-clean:
    -@docker rm ${IMAGENAME}

docker-build:
    @docker build -t ${IMAGENAME}:v1 --build-arg=USER=${USER} .

mkdocs-build:
    @docker run -it -v $(CURDIR):/home/mkdocs ${IMAGENAME}:v1 new /build

# @docker run -it --name ${IMAGENAME} -p 8789:80 ${IMAGENAME}:v1
mkdocs-serve:
    @docker run --rm -it -v $(CURDIR):/home/mkdocs -p 8789:8000 ${IMAGENAME}:v1 mkdocs serve --dev-addr 0.0.0.0:8000

all: docker-clean docker-build

Now I want to build and run the Docker image using Cloud Build and Cloud Run, and I'm having difficulty converting MakeFile to Cloud Build syntax:

  1. mkdoc-build:

I think the original bash syntax is:

docker run -it -v /home/mkdocs my_mkdocs:v1 new /build

Here is the Cloud Build syntax I think might work:

# Build MKDocs
  - name: 'bash'
    args: ['docker', 'run', '-it', '-v', '/home/mkdocs', 'my_mkdocs:v1', 'new', '/build']
  1. mkdocs-serve:

I think the original bash syntax is:

docker run --rm -it -v /home/mkdocs -p 8789:8000 my_mkdocs:v1 mkdocs serve --dev-addr 0.0.0.0:8000

Here is the Cloud Build syntax I think might work:

# Build MKDocs
  - name: 'bash'
    args: ['docker', 'run', '--rm', '-it', '-v', '/home/mkdocs', '-p', '8789:8000', 'my_mkdocs:v1', 'mkdocs', 'serve', '--dev-addr', '0.0.0.0:8000']

Does this make sense to you? I'm sure this works on my local machine, but I feel they are wrong as there is no deployment to Cloud Run. There is indeed some documentation of how to call Cloud Run from Cloud Build:

- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
  entrypoint: gcloud
  args: ['run', 'deploy', 'SERVICE-NAME', '--image', 'gcr.io/PROJECT_ID/IMAGE', '--region', 'REGION']
images:
- gcr.io/PROJECT_ID/IMAGE

But this seems to be a bit far from what the bash commands are.

0 Answers
Related