I’m very new with github actions, caprover and docker images so I might be asking very stupid questions, sorry if it is the case. I searched for a good amount of time and could not understand it by myself…
So, I’m trying to deploy to caprover a docker image built just before in my github action. Please see below my .yml
file:
name: Docker Image CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:latest
- name: Print image names
run: docker images -q my-image-name
- name: Deploy image
uses: floms/action-caprover@v1
with:
host: '${{ secrets.CAPROVER_SERVER }}'
password: '${{ secrets.CAPROVER_PASSWORD }}'
app: '${{ secrets.APP_NAME }}'
image: my-image-name:latest
The Build the Docker image
step was successful, but the Deploy image
one was not. The error message I got was:
Build started for ***
An explicit image name was provided (my-image-name:latest). Therefore, no build process is needed.
Pulling this image: my-image-name:latest This process might take a few minutes.
Build has failed!
----------------------
Deploy failed!
Error: (HTTP code 404) unexpected - pull access denied for my-image-name, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
Based on the error message, I believe I do not give the correct image name to the floms/action-caprover@v1
action. It is why I created step 2 Print image names
to try and understand better what is the real name of the image created. I tried several solutions for the field name image
, but all resulted in an error…
Thanks for the all the help you could provide!
2
Answers
Thanks Yoel Nunez for pointing I should deploy to the registry before trying to publish to caprover.
I followed the doc on github and finally managed to publish to caprover using a github action. Below is the
.yml
file that worked perfectly.To make sure your CapRover instance is able to pull the image from your github docker registry, it needs to be registered on your CapRover instance.
TLDR: I don’t see a publish step (for your docker image) in your GitHub Actions configuration. If you want to use the image name to push it to CapRover you will need to publish it to a registry, whether it is GitHub’s Container Registry, Nexus registry, or any other registry.
To do that in your CapRover instance, you need to go into
Cluster
>Docker Registry Configuration
>Add Remote Registry
. Then you will proceed to enter the configuration for your GitHub Container Registry. Typically you will need aPersonal Access Token
to allow CapRover to communicate with GitHub instead of using your password.Docker Registry Configuration
Remote Registry Configuration
Docker Registry Configuration – Remote Registry Configured