From b2c89f2e0d3f3ec75f76784b62b90e0ddc1e9fc2 Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Thu, 11 Jul 2024 19:10:17 +0200 Subject: [PATCH] LDEV-4979 GHA use alternate workflows for docker services https://luceeserver.atlassian.net/browse/LDEV-4979 --- .../build-services-no-credentials.yml | 51 ++++++++++++ .github/workflows/build-services.yml | 67 ++++++++++++++++ .github/workflows/main.yml | 78 ++++--------------- 3 files changed, 134 insertions(+), 62 deletions(-) create mode 100644 .github/workflows/build-services-no-credentials.yml create mode 100644 .github/workflows/build-services.yml diff --git a/.github/workflows/build-services-no-credentials.yml b/.github/workflows/build-services-no-credentials.yml new file mode 100644 index 0000000000..c965ab8c16 --- /dev/null +++ b/.github/workflows/build-services-no-credentials.yml @@ -0,0 +1,51 @@ +name: Load Services via Docker + +on: + workflow_call: + +jobs: + start-services: + runs-on: ubuntu-latest + services: + ldap: + # image: kwart/ldap-server + image: rroemhild/test-openldap + ports: + - 10389:10389 + - 10636:10636 + sql-server: + # Docker Hub image + image: mcr.microsoft.com/mssql/server:2019-latest + env: + MSSQL_PID: Express + ACCEPT_EULA: Y + SA_PASSWORD: Lucee!1433 # password must be complex or the service won't start + ports: + - 1433:1433 + options: --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P ${SA_PASSWORD} -Q 'SELECT 1' || exit 1" --health-interval 10s --health-timeout 5s --health-retries 5 + redis: + # Docker Hub image + image: redis + # Set health checks to wait until redis has started + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps port 6379 on service container to the host + - 6379:6379 + greenmail: + image: greenmail/standalone:1.6.9 + ports: + - 3025:3025 #SMTP + - 3110:3110 #POP3 + - 3143:3143 #IMAP + - 3465:3465 #SMTPS + - 3993:3993 #IMAPS + - 3995:3995 #POP3S + - 8080:8080 #API + mongo: + image: mongo-express + memcached: + image: bitnami/memcached:latest diff --git a/.github/workflows/build-services.yml b/.github/workflows/build-services.yml new file mode 100644 index 0000000000..0a5a90387c --- /dev/null +++ b/.github/workflows/build-services.yml @@ -0,0 +1,67 @@ +name: Load Docker Images + +on: + workflow_call: + workflow_dispatch: + +jobs: + start-services: + runs-on: ubuntu-latest + services: + ldap: + # image: kwart/ldap-server + image: rroemhild/test-openldap + ports: + - 10389:10389 + - 10636:10636 + credentials: + username: ${{ secrets.DOCKERHUB_PUBLIC_USERNAME }} + password: ${{ secrets.DOCKERHUB_PUBLIC_TOKEN }} + sql-server: + # Docker Hub image + image: mcr.microsoft.com/mssql/server:2019-latest + env: + MSSQL_PID: Express + ACCEPT_EULA: Y + SA_PASSWORD: Lucee!1433 # password must be complex or the service won't start + ports: + - 1433:1433 + options: --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P ${SA_PASSWORD} -Q 'SELECT 1' || exit 1" --health-interval 10s --health-timeout 5s --health-retries 5 + redis: + # Docker Hub image + image: redis + # Set health checks to wait until redis has started + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps port 6379 on service container to the host + - 6379:6379 + credentials: + username: ${{ secrets.DOCKERHUB_PUBLIC_USERNAME }} + password: ${{ secrets.DOCKERHUB_PUBLIC_TOKEN }} + greenmail: + image: greenmail/standalone:1.6.9 + ports: + - 3025:3025 #SMTP + - 3110:3110 #POP3 + - 3143:3143 #IMAP + - 3465:3465 #SMTPS + - 3993:3993 #IMAPS + - 3995:3995 #POP3S + - 8080:8080 #API + credentials: + username: ${{ secrets.DOCKERHUB_PUBLIC_USERNAME }} + password: ${{ secrets.DOCKERHUB_PUBLIC_TOKEN }} + mongo: + image: mongo-express + credentials: + username: ${{ secrets.DOCKERHUB_PUBLIC_USERNAME }} + password: ${{ secrets.DOCKERHUB_PUBLIC_TOKEN }} + memcached: + image: bitnami/memcached:latest + credentials: + username: ${{ secrets.DOCKERHUB_PUBLIC_USERNAME }} + password: ${{ secrets.DOCKERHUB_PUBLIC_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a50a2922f0..0abf5a2c9f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,63 +28,24 @@ jobs: DO_DEPLOY: "${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/6.1') }}" LUCEE_BUILD_JAVA_VERSION: 21 LUCEE_TEST_JAVA_VERSION: '' - services: - ldap: - # image: kwart/ldap-server - image: rroemhild/test-openldap - ports: - - 10389:10389 - - 10636:10636 - credentials: - username: ${{ secrets.DOCKERHUB_PUBLIC_USERNAME }} - password: ${{ secrets.DOCKERHUB_PUBLIC_TOKEN }} - sql-server: - # Docker Hub image - image: mcr.microsoft.com/mssql/server:2019-latest - env: - MSSQL_PID: Express - ACCEPT_EULA: Y - SA_PASSWORD: Lucee!1433 # password must be complex or the service won't start - ports: - - 1433:1433 - options: --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P ${SA_PASSWORD} -Q 'SELECT 1' || exit 1" --health-interval 10s --health-timeout 5s --health-retries 5 - redis: - # Docker Hub image - image: redis - # Set health checks to wait until redis has started - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - # Maps port 6379 on service container to the host - - 6379:6379 - credentials: - username: ${{ secrets.DOCKERHUB_PUBLIC_USERNAME }} - password: ${{ secrets.DOCKERHUB_PUBLIC_TOKEN }} - greenmail: - image: greenmail/standalone:1.6.9 - ports: - - 3025:3025 #SMTP - - 3110:3110 #POP3 - - 3143:3143 #IMAP - - 3465:3465 #SMTPS - - 3993:3993 #IMAPS - - 3995:3995 #POP3S - - 8080:8080 #API - credentials: - username: ${{ secrets.DOCKERHUB_PUBLIC_USERNAME }} - password: ${{ secrets.DOCKERHUB_PUBLIC_TOKEN }} steps: - # when workflow is run via a workflow_call, these vars are found under input, which doesn't exist otherwise - # so lets copy them over to the normal env vars - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_PUBLIC_USERNAME }} - password: ${{ secrets.DOCKERHUB_PUBLIC_TOKEN }} + - name: Check for Docker Hub secrets (DOCKERHUB_PUBLIC_USERNAME, DOCKERHUB_PUBLIC_TOKEN) + run: | + if [[ ! -z "$DOCKERHUB_PUBLIC_USERNAME" ]]; then + echo "Docker hub credentials defined" + else + echo "No Docker hub credentials defined, you may be rate limited" + fi + env: + DOCKERHUB_PUBLIC_USERNAME: ${{ secrets.DOCKERHUB_PUBLIC_USERNAME }} + + - name: Start Docker Services (with credentials) + if: ${{ env.DOCKERHUB_PUBLIC_USERNAME != '' }} + uses: ./.github/workflows/build-services.yml + - name: Start Docker Services (without credentials) + if: ${{ env.DOCKERHUB_PUBLIC_USERNAME != '' }} + uses: ./.github/workflows/build-services-no-credentials.yml - name: Configure Build Java Version if: ${{ inputs.LUCEE_BUILD_JAVA_VERSION != '' }} @@ -152,13 +113,6 @@ jobs: sudo -u postgres psql -c 'create database lucee;' sudo -u postgres psql -c "create user lucee with encrypted password 'lucee'"; sudo -u postgres psql -c 'grant all privileges on database lucee to lucee;' - - name: Start MongoDB (docker) - uses: supercharge/mongodb-github-action@1.6.0 - with: - mongodb-version: 4.4 - mongodb-port: 27017 - - name: Setup Memcached (docker) - uses: niden/actions-memcached@v7 - name: Extract version number id: extract-version run: |