c-scale-community / workflow-coastal-hydrowaq

Porting and deploying the HiSea use case on C-SCALE
Apache License 2.0
3 stars 1 forks source link

Testing ghcr.io #46

Open sebastian-luna-valero opened 1 year ago

sebastian-luna-valero commented 1 year ago

See: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry

First a Personal Access Token (classic) to deal with packages: https://github.com/settings/tokens. Use https://github.com/settings/tokens/new?scopes=write:packages

Then:

# build docker image
cd scripts/download
sudo docker build --tag download-input .

# properly tag image
sudo docker tag download-input ghcr.io/c-scale-community/hisea_download_era5:1.0.0

# log into ghcr.io: https://github.com/orgs/community/discussions/50035
export CR_PAT=YOUR_TOKEN
echo $CR_PAT | sudo docker login ghcr.io -u USERNAME --password-stdin

# push container image
sudo docker push ghcr.io/c-scale-community/hisea_download_era5:1.0.0

All going well, the image will be available at https://github.com/orgs/c-scale-community/packages

Use it from Snakemake:

git diff workflow/Snakefile
diff --git a/workflow/Snakefile b/workflow/Snakefile
index ede1b86..cff6da9 100644
--- a/workflow/Snakefile
+++ b/workflow/Snakefile
@@ -17,9 +17,9 @@ rule download_era5:
     shell:
         """
         sudo docker run \
            -v {params.cdsapirc}:/root/.cdsapirc \
             -v /home/centos/data/download/2023-01-23:/data \
-            download-input python download_era5.py \
+            ghcr.io/c-scale-community/hisea_download_era5:1.0.0 python download_era5.py \
                 --longitude_min {params.lon_min} \
                 --longitude_max {params.lon_max} \
                 --latitude_min {params.lat_min} \

@backeb what do you think?

xref: https://github.com/orgs/community/discussions/50035

sebastian-luna-valero commented 1 year ago

Update: it requires that one of the org admins explicitly configure public and internal packages (default is only private): https://github.com/organizations/c-scale-community/settings/packages

backeb commented 1 year ago

This looks very interesting. Then it almost becomes ‘as a service’

backeb commented 1 year ago

Update: it requires that one of the org admins explicitly configure public and internal packages (default is only private): https://github.com/organizations/c-scale-community/settings/packages

Seems like you've already set this up?

image
sebastian-luna-valero commented 1 year ago

That's correct.