From bd4e3e27611119b05438b90ba155f783550888c5 Mon Sep 17 00:00:00 2001 From: Bart Geesink Date: Wed, 13 Dec 2023 16:32:00 +0100 Subject: [PATCH 1/6] Docker: Set SetEnv HTTPS on in Apache --- docker/conf/webauthn-apache2.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/conf/webauthn-apache2.conf b/docker/conf/webauthn-apache2.conf index 390d396b..c6d80d43 100644 --- a/docker/conf/webauthn-apache2.conf +++ b/docker/conf/webauthn-apache2.conf @@ -4,6 +4,7 @@ DocumentRoot /var/www/html/public + SetEnv HTTPS on SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 From 061bf79aa7085210a52f892bce6fdd9569b7269e Mon Sep 17 00:00:00 2001 From: Bart Geesink Date: Thu, 7 Dec 2023 17:03:59 +0100 Subject: [PATCH 2/6] GHA: Add action to build a test image --- .../build-push-test-docker-image.yml | 57 +++++++++++++++++++ component_info | 1 + docker/Dockerfile.test | 16 ++++++ 3 files changed, 74 insertions(+) create mode 100644 .github/workflows/build-push-test-docker-image.yml create mode 100644 docker/Dockerfile.test diff --git a/.github/workflows/build-push-test-docker-image.yml b/.github/workflows/build-push-test-docker-image.yml new file mode 100644 index 00000000..2eadc97f --- /dev/null +++ b/.github/workflows/build-push-test-docker-image.yml @@ -0,0 +1,57 @@ +name: build-push-test-docker-image + +on: + push: + branches: feature/build-and-publish-test-container + workflow_dispatch: + +jobs: + build-push-test-docker-image: + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Build the app + uses: openconext/build-and-publish-test-container/php82-node20@main + with: + use_yarn: true + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set docker labels and tags + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/openconext/stepup-webauthn/stepup-webauthn + flavor: | + latest=false + suffix=-test + tags: | + type=ref,event=tag + type=semver,pattern={{version}} + type=sha + type=raw,suffix=,value=test + + - name: Build and push the TEST image + uses: docker/build-push-action@v4 + with: + context: . + file: docker/Dockerfile.test + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/component_info b/component_info index 7dc2c4cd..7997e89c 100644 --- a/component_info +++ b/component_info @@ -3,3 +3,4 @@ SYMFONY_VERSION=6 ENCORE=yes ASSETIC=no NODE_VERSION=20 +TEST_EXTRA_DIRS="dev/ tests/ ci/" diff --git a/docker/Dockerfile.test b/docker/Dockerfile.test new file mode 100644 index 00000000..45b17cd4 --- /dev/null +++ b/docker/Dockerfile.test @@ -0,0 +1,16 @@ +FROM ghcr.io/openconext/openconext-basecontainers/php82-apache2:latest +# Set the default workdir +WORKDIR /var/www/html +ADD output.tar /var/www/html/ +# Add the application configuration files +RUN cp .env.dist .env +RUN cp config/openconext/parameters.yaml.dist config/openconext/parameters.yaml +# Add the config files for Apache2 +RUN rm -rf /etc/apache2/sites-enabled/* +COPY ./docker/conf/webauthn-apache2.conf /etc/apache2/sites-enabled/webauthn.conf +RUN rm -rf /var/www/html/var/cache/prod && \ + mkdir -p /var/www/html/var/ && \ + chown -R www-data /var/www/html/var +EXPOSE 80 + +CMD ["apache2-foreground"] From 07102463acb429cc2dd0478c6157fd7551ee1140 Mon Sep 17 00:00:00 2001 From: Bart Geesink Date: Tue, 12 Dec 2023 09:07:57 +0100 Subject: [PATCH 3/6] Add smoketest parameters to override the default database used for testing --- config/services_smoketest.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 config/services_smoketest.yml diff --git a/config/services_smoketest.yml b/config/services_smoketest.yml new file mode 100644 index 00000000..a4c328a7 --- /dev/null +++ b/config/services_smoketest.yml @@ -0,0 +1,2 @@ +parameters: + database_url: "mysql://webauthn:webauthn_secret@mariadb:3306/webauthn_test" From 09f19c5dd7aee34f9b6a7822c151efc8971e9538 Mon Sep 17 00:00:00 2001 From: Bart Geesink Date: Tue, 12 Dec 2023 13:00:35 +0100 Subject: [PATCH 4/6] Docker test image: Use zip in stead of tar for the composer archive. This makes sure long filenames can be used --- docker/Dockerfile.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile.test b/docker/Dockerfile.test index 45b17cd4..7c4f303b 100644 --- a/docker/Dockerfile.test +++ b/docker/Dockerfile.test @@ -1,7 +1,7 @@ FROM ghcr.io/openconext/openconext-basecontainers/php82-apache2:latest # Set the default workdir WORKDIR /var/www/html -ADD output.tar /var/www/html/ +ADD output.zip /var/www/html/ # Add the application configuration files RUN cp .env.dist .env RUN cp config/openconext/parameters.yaml.dist config/openconext/parameters.yaml From 7a331c50a99a000e4613c1c6c5dbaa19ec49f5c7 Mon Sep 17 00:00:00 2001 From: Bart Geesink Date: Tue, 12 Dec 2023 13:09:22 +0100 Subject: [PATCH 5/6] Docker: Remove the line to copy .env.dist to .env. No longer needed --- docker/Dockerfile.prod | 1 - docker/Dockerfile.test | 1 - 2 files changed, 2 deletions(-) diff --git a/docker/Dockerfile.prod b/docker/Dockerfile.prod index 4128f740..1c8bd01b 100644 --- a/docker/Dockerfile.prod +++ b/docker/Dockerfile.prod @@ -4,7 +4,6 @@ RUN tar -xvjf /tmp/*.tar.bz2 -C /var/www/html/ && \ rm -rf /tmp/*.tar.bz2 # Add the application configuration files -RUN cp .env.dist .env RUN cp config/openconext/parameters.yaml.dist config/openconext/parameters.yaml # Add the config files for Apache2 diff --git a/docker/Dockerfile.test b/docker/Dockerfile.test index 7c4f303b..79bef840 100644 --- a/docker/Dockerfile.test +++ b/docker/Dockerfile.test @@ -3,7 +3,6 @@ FROM ghcr.io/openconext/openconext-basecontainers/php82-apache2:latest WORKDIR /var/www/html ADD output.zip /var/www/html/ # Add the application configuration files -RUN cp .env.dist .env RUN cp config/openconext/parameters.yaml.dist config/openconext/parameters.yaml # Add the config files for Apache2 RUN rm -rf /etc/apache2/sites-enabled/* From db2538d5ea2c500aa34248a871333f5d12e93215 Mon Sep 17 00:00:00 2001 From: Bart Geesink Date: Tue, 12 Dec 2023 13:55:39 +0100 Subject: [PATCH 6/6] Docker test: Use busybox image to unzip --- docker/Dockerfile.test | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile.test b/docker/Dockerfile.test index 79bef840..61455275 100644 --- a/docker/Dockerfile.test +++ b/docker/Dockerfile.test @@ -1,11 +1,15 @@ +FROM busybox AS unpack +WORKDIR /unpack +COPY output.zip /unpack +RUN unzip /unpack/output.zip + FROM ghcr.io/openconext/openconext-basecontainers/php82-apache2:latest # Set the default workdir WORKDIR /var/www/html -ADD output.zip /var/www/html/ +COPY --from=unpack /unpack/ /var/www/html/ # Add the application configuration files -RUN cp config/openconext/parameters.yaml.dist config/openconext/parameters.yaml -# Add the config files for Apache2 -RUN rm -rf /etc/apache2/sites-enabled/* +RUN cp config/openconext/parameters.yaml.dist config/openconext/parameters.yaml && \ + rm -rf /etc/apache2/sites-enabled/* COPY ./docker/conf/webauthn-apache2.conf /etc/apache2/sites-enabled/webauthn.conf RUN rm -rf /var/www/html/var/cache/prod && \ mkdir -p /var/www/html/var/ && \