Skip to content

Commit

Permalink
Complete code rewrite
Browse files Browse the repository at this point in the history
* uses acdh-oeaw/arche-diss-cache
  * has response cache
* has tests
* is deployed in a standardized way
  • Loading branch information
zozlak committed Oct 25, 2024
1 parent 5b5f8ff commit e2c564e
Show file tree
Hide file tree
Showing 14 changed files with 706 additions and 245 deletions.
64 changes: 36 additions & 28 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,48 @@
name: deploy on rancher
name: test and deploy
on:
workflow_dispatch: ~
workflow_dispatch:
inputs:
deploy:
type: boolean
description: Deploy if not a release
default: false
push: ~
release:
types: [published]
env:
RANCHER_API_BASE: https://rancher.acdh-dev.oeaw.ac.at/v3
RANCHER_PROJECT: Dissemination services
RANCHER_NAMESPACE: arche-iiifmanifest
jobs:
deploy:
testAndDeploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
#- name: test
# run: |
# composer update
# vendor/bin/phpunit tests
- uses: acdh-oeaw/arche_cicd_start_action@main
with:
phpExtensions: json,yaml,pdo,pdo_sqlite
prepareRepoConfig: true
- name: build docker image
run: |
git reset --hard HEAD
rm -fR vendor
docker build --rm -t "acdhch/$RANCHER_NAMESPACE:latest" --build-arg VARIANT=production --label "buildUrl=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" .
#- name: test image
# run: |
# docker run -d --name "$RANCHER_NAMESPACE" -p 8080:80 "acdhch/$RANCHER_NAMESPACE:latest"
# sleep 1
# some test command
- name: authorize against docker hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: push to docker hub
run: docker push "acdhch/$RANCHER_NAMESPACE:latest"
- name: redeploy on rancher
mkdir build/docroot && cp -R `ls -1 | grep -v ^build` build/docroot/ && cp build/config/arche.yaml build/docroot/config.yaml
docker build --rm -t "acdhch/$RANCHER_NAMESPACE:latest" --build-arg VARIANT=production --label "buildUrl=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" build
- name: test image
run: |
BASE_URL=`curl -s -H "Authorization: Bearer ${{ secrets.RANCHERTOKEN }}" "$RANCHER_API_BASE/projects" | jq -r ".data[] | select(.name == \"$RANCHER_PROJECT\") | .links.workloads"`
curl -i -X POST -H "Authorization: Bearer ${{ secrets.RANCHERTOKEN }}" "$BASE_URL/deployment:$RANCHER_NAMESPACE:$RANCHER_NAMESPACE?action=redeploy"
docker run -d --name "$RANCHER_NAMESPACE" -p 8080:80 "acdhch/$RANCHER_NAMESPACE:latest"
sleep 1
for mode in image images manifest ; do
# collection
curl -f -i "http:127.0.0.1/?mode=$mode&id=https://arche.acdh.oeaw.ac.at/api/585903"
curl -f -i "http:127.0.0.1/?mode=$mode&id=https://arche.acdh.oeaw.ac.at/api/585903"
# resource
curl -f -i "http:127.0.0.1/?mode=$mode&id=https://arche.acdh.oeaw.ac.at/api/600233"
curl -f -i "http:127.0.0.1/?mode=$mode&id=https://arche.acdh.oeaw.ac.at/api/600233"
done
- uses: acdh-oeaw/arche_cicd_finish_action@main
with:
pushAndRedeploy: ${{ github.event_name == 'release' && github.event.action == 'published' || inputs.deploy }}
dockerhubLogin: ${{ secrets.DOCKER_USERNAME }}
dockehubPassword: ${{ secrets.DOCKER_PASSWORD }}
imageName: $RANCHER_NAMESPACE
rancherProject: $RANCHER_PROJECT
rancherNamespace: $RANCHER_NAMESPACE
rancherToken: ${{ secrets.RANCHERTOKEN }}
coverallsToken: ${{ secrets.coverallsToken }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
/composer.lock
/vendor
/nbproject
/.phpunit.cache
/build/docroot

10 changes: 0 additions & 10 deletions Dockerfile

This file was deleted.

14 changes: 14 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM php:8.3-apache
MAINTAINER Mateusz Żółtak <mzoltak@oeaw.ac.at>
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod +x /usr/local/bin/install-php-extensions &&\
install-php-extensions yaml pdo_pgsql @composer &&\
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY * /var/www/html/
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN cd /var/www/html &&\
composer update -o --no-dev &&\
chown -R www-data:www-data /var/www/html
EXPOSE 80
ENTRYPOINT entrypoint.sh

54 changes: 54 additions & 0 deletions build/config/arche.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
dissCacheService:
db: sqlite:/var/www/html/db.sqlite
log:
file: /var/www/html/log
level: debug
ttl:
resource: 3600 # 1 hour
response: 31536000 # 1 year
repoDb:
- archeProd.yaml
- archeCur.yaml
allowedNmsp:
- https://id.acdh.oeaw.ac.at/
- https://arche.acdh.oeaw.ac.at/api/
- https://arche-curation.acdh-dev.oeaw.ac.at/api/
- https://arche-dev.acdh-dev.oeaw.ac.at.at/api/
- https://hdl.handle.net/
metadataMode: setInIndex.php
parentProperty: https://vocabs.acdh.oeaw.ac.at/schema#hasNextItem
resourceProperties:
- https://vocabs.acdh.oeaw.ac.at/schema#hasIdentifier
- https://vocabs.acdh.oeaw.ac.at/schema#hasTitle
- https://vocabs.acdh.oeaw.ac.at/schema#hasNextItem
- https://vocabs.acdh.oeaw.ac.at/schema#isPartOf
- https://vocabs.acdh.oeaw.ac.at/schema#hasFormat
- https://vocabs.acdh.oeaw.ac.at/schema#hasPixelWidth
- https://vocabs.acdh.oeaw.ac.at/schema#hasPixelHeight
relativesProperties:
- https://vocabs.acdh.oeaw.ac.at/schema#hasIdentifier
- https://vocabs.acdh.oeaw.ac.at/schema#hasTitle
- https://vocabs.acdh.oeaw.ac.at/schema#hasNextItem
- https://vocabs.acdh.oeaw.ac.at/schema#isPartOf
- https://vocabs.acdh.oeaw.ac.at/schema#hasFormat
- https://vocabs.acdh.oeaw.ac.at/schema#hasPixelWidth
- https://vocabs.acdh.oeaw.ac.at/schema#hasPixelHeight
iiifManifest:
defaultMode: image
baseUrl: https://arche-iiifmanifest.acdh.oeaw.ac.at/
profile: http://iiif.io/api/image/2/level2.json
iiifServiceBase: https://loris.acdh.oeaw.ac.at/
fetchDimensions: false
schema:
id: https://vocabs.acdh.oeaw.ac.at/schema#hasIdentifier
label: https://vocabs.acdh.oeaw.ac.at/schema#hasTitle
next: https://vocabs.acdh.oeaw.ac.at/schema#hasNextItem
parent: https://vocabs.acdh.oeaw.ac.at/schema#isPartOf
mime: https://vocabs.acdh.oeaw.ac.at/schema#hasFormat
imagePxWidth: https://vocabs.acdh.oeaw.ac.at/schema#hasPixelWidth
imagePxHeight: https://vocabs.acdh.oeaw.ac.at/schema#hasPixelHeight
classes:
collection: https://vocabs.acdh.oeaw.ac.at/schema#Collection
topCollection: https://vocabs.acdh.oeaw.ac.at/schema#TopCollection
namespaces:
id: https://id.acdh.oeaw.ac.at/
7 changes: 7 additions & 0 deletions build/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
echo "$PGPASS" > /var/www/.pgpass &&\
chmod 600 /var/www/.pgpass &&\
chown www-data:www-data /var/www/.pgpass

docker-php-entrypoint apache2-foreground

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"require": {
"php": "^8.1",
"psr/log": "*",
"acdh-oeaw/arche-core": "^5"
"acdh-oeaw/arche-diss-cache": "^0.6",
"zozlak/logging": "^1.0"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit e2c564e

Please sign in to comment.