How to build (custom) apps using the docker-registry
-
@msbt Nice guide!
There is something that I miss tho.
I like to run my cloudron apps local first so I can see if everything is working as intended.
This only works to a certain level for example this can't work if a database addon is used.
But everything before that step can be tested locally.A full local test suite would be awesome, so I the developer don't have to push every test and deploy it.
For example this is how I do some local testing before I push my image.
Needed software is
jq
for json parsing,docker
,bash
,sed
Script explained with words:
- Get the ID and version Tag from the
CloudronManifest.json
and use them for docker build. - Create local folders for
/tmp
/app/data
and/run
so I can emulate cloudrons readonly behavior. - Cleanup local folders so every test is fresh and clean
- Build the docker image with Data from
CloudronManifest.json
- Run the freshly build Image in readonly mode with local test folders and an interactive bash session so I can debug / test some stuff.
#!/bin/bash set -x ID=$(jq -r ".id" CloudronManifest.json) VERSION=$(jq -r ".version" CloudronManifest.json') echo "=> Create Test Data dir" mkdir -p ./cloudron_test/data ./cloudron_test/tmp ./cloudron_test/run echo "=> Cleanup Test Data" rm -rf ./cloudron_test/data/* ./cloudron_test/tmp/* ./cloudron_test/run/* echo "=> Build test image" docker build -t dr.cloudron.dev/$ID:$VERSION . echo "=> Run $VERSION tag of build image of $ID" docker run -ti --read-only \ --volume $(pwd)/cloudron_test/data:/app/data:rw \ --volume $(pwd)/cloudron_test/tmp:/tmp:rw \ --volume $(pwd)/cloudron_test/run:/run:rw \ dr.cloudron.dev/$ID:$VERSION \ bash
- Get the ID and version Tag from the
-
@brutalbirdie btw, you can get raw strings from jq directly without having to strip quotes with the
-r
option:ID=$(jq -r ".id" CloudronManifest.json) VERSION=$(jq -r ".version" CloudronManifest.json)
This does one better than just stripping quotes since it will also decode other escaped characters (not that that applies in this case).
-
@infogulch RTFM myself nice catch, thanks for that.
-