I'm trying to build project using Google Cloud Build in GCP. Here is my cloudbuild.yaml file example.
steps:
- id: Docker Run
name: gcr.io/cloud-builders/docker
args: ['run', '-p', '8080:8080', '--name', 'test', '-d', 'asia.gcr.io/project/myTomcatImage:latest']
- id: Export
name: gcr.io/cloud-builders/javac
waitFor:
- Docker Run
entrypoint: bash
args:
- -exc
- |
chmod 755 ./tool/deploy.sh
./tool/deploy.sh
env:
- _EXPORT_VALUE=${_EXPORT_VALUE}
- id: Docker Commit
name: gcr.io/cloud-builders/docker
args: ['commit', 'test', 'asia.gcr.io/project/myTomcatImage:latest']
- id: Docker Push
name: gcr.io/cloud-builders/docker
args: ['push', 'asia.gcr.io/project/myTomcatImage:latest']
"myTomcatImage" is docker image based on Tomcat8.5. After opening 8080 port, I have to access http://127.0.0.1:8080 at ./tool/deploy.sh at Export step.(In Shell script, there is a runnable jar file which is using tomcat server)
I thought it will work, but it caused errer like below.
Connect to 127.0.0.1:8080 [/127.0.0.1] failed: Connection refused (Connection refused)
I tried to give permissions to access to cloud source repositories, open firewalls, but does not work. Can anyone give me some ideas to access localhost of cloud build? or any other solutions? I will appreciate your help.