From e52061d4fab332d3b07234a1a3914f82ba5a385c Mon Sep 17 00:00:00 2001 From: "Fco. Javier Delgado del Hoyo" Date: Sun, 17 Sep 2023 11:01:33 +0200 Subject: [PATCH] Test docker image before pushing to docker hub (#111) * update dockerize docker instructions * use go with alpine * login to docker hub using action too * test docker image before building * extract command from the entrypoint * change volume path * user docker compose run and cmd instead entrypoint --- .github/workflows/image.yml | 10 ++++++++++ Dockerfile | 2 +- restore.sh | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index e639e5f..1fe4d25 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -16,6 +16,16 @@ jobs: uses: actions/checkout@v4 - name: Test Bash scripts run: sudo apt-get -qq update && sudo apt-get install -y devscripts shellcheck && make test + - name: Test image + env: + VOLUME_PATH: /tmp/mariadb + DATABASE_NAME: foo + MARIADB_ROOT_PASSWORD: abcd + run: | + docker-compose up -d mariadb + docker-compose run backup /backup.sh + docker-compose run backup /restore.sh /backup/latest.foo.sql.gz + docker-compose stop build: runs-on: ubuntu-22.04 needs: test diff --git a/Dockerfile b/Dockerfile index 95ad9bc..851a5c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,4 +44,4 @@ VOLUME ["/backup"] HEALTHCHECK --interval=2s --retries=1800 \ CMD stat /HEALTHY.status || exit 1 -ENTRYPOINT dockerize -wait tcp://${MYSQL_HOST}:${MYSQL_PORT} -timeout ${TIMEOUT} /run.sh \ No newline at end of file +CMD dockerize -wait tcp://${MYSQL_HOST}:${MYSQL_PORT} -timeout ${TIMEOUT} /run.sh diff --git a/restore.sh b/restore.sh index 0607d6f..6c03634 100755 --- a/restore.sh +++ b/restore.sh @@ -13,6 +13,7 @@ if [ "$#" -ne 1 ] then echo "You must pass the path of the backup file to restore" + exit 1 fi set -o pipefail