Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support reverse proxies + CI integration test #43

Merged
merged 4 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ CONSISTENCY=delegated
ISLANDORA_REPOSITORY=islandora

# The version of the isle-buildkit images to use.
ISLANDORA_TAG=3.2.4
ISLANDORA_TAG=3.2.5

# The Docker image repository, to push/pull custom images from.
# islandora.io redirects to localhost.
Expand All @@ -42,6 +42,19 @@ TAG=local
# The domain at which your production site is hosted.
DOMAIN=islandora.dev

# Set to "on" if your ISLE docker deployment is behind a reverse proxy
REVERSE_PROXY=off

# This list should be all the IPs in front of your Drupal docker container
# this is used to pass the original client IP to the drupal container so
# drupal/php is aware of who sent the original request
# if you're not behind a reverse proxy, you probably do not need to edit these IPs
# if you are behind a reverse proxy, most likely you can just replace FRONTEND_IP_1
# with the IP address used on your front end // reverse proxy domain
FRONTEND_IP_1=127.0.0.1/32
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shame I didn't see the changes for this go into build kit, we could have made it into a single variable that was delimited by comma. That way we could support any number of IP's.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're welcome to open a new PR to simplify. FWIW I did it this way because the values are used in two places. One comma delimited used in docker compose(traefik), the other is multiple directives in buildkit // nginx directive.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the bits on nginx we can iterate on a list using confd, let's not worry about it for now though. If someone wants to use more than 3 ip's in the future we can sort it then.

FRONTEND_IP_2=172.0.0.0/8
FRONTEND_IP_3=192.168.0.0/16

# The email to use for admin users and Lets Encrypt.
[email protected]

Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Run tests
on:
pull_request:
workflow_dispatch:
inputs:
buildkit-tag:
description: "The isle-buildkit tag to pull for the fleet of docker containers"
required: true
type: string
default: 'main'
starter-site-ref:
description: "The islandora-starter-site ref to checkout (heads/BRANCH-NAME or tags/TAG-NAME)"
required: true
type: string
default: 'heads/main'
schedule:
- cron: '15 11 * * *'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why test with cron? Do we expect this to fail without changes to the code base?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah to catch issues with buildkit+starter that are otherwise never discovered

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought being: this is sort of the last mile before someone installs a site, so if some issue does arise between buildkit and starter site this feels like the best place to discover it since it's the place those two repos converge

jobs:
build:
runs-on: ubuntu-latest
env:
ISLANDORA_TAG: "${{ github.event.inputs.buildkit-tag }}"
ISLANDORA_STARTER_REF: "${{ github.event.inputs.starter-site-ref }}"
steps:
- uses: actions/checkout@v4

- run: shellcheck tests/*.sh

- name: install mkcert
run: |-
curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64"
chmod +x mkcert-v*-linux-amd64
sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert

- name: start islandora-starter-site
run: ./tests/init-template-starter.sh

- name: Notify Slack on nightly test failure
if: failure() && github.event_name == 'schedule'
run: |-
curl -s -o /dev/null -XPOST $SLACK_WEBHOOK_URL -d '{
"text": "🚨 Scheduled job failed! Click to view the run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
}'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ services:
DRUPAL_DEFAULT_MATOMO_URL: "https://${DOMAIN}/matomo/"
DRUPAL_DEFAULT_SITE_URL: "${DOMAIN}"
DRUPAL_DRUSH_URI: "https://${DOMAIN}"
NGINX_REAL_IP_RECURSIVE: ${REVERSE_PROXY}
NGINX_SET_REAL_IP_FROM: ${FRONTEND_IP_1}
NGINX_SET_REAL_IP_FROM2: ${FRONTEND_IP_2}
NGINX_SET_REAL_IP_FROM3: ${FRONTEND_IP_3}
labels:
<<: [*traefik-enable, *traefik-https-redirect-middleware, *traefik-drupal-labels]
traefik.http.routers.drupal_http.rule: &traefik-host-drupal-prod Host(`${DOMAIN}`)
Expand Down Expand Up @@ -663,6 +667,8 @@ services:
--api.debug=false
--entryPoints.http.address=:80
--entryPoints.https.address=:443
--entryPoints.http.forwardedHeaders.trustedIPs=${FRONTEND_IP_1},${FRONTEND_IP_2},${FRONTEND_IP_3}
--entryPoints.https.forwardedHeaders.trustedIPs=${FRONTEND_IP_1},${FRONTEND_IP_2},${FRONTEND_IP_3}
--entrypoints.https.http.tls.certResolver=resolver
--providers.file.filename=/etc/traefik/tls.yml
--providers.docker
Expand Down
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function initialize_from_site_template {
echo "Initializing from site template..."
ref=$(choose_ref "${repo}")
curl -L "${repo}/archive/${ref}.tar.gz" | tar -xz --strip-components=1
rm -fr .github setup.sh
rm -fr .github setup.sh tests
git add .
git commit -am "First commit, added isle-site-template."
}
Expand Down
25 changes: 25 additions & 0 deletions tests/init-template-starter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -eou pipefail

if [ ! -v ISLANDORA_STARTER_REF ] || [ "$ISLANDORA_STARTER_REF" = "" ]; then
ISLANDORA_STARTER_REF=heads/main
fi

if [ ! -v ISLANDORA_TAG ] || [ "$ISLANDORA_TAG" = "" ]; then
ISLANDORA_TAG=main
fi

mv drupal/rootfs/var/www/drupal/assets/patches/default_settings.txt .

curl -L "https://github.com/Islandora-Devops/islandora-starter-site/archive/refs/${ISLANDORA_STARTER_REF}.tar.gz" \
| tar --strip-components=1 -C drupal/rootfs/var/www/drupal -xz

mv default_settings.txt drupal/rootfs/var/www/drupal/assets/patches/default_settings.txt

./generate-certs.sh
./generate-secrets.sh

docker compose --profile dev up -d

./tests/ping.sh
18 changes: 18 additions & 0 deletions tests/ping.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

COUNTER=0
while true; do
HTTP_STATUS=$(curl -w '%{http_code}' -o /dev/null -s https://islandora.dev/)
echo "Ping returned http status ${HTTP_STATUS}, exit code $?"
if [ "${HTTP_STATUS}" -eq 200 ]; then
echo "We're live 🚀"
exit 0
fi

((COUNTER++))
if [ "${COUNTER}" -eq 50 ]; then
echo "Failed to come online after 4m"
exit 1
fi
sleep 5;
done