From 60700a56e9ee3a40c7c5cf64317b682f3434264c Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 22 Nov 2023 23:36:36 +0000 Subject: [PATCH] Fix (docker): Use `127.0.0.1` instead of `localhost` to test snappymail in `entrypoint.sh` (#1325) * Fix (docker): Use `127.0.0.1` instead of `localhost` to test snappymail in `entrypoint.sh` * Run build on PR but don't push * Login only on tags * Fix test --- .docker/release/files/entrypoint.sh | 8 ++++---- .docker/release/test/config.yaml | 6 +++--- .github/workflows/docker.yml | 11 +++++++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.docker/release/files/entrypoint.sh b/.docker/release/files/entrypoint.sh index 3db1d0156..75e82d729 100755 --- a/.docker/release/files/entrypoint.sh +++ b/.docker/release/files/entrypoint.sh @@ -62,17 +62,17 @@ sed 's/^auth_logging_format = .*/auth_logging_format = "[{date:Y-m-d H:i:s}] Aut sed 's/^auth_syslog = .*/auth_syslog = Off/' -i $SNAPPYMAIL_CONFIG_FILE ( - while ! nc -vz -w 1 localhost 8888 > /dev/null 2>&1; do echo "[INFO] Checking whether nginx is alive"; sleep 1; done - while ! nc -vz -w 1 localhost 9000 > /dev/null 2>&1; do echo "[INFO] Checking whether php-fpm is alive"; sleep 1; done + while ! nc -vz -w 1 127.0.0.1 8888 > /dev/null 2>&1; do echo "[INFO] Checking whether nginx is alive"; sleep 1; done + while ! nc -vz -w 1 127.0.0.1 9000 > /dev/null 2>&1; do echo "[INFO] Checking whether php-fpm is alive"; sleep 1; done # Create snappymail admin password if absent SNAPPYMAIL_ADMIN_PASSWORD_FILE=/var/lib/snappymail/_data_/_default_/admin_password.txt if [ ! -f "$SNAPPYMAIL_ADMIN_PASSWORD_FILE" ]; then echo "[INFO] Creating Snappymail admin password file: $SNAPPYMAIL_ADMIN_PASSWORD_FILE" - wget -T 1 -qO- 'http://localhost:8888/?/AdminAppData/0/12345/' > /dev/null + wget -T 1 -qO- 'http://127.0.0.1:8888/?/AdminAppData/0/12345/' > /dev/null echo "[INFO] Snappymail Admin Panel ready at http://localhost:8888/?admin. Login using password in $SNAPPYMAIL_ADMIN_PASSWORD_FILE" fi - wget -T 1 -qO- 'http://localhost:8888/' > /dev/null + wget -T 1 -qO- 'http://127.0.0.1:8888/' > /dev/null echo "[INFO] Snappymail ready at http://localhost:8888/" ) & diff --git a/.docker/release/test/config.yaml b/.docker/release/test/config.yaml index b265dea6d..47cf00ea9 100644 --- a/.docker/release/test/config.yaml +++ b/.docker/release/test/config.yaml @@ -16,9 +16,9 @@ commandTests: pidof php-fpm ls -al /var/lib/snappymail/_data_/_default_/configs/application.ini ls -al /var/lib/snappymail/_data_/_default_/admin_password.txt - nc -vz localhost 8888 - nc -vz localhost 9000 - wget -S -T 3 -O /dev/null http://localhost:8888 + nc -vz 127.0.0.1 8888 + nc -vz 127.0.0.1 9000 + wget -S -T 3 -O /dev/null http://127.0.0.1:8888 kill `pidof supervisord` metadataTest: exposedPorts: ["8888", "9000"] diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 840b1265b..69be3c05d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,7 +3,10 @@ name: docker on: push: tags: - - 'v2.*' + - '**' + pull_request: + branches: + - master # This is needed to push to GitHub Container Registry. See https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry permissions: @@ -28,9 +31,11 @@ jobs: images: | djmaze/snappymail ghcr.io/${{ github.repository }} + # type=ref,event=pr generates tag(s) on PRs only. E.g. 'pr-123', 'pr-123-abc0123' # type=ref,event=branch generates tag(s) on branch only. E.g. 'master', 'master-abc0123' # type=ref,event=tag generates tag(s) on tags only. E.g. 'v0.0.0', 'v0.0.0-abc0123', and 'latest' tags: | + type=ref,event=pr type=ref,suffix=-{{sha}},event=pr type=ref,event=branch type=ref,event=tag @@ -56,12 +61,14 @@ jobs: ${{ runner.os }}-buildx- - name: Login to Docker Hub registry + if: startsWith(github.ref, 'refs/tags/') # Login only on tags uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry + if: startsWith(github.ref, 'refs/tags/') # Login only on tags uses: docker/login-action@v2 with: registry: ghcr.io @@ -101,7 +108,7 @@ jobs: # TODO: Add more arches? # platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x platforms: linux/386,linux/amd64 - push: true + push: startsWith(github.ref, 'refs/tags/') # Push only on tags tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=local,src=/tmp/.buildx-cache