From 88a3c6f9a550ab025a1a3327bbd31ab5a1e908d2 Mon Sep 17 00:00:00 2001 From: Luchesar ILIEV Date: Thu, 16 May 2024 13:58:04 +0300 Subject: [PATCH] ops: update software versions for testing Also update the actions configuration and add dependabot config. --- .github/dependabot.yml | 11 ++ .github/workflows/build.yml | 136 +++++++++++++----- README.md | 9 +- ci/ambit-api/tags.txt | 5 +- .../tomcat8.5-jdk17-temurin/Dockerfile | 13 -- .../docker-entrypoint.sh | 75 ---------- .../Dockerfile | 2 +- .../docker-entrypoint.sh | 0 .../Dockerfile | 2 +- .../docker-entrypoint.sh | 0 ci/ambit-db/mariadb-10.10/Dockerfile | 18 --- .../mariadb-10.10/docker-entrypoint-ambit.sh | 126 ---------------- .../mariadb-10.11/docker-entrypoint-ambit.sh | 2 +- ci/ambit-db/mariadb-10.4/Dockerfile | 19 --- .../mariadb-10.4/docker-entrypoint-ambit.sh | 126 ---------------- ci/ambit-db/mariadb-10.5/Dockerfile | 18 --- .../mariadb-10.5/docker-entrypoint-ambit.sh | 126 ---------------- .../docker-entrypoint-ambit.sh | 2 +- .../mariadb-10.6/docker-entrypoint-ambit.sh | 2 +- ci/ambit-db/mysql-5.7/Dockerfile | 19 --- .../mysql-5.7/docker-entrypoint-ambit.sh | 126 ---------------- ci/ambit-db/tags.txt | 8 +- 22 files changed, 123 insertions(+), 722 deletions(-) create mode 100755 .github/dependabot.yml delete mode 100644 ci/ambit-api/tomcat8.5-jdk17-temurin/Dockerfile delete mode 100755 ci/ambit-api/tomcat8.5-jdk8-temurin/docker-entrypoint.sh rename ci/ambit-api/{tomcat8.5-jdk8-temurin => tomcat9-jdk21-temurin}/Dockerfile (91%) rename ci/ambit-api/{tomcat8.5-jdk11-temurin => tomcat9-jdk21-temurin}/docker-entrypoint.sh (100%) rename ci/ambit-api/{tomcat8.5-jdk11-temurin => tomcat9-jdk25-temurin}/Dockerfile (90%) rename ci/ambit-api/{tomcat8.5-jdk17-temurin => tomcat9-jdk25-temurin}/docker-entrypoint.sh (100%) delete mode 100644 ci/ambit-db/mariadb-10.10/Dockerfile delete mode 100755 ci/ambit-db/mariadb-10.10/docker-entrypoint-ambit.sh delete mode 100644 ci/ambit-db/mariadb-10.4/Dockerfile delete mode 100755 ci/ambit-db/mariadb-10.4/docker-entrypoint-ambit.sh delete mode 100644 ci/ambit-db/mariadb-10.5/Dockerfile delete mode 100755 ci/ambit-db/mariadb-10.5/docker-entrypoint-ambit.sh delete mode 100644 ci/ambit-db/mysql-5.7/Dockerfile delete mode 100755 ci/ambit-db/mysql-5.7/docker-entrypoint-ambit.sh diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100755 index 0000000..f152684 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +--- +version: 2 +updates: + + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + assignees: + - "kerberizer" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b0f267a..1f60171 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,10 +4,16 @@ name: Build the ambit-docker images on: # yamllint disable-line rule:truthy workflow_dispatch: repository_dispatch: - types: [ambit-repo-push] + types: + - ambit-repo-push push: branches: - master + - ci-updates + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: @@ -21,7 +27,7 @@ jobs: steps: - name: Checkout the repository - uses: actions/checkout@v3 + uses: actions/checkout@v6.0.1 - name: Determining the RDBMS test matrix id: db @@ -48,14 +54,16 @@ jobs: war_db="$( awk "${awk_get_war_from_db}" '${{ env.prefix }}/tags.txt')" echo "war-db=${war_db}" >> $GITHUB_OUTPUT + build-ambit: - needs: [set-test-matrices] runs-on: ubuntu-latest + needs: + - set-test-matrices strategy: matrix: - java-distribution: ['temurin', 'zulu'] - java-version: [8, 11, 17] + java-distribution: ['temurin', 'corretto'] + java-version: [8, 11, 17, 21, 25] rdbms-version: ${{ fromJson(needs.set-test-matrices.outputs.matrix-db) }} fail-fast: false env: @@ -66,14 +74,14 @@ jobs: steps: - name: Checkout the AMBIT repository - uses: actions/checkout@v3 + uses: actions/checkout@v6.0.1 with: repository: ideaconsult/ambit-mirror ref: ${{ github.event.client_payload.sha }} token: ${{ secrets.GH_R_PR }} - name: 'Set up OpenJDK: ${{ matrix.java-distribution }}/${{ matrix.java-version }}' - uses: actions/setup-java@v3 + uses: actions/setup-java@v5.1.0 with: distribution: ${{ matrix.java-distribution }} java-version: ${{ matrix.java-version }} @@ -83,7 +91,7 @@ jobs: - name: Set up Maven if using act if: ${{ env.ACT }} env: - maven_version: 3.6.3 + maven_version: 3.9.11 run: >- wget -P /tmp "https://mirrors.netix.net/apache/maven/maven-3/${maven_version}/binaries/apache-maven-${maven_version}-bin.tar.gz"; @@ -91,7 +99,7 @@ jobs: ln -s -t /usr/bin "/opt/apache-maven-${maven_version}/bin/mvn" - name: Cache the local Maven repository - uses: actions/cache@v3 + uses: actions/cache@v4.3.0 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} @@ -184,14 +192,18 @@ jobs: run: docker stop "${rdbms_ctnr_name}" - name: Save the newly build WAR - # Only the one tested with the RDBMS marked with our "latest" image tag - if: ${{ matrix.rdbms-version == needs.set-test-matrices.outputs.war-db }} - uses: actions/upload-artifact@v3 + # Only the one tested with the RDBMS marked with our "latest" image tag, + # and only for the Java distribution that we build our images with. + if: > + matrix.rdbms-version == needs.set-test-matrices.outputs.war-db && + matrix.java-distribution == 'temurin' + uses: actions/upload-artifact@v5.0.0 with: name: ambit-war-java${{ matrix.java-version }} path: ambit2-apps/ambit2-www/target/ambit2.war retention-days: 1 + set-build-matrices: runs-on: ubuntu-latest @@ -203,7 +215,7 @@ jobs: steps: - name: Checkout the repository - uses: actions/checkout@v3 + uses: actions/checkout@v6.0.1 - name: Determining the ambit-api build matrix id: api @@ -225,10 +237,13 @@ jobs: jq . <<<"$matrix_json" # lint echo "matrix=${matrix_json}" >> $GITHUB_OUTPUT + build-images-api: - needs: [build-ambit, set-build-matrices] runs-on: ubuntu-latest + needs: + - build-ambit + - set-build-matrices strategy: matrix: ${{ fromJson(needs.set-build-matrices.outputs.matrix-api) }} env: @@ -239,7 +254,7 @@ jobs: steps: - name: Checkout the repository - uses: actions/checkout@v3 + uses: actions/checkout@v6.0.1 - name: Identify the OpenJDK version run: | @@ -247,7 +262,7 @@ jobs: echo "java_version=${java_version}" >>"$GITHUB_ENV" - name: Load the latest WAR for the required OpenJDK version - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v6.0.0 with: name: ambit-war-java${{ env.java_version }} path: ./ci/${{ env.image }}/${{ matrix.ver }} @@ -264,33 +279,43 @@ jobs: echo "image_tags=${tags_list:1}" >>"$GITHUB_ENV" - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3.11.1 - name: Log in to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3.6.0 with: registry: ghcr.io - username: idea-docker - password: ${{ secrets.GH_CR_FA }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Log in to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3.6.0 with: - username: kerberizer + username: ${{ secrets.DCKR_USER }} password: ${{ secrets.DCKR_TOKEN }} - name: Build the ambit-api image - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6.18.0 with: context: ./ci/${{ env.image }}/${{ matrix.ver }} + outputs: type=docker,dest=ambit-api.${{ matrix.ver }}.docker.tar pull: true push: ${{ github.ref == 'refs/heads/master' }} # push only if we're on the master branch tags: ${{ env.image_tags }} + - name: Upload the built image as artifact for download + uses: actions/upload-artifact@v5.0.0 + with: + name: ambit-api.${{ matrix.ver }}.docker.tar + path: ambit-api.${{ matrix.ver }}.docker.tar + retention-days: 3 + + build-images-db: - needs: set-build-matrices runs-on: ubuntu-latest + needs: + - set-build-matrices strategy: matrix: ${{ fromJson(needs.set-build-matrices.outputs.matrix-db) }} env: @@ -301,7 +326,7 @@ jobs: steps: - name: Checkout the repository - uses: actions/checkout@v3 + uses: actions/checkout@v6.0.1 - name: Determine the image tags run: >- @@ -315,43 +340,76 @@ jobs: echo "image_tags=${tags_list:1}" >>"$GITHUB_ENV" - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3.11.1 - name: Log in to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3.6.0 with: registry: ghcr.io - username: idea-docker - password: ${{ secrets.GH_CR_FA }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Log in to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3.6.0 with: - username: kerberizer + username: ${{ secrets.DCKR_USER }} password: ${{ secrets.DCKR_TOKEN }} - name: Build the ambit-db image - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6.18.0 with: context: ./ci/${{ env.image }}/${{ matrix.ver }} + outputs: type=docker,dest=ambit-db.${{ matrix.ver }}.docker.tar pull: true push: ${{ github.ref == 'refs/heads/master' }} # push only if we're on the master branch tags: ${{ env.image_tags }} + - name: Upload the built image as artifact for download + uses: actions/upload-artifact@v5.0.0 + with: + name: ambit-db.${{ matrix.ver }}.docker.tar + path: ambit-db.${{ matrix.ver }}.docker.tar + retention-days: 3 + + integration-testing: - needs: [build-images-api, build-images-db] runs-on: ubuntu-latest + needs: + - set-build-matrices + - build-images-api + - build-images-db + strategy: + matrix: + api: ${{ fromJson(needs.set-build-matrices.outputs.matrix-api) }} + db: ${{ fromJson(needs.set-build-matrices.outputs.matrix-db) }} steps: - name: Checkout the repository - uses: actions/checkout@v3 + uses: actions/checkout@v6.0.1 + + - name: Download the ambit-api Docker image + uses: actions/download-artifact@v6.0.0 + with: + name: ambit-api.${{ matrix.api.ver }}.docker.tar + + - name: Download the ambit-db Docker image + uses: actions/download-artifact@v6.0.0 + with: + name: ambit-db.${{ matrix.db.ver }}.docker.tar + + - name: Load the Docker images and spoof as 'latest' + run: | + docker load --input ambit-api.${{ matrix.api.ver }}.docker.tar + docker load --input ambit-db.${{ matrix.db.ver }}.docker.tar + docker tag ideaconsult/ambit-api:${{ matrix.api.ver }} ideaconsult/ambit-api + docker tag ideaconsult/ambit-db:${{ matrix.db.ver }} ideaconsult/ambit-db - - name: Spin up a default docker-compose setup + - name: Spin up a default Docker Compose setup run: | - docker-compose pull - docker-compose up --detach + docker compose pull + docker compose up --detach - name: Wait for the API to become operational run: | @@ -363,8 +421,8 @@ jobs: - name: Run the API tests run: ./ci/run_integration_tests.sh - - name: Bring down the docker-compose setup - run: docker-compose down --volumes + - name: Bring down the Docker Compose setup + run: docker compose down --volumes # FIXME: Temporarily not sending notifications to Discord until we manage to send the final status. # send-notifications: diff --git a/README.md b/README.md index 6e1e75e..ef760b6 100644 --- a/README.md +++ b/README.md @@ -99,9 +99,12 @@ ambit-db | [ci/ambit-db/tags.txt](https://github.com/ideaconsult/ambit-docker/b ## Notes on specific versions -* Java 11 and 17 are supported, but for maximum stability we still recommend Java 8 as the most thoroughly tested platform. -* MySQL 8+ is *not* supported. We may add support for it in the future, but for the time being please use MariaDB instead. -* Tomcat 10 is *not* supported and most likely will never be supported. We plan to transition to [Quarkus](https://quarkus.io/). +* Java LTS versions up to and including 25 should work, of which Java 8 remains the most thoroughly tested platform. +* There are many Java binary builds. We test [Eclispe Temurin](https://adoptium.net/), which is used in our Docker images, and [Amazon Corretto](https://aws.amazon.com/corretto/). +* MySQL is *not* supported. If your organization requires such support, please contact us at `support@ideaconsult.net`. +* MariaDB 11+ is *not yet* supported, but will be. Currently supported are the 10.x LTS versions. +* For both Java and MariaDB we test only LTS releases that are still supported, e.g. Java 22 or MariaDB 10.5 are not tested. +* Tomcat 10+ is *not* supported and most likely will never be supported. We plan to transition to [Quarkus](https://quarkus.io/). # Troubleshooting * If you hit the Docker Hub pull limits, use [GitHub Container Registry](https://github.com/orgs/ideaconsult/packages). You'll need to edit the docker compose files and prepend the `image` settings with `ghcr.io/`, e.g. `ideaconsult/ambit-db:latest` becomes `ghcr.io/ideaconsult/ambit-db:latest`. diff --git a/ci/ambit-api/tags.txt b/ci/ambit-api/tags.txt index 027b903..222fa55 100644 --- a/ci/ambit-api/tags.txt +++ b/ci/ambit-api/tags.txt @@ -1,6 +1,5 @@ +tomcat9-jdk25-temurin tomcat9-jdk25 jdk25 +tomcat9-jdk21-temurin tomcat9-jdk21 jdk21 tomcat9-jdk17-temurin tomcat9-jdk17 jdk17 tomcat9-jdk11-temurin tomcat9-jdk11 jdk11 tomcat9-jdk8-temurin tomcat9-jdk8 tomcat9 jdk8 latest -tomcat8.5-jdk17-temurin tomcat8.5-jdk17 -tomcat8.5-jdk11-temurin tomcat8.5-jdk11 -tomcat8.5-jdk8-temurin tomcat8.5-jdk8 tomcat8.5 diff --git a/ci/ambit-api/tomcat8.5-jdk17-temurin/Dockerfile b/ci/ambit-api/tomcat8.5-jdk17-temurin/Dockerfile deleted file mode 100644 index 8197c14..0000000 --- a/ci/ambit-api/tomcat8.5-jdk17-temurin/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM tomcat:8.5-jdk17-temurin - -ENV AMBIT_CONFIG_OVERRIDE_DIR /opt/ambit/config_override - -COPY docker-entrypoint.sh /usr/local/bin/ -RUN ln -s usr/local/bin/docker-entrypoint.sh / -ENTRYPOINT ["docker-entrypoint.sh"] - -COPY ambit2.war /usr/local/tomcat/webapps/ambit.war - -CMD ["catalina.sh", "run"] - -# vim: set ts=4 sts=4 sw=4 et: diff --git a/ci/ambit-api/tomcat8.5-jdk8-temurin/docker-entrypoint.sh b/ci/ambit-api/tomcat8.5-jdk8-temurin/docker-entrypoint.sh deleted file mode 100755 index f106034..0000000 --- a/ci/ambit-api/tomcat8.5-jdk8-temurin/docker-entrypoint.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env bash -set -o noclobber -set -o errexit -set -o pipefail -set -o nounset - - -ambit_internal_config_dir='WEB-INF/classes/ambit2/rest/config' -ambit2_props_file="${ambit_internal_config_dir}/ambit2.pref" -config_props_file="${ambit_internal_config_dir}/config.prop" -tomcat_webapps_dir='/usr/local/tomcat/webapps' -ambit_deploy_dir="${tomcat_webapps_dir}/ambit" -ambit_war="${ambit_deploy_dir}.war" - -ambit_profile="${AMBIT_PROFILE:-enanomapper}" -ambit_database="${AMBIT_DATABASE:-ambit}" -ambit_db_host="${AMBIT_DB_HOST:-db}" -ambit_db_user="${AMBIT_DB_USER:-ambit}" -ambit_db_pass="${AMBIT_DB_PASS:-ambit}" -ambit_aa_enable="${AMBIT_AA_ENABLE:-false}" -ambit_users_db="${AMBIT_USERS_DB:-ambit_users}" - -declare -A ambit2_props=( - ['ambit.profile']="${ambit_profile}" - ['Database']="${ambit_database}" - ['Host']="${ambit_db_host}" - ['User']="${ambit_db_user}" - ['Password']="${ambit_db_pass}" -) - -declare -A config_props=( - ['aa.db.enabled']="${ambit_aa_enable}" - ['Database']="${ambit_users_db}" - ['Host']="${ambit_db_host}" - ['User']="${ambit_db_user}" - ['Password']="${ambit_db_pass}" - ['secret']="$(tr -cd '[:alnum:]' "${initdb_d_init_databases}" - - - # Create the AMBIT database(s) and the associated grants. - for ambit_db in ${ambit_databases}; do - echo "CREATE DATABASE \`${ambit_db}\` CHARACTER SET utf8;" - echo "GRANT ALL ON \`${ambit_db}\`.* TO '${ambit_db_user}'@'%';" - echo "GRANT TRIGGER ON \`${ambit_db}\`.* TO '${ambit_db_user}'@'%';" - done >>"${initdb_d_init_databases}" - - - # Initialize the AMBIT databases. - for ambit_db in ${ambit_databases}; do - echo "USE \`${ambit_db}\`;" - cat "${ambit_sql_tables}" - done >"${initdb_d_create_ambit_tables}" - - - # Initialize the AMBIT users database. - { - echo "USE \`${ambit_users_db}\`;" - sed 's|"/ambit2"|"/ambit"|g' "${ambit_sql_users}" - } >"${initdb_d_create_ambit_user_tables}" - - - # Set up the execute procedure grants. - for ambit_db in ${ambit_databases}; do - for procedure in "${procedure_list[@]}"; do - echo "GRANT EXECUTE ON PROCEDURE \`${ambit_db}\`.${procedure} TO '${ambit_db_user}'@'%';" - done - done >"${initdb_d_init_procedure_grants}" - - - # If well-known public databases are defined, populate them. - echo '[Entrypoint AMBIT] Populating databases...' - for ambit_db in ${ambit_databases}; do - set +o nounset - if [[ -r ${ambit_sql_data_import}/${ambit_db}.sql.xz ]]; then - set -o nounset - echo "USE \`${ambit_db}\`;" - xzcat "${ambit_sql_data_import}/${ambit_db}.sql.xz" - # Well-known DB names (e.g. "nanoreg1") could be set as keys in the associative array - # ${public_db_import_urls}, with the URI to fetch the (compressed) SQL from as value. - elif [[ ${public_db_import_urls[${ambit_db}]} ]]; then - set -o nounset - import_url="${public_db_import_urls[${ambit_db}]}" - echo "USE \`${ambit_db}\`;" - curl -s "${import_url}" | xzcat - else - set -o nounset - echo "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" >/dev/stderr - echo >/dev/stderr - echo "WARNING: Missing SQL import file for database \"${ambit_db}\"" >/dev/stderr - echo >/dev/stderr - echo "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" >/dev/stderr - fi - done >"${initdb_d_populate_databases}" - - - # Clean up. - rm -r "${ambit_tmp}" - - -# End the initialization "if" block. -fi - - -# Switch to the upstream Docker image entrypoint script. -exec /usr/local/bin/docker-entrypoint.sh "$@" diff --git a/ci/ambit-db/mariadb-10.11/docker-entrypoint-ambit.sh b/ci/ambit-db/mariadb-10.11/docker-entrypoint-ambit.sh index 6c56c30..8950d6c 100755 --- a/ci/ambit-db/mariadb-10.11/docker-entrypoint-ambit.sh +++ b/ci/ambit-db/mariadb-10.11/docker-entrypoint-ambit.sh @@ -102,7 +102,7 @@ if [[ ! -d ${mysql_datadir}mysql && ( -z ${1} || ${1:0:1} = '-' ) ]]; then set -o nounset import_url="${public_db_import_urls[${ambit_db}]}" echo "USE \`${ambit_db}\`;" - curl -s "${import_url}" | xzcat + curl -Ls "${import_url}" | xzcat else set -o nounset echo "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" >/dev/stderr diff --git a/ci/ambit-db/mariadb-10.4/Dockerfile b/ci/ambit-db/mariadb-10.4/Dockerfile deleted file mode 100644 index 77b7264..0000000 --- a/ci/ambit-db/mariadb-10.4/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM mariadb:10.4 - -ENV MYSQL_ROOT_PASSWORD ambitroot - -RUN apt-get update && apt-get --yes install curl xz-utils - -ADD https://raw.githubusercontent.com/ideaconsult/ambit-mirror/master/ambit2-all/ambit2-db/src/main/resources/ambit2/db/sql/create_tables.sql \ - /opt/ambit/tmp/ - -ADD https://raw.githubusercontent.com/vedina/RESTNet/master/restnet-db/src/main/resources/net/idea/restnet/db/aalocal/sql/users.sql \ - /opt/ambit/tmp/ - -COPY docker-entrypoint-ambit.sh /usr/local/bin/ -RUN ln -s usr/local/bin/docker-entrypoint-ambit.sh / -ENTRYPOINT ["docker-entrypoint-ambit.sh"] - -CMD ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"] - -# vim: set ts=4 sts=4 sw=4 et: diff --git a/ci/ambit-db/mariadb-10.4/docker-entrypoint-ambit.sh b/ci/ambit-db/mariadb-10.4/docker-entrypoint-ambit.sh deleted file mode 100755 index 6c56c30..0000000 --- a/ci/ambit-db/mariadb-10.4/docker-entrypoint-ambit.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env bash -set -o noclobber -set -o errexit -set -o pipefail -set -o nounset - - -ambit_db_user="${AMBIT_DB_USER:-ambit}" -ambit_db_pass="${AMBIT_DB_PASS:-ambit}" -ambit_users_db="${AMBIT_USERS_DB:-ambit_users}" -ambit_databases="${AMBIT_DATABASES:-ambit}" - -ambit_base='/opt/ambit' -ambit_tmp="${ambit_base}/tmp" -ambit_sql_tables="${ambit_tmp}/create_tables.sql" -ambit_sql_users="${ambit_tmp}/users.sql" -ambit_sql_data_import="${ambit_base}/data_import" - -declare -a procedure_list=( - 'findByProperty' - 'deleteDataset' - 'createBundleCopy' - 'createBundleVersion' -) - -declare -A public_db_import_urls=( - ['calibrate']='https://zenodo.org/record/7193516/files/calibrate.sql.xz' - ['gracious']='https://zenodo.org/record/7777590/files/gracious.sql.xz' - ['nanoreg1']='https://zenodo.org/record/3467016/files/nanoreg_nrfiles.sql.xz' - ['nanoreg2']='https://zenodo.org/record/4713745/files/nanoreg2.sql.xz' -) - -initdb_d_base='/docker-entrypoint-initdb.d' -initdb_d_init_databases="${initdb_d_base}/00-init-databases.sql" -initdb_d_create_ambit_tables="${initdb_d_base}/01-create-ambit-tables.sql" -initdb_d_create_ambit_user_tables="${initdb_d_base}/02-create-ambit-user-tables.sql" -initdb_d_init_procedure_grants="${initdb_d_base}/03-init-procedure-grants.sql" -initdb_d_populate_databases="${initdb_d_base}/04-populate-databases.sql" - - -# Run the initialization process if both are true: -# * the initialization has not already been performed; -# * no custom command is passed or it's only an option for MariaDB/MySQL. - -mysql_datadir="$(mysqld --verbose --help --log-bin-index=/dev/null 2>/dev/null \ - | awk '/^datadir[[:blank:]]/ { print $2 }')" - -if [[ ! -d ${mysql_datadir}mysql && ( -z ${1} || ${1:0:1} = '-' ) ]]; then - - # Create the AMBIT user and the AMBIT users database. - # FIXME: We also need the 'guest'@'localhost' user. - guest_pass="$(openssl rand -base64 32)" - { - echo "CREATE USER 'guest'@'localhost' IDENTIFIED BY '${guest_pass}';" - echo "CREATE USER '${ambit_db_user}'@'%' IDENTIFIED BY '${ambit_db_pass}';" - echo "CREATE DATABASE \`${ambit_users_db}\` CHARACTER SET utf8;" - echo "GRANT ALL ON \`${ambit_users_db}\`.* TO '${ambit_db_user}'@'%';" - } >"${initdb_d_init_databases}" - - - # Create the AMBIT database(s) and the associated grants. - for ambit_db in ${ambit_databases}; do - echo "CREATE DATABASE \`${ambit_db}\` CHARACTER SET utf8;" - echo "GRANT ALL ON \`${ambit_db}\`.* TO '${ambit_db_user}'@'%';" - echo "GRANT TRIGGER ON \`${ambit_db}\`.* TO '${ambit_db_user}'@'%';" - done >>"${initdb_d_init_databases}" - - - # Initialize the AMBIT databases. - for ambit_db in ${ambit_databases}; do - echo "USE \`${ambit_db}\`;" - cat "${ambit_sql_tables}" - done >"${initdb_d_create_ambit_tables}" - - - # Initialize the AMBIT users database. - { - echo "USE \`${ambit_users_db}\`;" - sed 's|"/ambit2"|"/ambit"|g' "${ambit_sql_users}" - } >"${initdb_d_create_ambit_user_tables}" - - - # Set up the execute procedure grants. - for ambit_db in ${ambit_databases}; do - for procedure in "${procedure_list[@]}"; do - echo "GRANT EXECUTE ON PROCEDURE \`${ambit_db}\`.${procedure} TO '${ambit_db_user}'@'%';" - done - done >"${initdb_d_init_procedure_grants}" - - - # If well-known public databases are defined, populate them. - echo '[Entrypoint AMBIT] Populating databases...' - for ambit_db in ${ambit_databases}; do - set +o nounset - if [[ -r ${ambit_sql_data_import}/${ambit_db}.sql.xz ]]; then - set -o nounset - echo "USE \`${ambit_db}\`;" - xzcat "${ambit_sql_data_import}/${ambit_db}.sql.xz" - # Well-known DB names (e.g. "nanoreg1") could be set as keys in the associative array - # ${public_db_import_urls}, with the URI to fetch the (compressed) SQL from as value. - elif [[ ${public_db_import_urls[${ambit_db}]} ]]; then - set -o nounset - import_url="${public_db_import_urls[${ambit_db}]}" - echo "USE \`${ambit_db}\`;" - curl -s "${import_url}" | xzcat - else - set -o nounset - echo "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" >/dev/stderr - echo >/dev/stderr - echo "WARNING: Missing SQL import file for database \"${ambit_db}\"" >/dev/stderr - echo >/dev/stderr - echo "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" >/dev/stderr - fi - done >"${initdb_d_populate_databases}" - - - # Clean up. - rm -r "${ambit_tmp}" - - -# End the initialization "if" block. -fi - - -# Switch to the upstream Docker image entrypoint script. -exec /usr/local/bin/docker-entrypoint.sh "$@" diff --git a/ci/ambit-db/mariadb-10.5/Dockerfile b/ci/ambit-db/mariadb-10.5/Dockerfile deleted file mode 100644 index 00e0e52..0000000 --- a/ci/ambit-db/mariadb-10.5/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM mariadb:10.5 - -ENV MYSQL_ROOT_PASSWORD ambitroot - -RUN apt-get update && apt-get --yes install curl xz-utils - -ADD https://raw.githubusercontent.com/ideaconsult/ambit-mirror/master/ambit2-all/ambit2-db/src/main/resources/ambit2/db/sql/create_tables.sql \ - /opt/ambit/tmp/ - -ADD https://raw.githubusercontent.com/vedina/RESTNet/master/restnet-db/src/main/resources/net/idea/restnet/db/aalocal/sql/users.sql \ - /opt/ambit/tmp/ - -COPY docker-entrypoint-ambit.sh /usr/local/bin/ -ENTRYPOINT ["docker-entrypoint-ambit.sh"] - -CMD ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"] - -# vim: set ts=4 sts=4 sw=4 et: diff --git a/ci/ambit-db/mariadb-10.5/docker-entrypoint-ambit.sh b/ci/ambit-db/mariadb-10.5/docker-entrypoint-ambit.sh deleted file mode 100755 index 6c56c30..0000000 --- a/ci/ambit-db/mariadb-10.5/docker-entrypoint-ambit.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env bash -set -o noclobber -set -o errexit -set -o pipefail -set -o nounset - - -ambit_db_user="${AMBIT_DB_USER:-ambit}" -ambit_db_pass="${AMBIT_DB_PASS:-ambit}" -ambit_users_db="${AMBIT_USERS_DB:-ambit_users}" -ambit_databases="${AMBIT_DATABASES:-ambit}" - -ambit_base='/opt/ambit' -ambit_tmp="${ambit_base}/tmp" -ambit_sql_tables="${ambit_tmp}/create_tables.sql" -ambit_sql_users="${ambit_tmp}/users.sql" -ambit_sql_data_import="${ambit_base}/data_import" - -declare -a procedure_list=( - 'findByProperty' - 'deleteDataset' - 'createBundleCopy' - 'createBundleVersion' -) - -declare -A public_db_import_urls=( - ['calibrate']='https://zenodo.org/record/7193516/files/calibrate.sql.xz' - ['gracious']='https://zenodo.org/record/7777590/files/gracious.sql.xz' - ['nanoreg1']='https://zenodo.org/record/3467016/files/nanoreg_nrfiles.sql.xz' - ['nanoreg2']='https://zenodo.org/record/4713745/files/nanoreg2.sql.xz' -) - -initdb_d_base='/docker-entrypoint-initdb.d' -initdb_d_init_databases="${initdb_d_base}/00-init-databases.sql" -initdb_d_create_ambit_tables="${initdb_d_base}/01-create-ambit-tables.sql" -initdb_d_create_ambit_user_tables="${initdb_d_base}/02-create-ambit-user-tables.sql" -initdb_d_init_procedure_grants="${initdb_d_base}/03-init-procedure-grants.sql" -initdb_d_populate_databases="${initdb_d_base}/04-populate-databases.sql" - - -# Run the initialization process if both are true: -# * the initialization has not already been performed; -# * no custom command is passed or it's only an option for MariaDB/MySQL. - -mysql_datadir="$(mysqld --verbose --help --log-bin-index=/dev/null 2>/dev/null \ - | awk '/^datadir[[:blank:]]/ { print $2 }')" - -if [[ ! -d ${mysql_datadir}mysql && ( -z ${1} || ${1:0:1} = '-' ) ]]; then - - # Create the AMBIT user and the AMBIT users database. - # FIXME: We also need the 'guest'@'localhost' user. - guest_pass="$(openssl rand -base64 32)" - { - echo "CREATE USER 'guest'@'localhost' IDENTIFIED BY '${guest_pass}';" - echo "CREATE USER '${ambit_db_user}'@'%' IDENTIFIED BY '${ambit_db_pass}';" - echo "CREATE DATABASE \`${ambit_users_db}\` CHARACTER SET utf8;" - echo "GRANT ALL ON \`${ambit_users_db}\`.* TO '${ambit_db_user}'@'%';" - } >"${initdb_d_init_databases}" - - - # Create the AMBIT database(s) and the associated grants. - for ambit_db in ${ambit_databases}; do - echo "CREATE DATABASE \`${ambit_db}\` CHARACTER SET utf8;" - echo "GRANT ALL ON \`${ambit_db}\`.* TO '${ambit_db_user}'@'%';" - echo "GRANT TRIGGER ON \`${ambit_db}\`.* TO '${ambit_db_user}'@'%';" - done >>"${initdb_d_init_databases}" - - - # Initialize the AMBIT databases. - for ambit_db in ${ambit_databases}; do - echo "USE \`${ambit_db}\`;" - cat "${ambit_sql_tables}" - done >"${initdb_d_create_ambit_tables}" - - - # Initialize the AMBIT users database. - { - echo "USE \`${ambit_users_db}\`;" - sed 's|"/ambit2"|"/ambit"|g' "${ambit_sql_users}" - } >"${initdb_d_create_ambit_user_tables}" - - - # Set up the execute procedure grants. - for ambit_db in ${ambit_databases}; do - for procedure in "${procedure_list[@]}"; do - echo "GRANT EXECUTE ON PROCEDURE \`${ambit_db}\`.${procedure} TO '${ambit_db_user}'@'%';" - done - done >"${initdb_d_init_procedure_grants}" - - - # If well-known public databases are defined, populate them. - echo '[Entrypoint AMBIT] Populating databases...' - for ambit_db in ${ambit_databases}; do - set +o nounset - if [[ -r ${ambit_sql_data_import}/${ambit_db}.sql.xz ]]; then - set -o nounset - echo "USE \`${ambit_db}\`;" - xzcat "${ambit_sql_data_import}/${ambit_db}.sql.xz" - # Well-known DB names (e.g. "nanoreg1") could be set as keys in the associative array - # ${public_db_import_urls}, with the URI to fetch the (compressed) SQL from as value. - elif [[ ${public_db_import_urls[${ambit_db}]} ]]; then - set -o nounset - import_url="${public_db_import_urls[${ambit_db}]}" - echo "USE \`${ambit_db}\`;" - curl -s "${import_url}" | xzcat - else - set -o nounset - echo "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" >/dev/stderr - echo >/dev/stderr - echo "WARNING: Missing SQL import file for database \"${ambit_db}\"" >/dev/stderr - echo >/dev/stderr - echo "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" >/dev/stderr - fi - done >"${initdb_d_populate_databases}" - - - # Clean up. - rm -r "${ambit_tmp}" - - -# End the initialization "if" block. -fi - - -# Switch to the upstream Docker image entrypoint script. -exec /usr/local/bin/docker-entrypoint.sh "$@" diff --git a/ci/ambit-db/mariadb-10.6-lri/docker-entrypoint-ambit.sh b/ci/ambit-db/mariadb-10.6-lri/docker-entrypoint-ambit.sh index d50f303..7783aac 100755 --- a/ci/ambit-db/mariadb-10.6-lri/docker-entrypoint-ambit.sh +++ b/ci/ambit-db/mariadb-10.6-lri/docker-entrypoint-ambit.sh @@ -114,7 +114,7 @@ if [[ ! -d ${mysql_datadir}mysql && ( -z ${1} || ${1:0:1} = '-' ) ]]; then set -o nounset import_url="${public_db_import_urls[${ambit_db}]}" echo "USE \`${ambit_db}\`;" - curl -s "${import_url}" | xzcat + curl -Ls "${import_url}" | xzcat else set -o nounset echo "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" >/dev/stderr diff --git a/ci/ambit-db/mariadb-10.6/docker-entrypoint-ambit.sh b/ci/ambit-db/mariadb-10.6/docker-entrypoint-ambit.sh index 6c56c30..8950d6c 100755 --- a/ci/ambit-db/mariadb-10.6/docker-entrypoint-ambit.sh +++ b/ci/ambit-db/mariadb-10.6/docker-entrypoint-ambit.sh @@ -102,7 +102,7 @@ if [[ ! -d ${mysql_datadir}mysql && ( -z ${1} || ${1:0:1} = '-' ) ]]; then set -o nounset import_url="${public_db_import_urls[${ambit_db}]}" echo "USE \`${ambit_db}\`;" - curl -s "${import_url}" | xzcat + curl -Ls "${import_url}" | xzcat else set -o nounset echo "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" >/dev/stderr diff --git a/ci/ambit-db/mysql-5.7/Dockerfile b/ci/ambit-db/mysql-5.7/Dockerfile deleted file mode 100644 index 7c96f33..0000000 --- a/ci/ambit-db/mysql-5.7/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM mysql:5.7-debian - -ENV MYSQL_ROOT_PASSWORD ambitroot - -RUN apt-get update && apt-get --yes install curl xz-utils - -ADD https://raw.githubusercontent.com/ideaconsult/ambit-mirror/master/ambit2-all/ambit2-db/src/main/resources/ambit2/db/sql/create_tables.sql \ - /opt/ambit/tmp/ - -ADD https://raw.githubusercontent.com/vedina/RESTNet/master/restnet-db/src/main/resources/net/idea/restnet/db/aalocal/sql/users.sql \ - /opt/ambit/tmp/ - -COPY docker-entrypoint-ambit.sh /usr/local/bin/ -RUN ln -s usr/local/bin/docker-entrypoint-ambit.sh / -ENTRYPOINT ["docker-entrypoint-ambit.sh"] - -CMD ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"] - -# vim: set ts=4 sts=4 sw=4 et: diff --git a/ci/ambit-db/mysql-5.7/docker-entrypoint-ambit.sh b/ci/ambit-db/mysql-5.7/docker-entrypoint-ambit.sh deleted file mode 100755 index 6c56c30..0000000 --- a/ci/ambit-db/mysql-5.7/docker-entrypoint-ambit.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env bash -set -o noclobber -set -o errexit -set -o pipefail -set -o nounset - - -ambit_db_user="${AMBIT_DB_USER:-ambit}" -ambit_db_pass="${AMBIT_DB_PASS:-ambit}" -ambit_users_db="${AMBIT_USERS_DB:-ambit_users}" -ambit_databases="${AMBIT_DATABASES:-ambit}" - -ambit_base='/opt/ambit' -ambit_tmp="${ambit_base}/tmp" -ambit_sql_tables="${ambit_tmp}/create_tables.sql" -ambit_sql_users="${ambit_tmp}/users.sql" -ambit_sql_data_import="${ambit_base}/data_import" - -declare -a procedure_list=( - 'findByProperty' - 'deleteDataset' - 'createBundleCopy' - 'createBundleVersion' -) - -declare -A public_db_import_urls=( - ['calibrate']='https://zenodo.org/record/7193516/files/calibrate.sql.xz' - ['gracious']='https://zenodo.org/record/7777590/files/gracious.sql.xz' - ['nanoreg1']='https://zenodo.org/record/3467016/files/nanoreg_nrfiles.sql.xz' - ['nanoreg2']='https://zenodo.org/record/4713745/files/nanoreg2.sql.xz' -) - -initdb_d_base='/docker-entrypoint-initdb.d' -initdb_d_init_databases="${initdb_d_base}/00-init-databases.sql" -initdb_d_create_ambit_tables="${initdb_d_base}/01-create-ambit-tables.sql" -initdb_d_create_ambit_user_tables="${initdb_d_base}/02-create-ambit-user-tables.sql" -initdb_d_init_procedure_grants="${initdb_d_base}/03-init-procedure-grants.sql" -initdb_d_populate_databases="${initdb_d_base}/04-populate-databases.sql" - - -# Run the initialization process if both are true: -# * the initialization has not already been performed; -# * no custom command is passed or it's only an option for MariaDB/MySQL. - -mysql_datadir="$(mysqld --verbose --help --log-bin-index=/dev/null 2>/dev/null \ - | awk '/^datadir[[:blank:]]/ { print $2 }')" - -if [[ ! -d ${mysql_datadir}mysql && ( -z ${1} || ${1:0:1} = '-' ) ]]; then - - # Create the AMBIT user and the AMBIT users database. - # FIXME: We also need the 'guest'@'localhost' user. - guest_pass="$(openssl rand -base64 32)" - { - echo "CREATE USER 'guest'@'localhost' IDENTIFIED BY '${guest_pass}';" - echo "CREATE USER '${ambit_db_user}'@'%' IDENTIFIED BY '${ambit_db_pass}';" - echo "CREATE DATABASE \`${ambit_users_db}\` CHARACTER SET utf8;" - echo "GRANT ALL ON \`${ambit_users_db}\`.* TO '${ambit_db_user}'@'%';" - } >"${initdb_d_init_databases}" - - - # Create the AMBIT database(s) and the associated grants. - for ambit_db in ${ambit_databases}; do - echo "CREATE DATABASE \`${ambit_db}\` CHARACTER SET utf8;" - echo "GRANT ALL ON \`${ambit_db}\`.* TO '${ambit_db_user}'@'%';" - echo "GRANT TRIGGER ON \`${ambit_db}\`.* TO '${ambit_db_user}'@'%';" - done >>"${initdb_d_init_databases}" - - - # Initialize the AMBIT databases. - for ambit_db in ${ambit_databases}; do - echo "USE \`${ambit_db}\`;" - cat "${ambit_sql_tables}" - done >"${initdb_d_create_ambit_tables}" - - - # Initialize the AMBIT users database. - { - echo "USE \`${ambit_users_db}\`;" - sed 's|"/ambit2"|"/ambit"|g' "${ambit_sql_users}" - } >"${initdb_d_create_ambit_user_tables}" - - - # Set up the execute procedure grants. - for ambit_db in ${ambit_databases}; do - for procedure in "${procedure_list[@]}"; do - echo "GRANT EXECUTE ON PROCEDURE \`${ambit_db}\`.${procedure} TO '${ambit_db_user}'@'%';" - done - done >"${initdb_d_init_procedure_grants}" - - - # If well-known public databases are defined, populate them. - echo '[Entrypoint AMBIT] Populating databases...' - for ambit_db in ${ambit_databases}; do - set +o nounset - if [[ -r ${ambit_sql_data_import}/${ambit_db}.sql.xz ]]; then - set -o nounset - echo "USE \`${ambit_db}\`;" - xzcat "${ambit_sql_data_import}/${ambit_db}.sql.xz" - # Well-known DB names (e.g. "nanoreg1") could be set as keys in the associative array - # ${public_db_import_urls}, with the URI to fetch the (compressed) SQL from as value. - elif [[ ${public_db_import_urls[${ambit_db}]} ]]; then - set -o nounset - import_url="${public_db_import_urls[${ambit_db}]}" - echo "USE \`${ambit_db}\`;" - curl -s "${import_url}" | xzcat - else - set -o nounset - echo "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" >/dev/stderr - echo >/dev/stderr - echo "WARNING: Missing SQL import file for database \"${ambit_db}\"" >/dev/stderr - echo >/dev/stderr - echo "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" >/dev/stderr - fi - done >"${initdb_d_populate_databases}" - - - # Clean up. - rm -r "${ambit_tmp}" - - -# End the initialization "if" block. -fi - - -# Switch to the upstream Docker image entrypoint script. -exec /usr/local/bin/docker-entrypoint.sh "$@" diff --git a/ci/ambit-db/tags.txt b/ci/ambit-db/tags.txt index a357941..0d137e8 100644 --- a/ci/ambit-db/tags.txt +++ b/ci/ambit-db/tags.txt @@ -1,6 +1,2 @@ -mariadb-10.11 -mariadb-10.10 -mariadb-10.6 mariadb-10 mariadb latest -mariadb-10.5 -mariadb-10.4 -mysql-5.7 mysql-5 mysql +mariadb-10.11 mariadb-10 mariadb latest +mariadb-10.6