Reputation: 1807
Using GH actions I'm building and pushing an image to my docker repository. How can this be pulled on a Google compute engine after having completed setup-gcloud
:
steps:
- name: setup gcloud
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '290.0.1'
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
I am aware of GCE-Github actions and the google/docker-registry. But as my VM is not container-optimized I want to run
docker pull [docker-hub-repo]
and perform a docker-compose up
in a specific dir afterwards.
Upvotes: 2
Views: 2509
Reputation: 1807
I didn't realise that the obvious gcloud compute ssh command is sufficient for this.
- run: gcloud compute ssh --zone $GCE_INSTANCE_ZONE $GCE_INSTANCE --command 'docker login -u [user] -p [password] && docker pull [repository:tag]'
2022 Edit
For better safety, use Github Secrets.
To avoid direct use of the SSH command via run
, there is a job appleboy/ssh-action@master
for this;
jobs:
deploy:
runs-on: [ubuntu-latest]
steps:
#Job starts here
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.WEBSPACE_HOST }}
username: ${{ secrets.WEBSPACE_USER }}
password: ${{ secrets.WEBSPACE_PASS }}
#Bash commands may be placed line by line here
script: |
cd ...
git pull
docker-compose up --build --detach
Upvotes: 4
Reputation: 118
You could install Docker Engine on several Linux Platforms and on macOS and Windows10 through Docker Desktop.
The command "docker pull" pulls image by default from Docker Hub. You could also pull the images from your desired repository by specifying the path of repository.
You need to install Docker Compose so that you could run the command "docker-compose up" which starts compose and runs your entire app.
Upvotes: 1