Skip to content

Commit 08595df

Browse files
committed
Update base images
Add recaptcha support
1 parent 3a2ca81 commit 08595df

File tree

11 files changed

+163
-55
lines changed

11 files changed

+163
-55
lines changed

Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM islandora/nginx:6.0.10@sha256:57f9e680cc7515ba0025c2e5ba5f1f16dc6bb0810810684556805431af5fd962
1+
FROM islandora/nginx:6.2.3@sha256:1e85a1f0a222289a3079d5740ce8156d36c325c1f8477fb96806fa157cfb666b
22

33
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
44

@@ -12,11 +12,11 @@ ARG \
1212
# renovate: datasource=repology depName=alpine_3_22/ghostscript
1313
GHOSTSCRIPT_VERSION=10.05.1-r0 \
1414
# renovate: datasource=repology depName=alpine_3_22/npm
15-
NPM_VERSION=11.4.2-r0 \
15+
NPM_VERSION=11.6.4-r0 \
1616
# renovate: datasource=github-tags depName=ojs packageName=pkp/ojs
1717
OJS_VERSION=3_5_0rc2 \
1818
# renovate: datasource=repology depName=alpine_3_22/php83
19-
PHP_VERSION=8.3.27-r0 \
19+
PHP_VERSION=8.3.29-r0 \
2020
# renovate: datasource=repology depName=alpine_3_22/poppler-utils
2121
POPPLER_VERSION=25.04.0-r0
2222

@@ -28,11 +28,15 @@ RUN apk add --no-cache \
2828
php83-ftp=="${PHP_VERSION}" \
2929
php83-gettext=="${PHP_VERSION}" \
3030
poppler-utils=="${POPPLER_VERSION}" \
31+
patch \
3132
&& cleanup.sh
3233

34+
COPY patches /patches
35+
3336
RUN git clone https://github.com/pkp/ojs.git . \
3437
&& git checkout "${OJS_VERSION}" \
3538
&& git submodule update --init --recursive \
39+
&& for patch in /patches/*.patch; do patch -p1 < "$patch"; done \
3640
&& rm -rf .github tests docs \
3741
&& composer -d lib/pkp install \
3842
&& composer -d plugins/generic/citationStyleLanguage install \

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
DOCKER_IMAGE=ghcr.io/libops/ojs:main
44

55
deps:
6-
docker compose pull
6+
docker compose pull --ignore-buildable
77

88
build: deps
99
docker compose build

docker-compose.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
2+
networks:
3+
default:
24
volumes:
35
mariadb-data: {}
46
ojs-cache: {}
@@ -21,7 +23,7 @@ secrets:
2123

2224
services:
2325
init:
24-
image: islandora/base:6.0.10@sha256:00f16e56a20950f7b85e690b03c1e6e167625236bc77c56f4cd121dafd9ef578
26+
image: islandora/base:6.2.3@sha256:010f7e422ad4563f91335106215a72c7485635b0a1125c651b4e76cb6d7efbd4
2527
restart: no
2628
volumes:
2729
- ./secrets:/secrets:rw
@@ -32,12 +34,16 @@ services:
3234
ojs:
3335
image: ghcr.io/libops/ojs:main
3436
build: .
37+
networks:
38+
- default
3539
ports:
3640
- 80:80
3741
environment:
3842
OJS_OAI_REPOSITORY_ID: ${DOMAIN:-localhost}
3943
OJS_ENABLE_BEACON: 1
4044
OJS_SMTP_SERVER: ${OJS_SMTP_SERVER:-}
45+
OJS_ENABLE_HTTPS: "true"
46+
OJS_BASE_URL: "https://${DOMAIN:-localhost}"
4147
secrets:
4248
- source: DB_ROOT_PASSWORD
4349
- source: OJS_API_KEY_SECRET
@@ -54,7 +60,9 @@ services:
5460
mariadb:
5561
condition: service_started
5662
mariadb:
57-
image: islandora/mariadb:6.0.10@sha256:a89a1152abe0fc3d5de66d071b4391dd8f18e5f4883bfa32a82caf45a46d96da
63+
image: islandora/mariadb:6.2.3@sha256:3c6e7cbed734310f4d9fea7a4f08e7e282ecb1a5e73aec0ab79b4167930380ab
64+
networks:
65+
- default
5866
volumes:
5967
- mariadb-data:/var/lib/mysql:rw
6068
secrets:
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
diff --git a/lib/pkp/classes/task/UpdateRorRegistryDataset.php b/lib/pkp/classes/task/UpdateRorRegistryDataset.php
2+
index 5b1af95424c..a033f250ae6 100644
3+
--- a/lib/pkp/classes/task/UpdateRorRegistryDataset.php
4+
+++ b/lib/pkp/classes/task/UpdateRorRegistryDataset.php
5+
@@ -84,7 +84,7 @@ class UpdateRorRegistryDataset extends ScheduledTask
6+
private string $urlVersions = 'https://zenodo.org/api/communities/ror-data/records?q=&sort=newest';
7+
8+
/** @var string The file contains the following text in the name. */
9+
- private string $csvNameContains = 'ror-data_schema_v2.csv';
10+
+ private string $csvNameContains = 'ror-data.csv';
11+
12+
/** @var string The prefix used for the temporary zip file and the extracted directory. */
13+
private string $prefix = 'TemporaryRorRegistryCache';
14+
@@ -135,7 +135,7 @@ public function executeActions(): bool
15+
}
16+
17+
$pathCsv = $this->getPathCsv($pathZipDir);
18+
- if (empty($pathCsv || !$this->fileManager->fileExists($pathCsv))) {
19+
+ if (empty($pathCsv) || !$this->fileManager->fileExists($pathCsv)) {
20+
return false;
21+
}
22+
23+
@@ -175,7 +175,7 @@ private function getDownloadUrl(): string
24+
}
25+
26+
return '';
27+
- } catch (GuzzleException|Exception $e) {
28+
+ } catch (GuzzleException | Exception $e) {
29+
$this->addExecutionLogEntry(
30+
$e->getMessage(),
31+
ScheduledTaskHelper::SCHEDULED_TASK_MESSAGE_TYPE_ERROR
32+
@@ -210,7 +210,7 @@ private function downloadAndExtract(string $downloadUrl, string $pathZipFile, st
33+
}
34+
35+
return true;
36+
- } catch (GuzzleException|Exception $e) {
37+
+ } catch (GuzzleException | Exception $e) {
38+
$this->addExecutionLogEntry(
39+
$e->getMessage(),
40+
ScheduledTaskHelper::SCHEDULED_TASK_MESSAGE_TYPE_ERROR
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[template]
2+
src = "ojs.conf.tmpl"
3+
dest = "/etc/nginx/shared/ojs.conf"
4+
uid = 0
5+
gid = 0
6+
mode = "0644"
7+
keys = [ "/" ]

rootfs/etc/confd/templates/config.inc.tmpl

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ restful_urls = On
102102
{{- $cleaned := replace $temp "http://" "" -1 -}}
103103

104104
{{- $host := index (split $cleaned "/") 0 -}}
105-
{{- $domain := index (split $host ":") 0 -}}
105+
{{ $domain := index (split $host ":") 0 }}
106106
allowed_hosts = '["localhost", "{{ $domain }}"]'
107107

108108

@@ -431,45 +431,13 @@ page_links = 10
431431
[captcha]
432432

433433
; Whether or not to enable ReCaptcha
434-
recaptcha = off
435-
436-
; Public key for reCaptcha (see http://www.google.com/recaptcha)
437-
recaptcha_public_key = your_public_key
438-
439-
; Private key for reCaptcha (see http://www.google.com/recaptcha)
440-
recaptcha_private_key = your_private_key
441-
442-
; Whether or not to use Captcha on user registration
434+
recaptcha = {{ if getenv "RECAPTCHA_PUBLIC_KEY" }}on{{ else }}off{{ end }}
435+
recaptcha_public_key = {{ getenv "RECAPTCHA_PUBLIC_KEY" }}
436+
recaptcha_private_key = {{ getenv "RECAPTCHA_PRIVATE_KEY" }}
443437
captcha_on_register = on
444-
445-
; Whether or not to use Captcha on user login
446438
captcha_on_login = on
447-
448-
; Validate the hostname in the ReCaptcha response
449439
recaptcha_enforce_hostname = Off
450440

451-
; ALTCHA is a free and open-source alternative to Google's ReCaptcha
452-
; The options below will manage all the required configurations used to
453-
; work with ALTCHA instead of ReCaptcha on system
454-
455-
; Whether or not to enable ALTCHA
456-
altcha = off
457-
458-
; Private key for ALTCHA
459-
altcha_hmackey = 'Example key'
460-
461-
; Whether or not to use ALTCHA on user registration
462-
altcha_on_register = on
463-
464-
; Whether or not to use ALTCHA on user login
465-
altcha_on_login = on
466-
467-
; Whether or not to use ALTCHA on user lost password
468-
altcha_on_lost_password = on
469-
470-
; The quantity of encryption cycles performed by the ALTCHA system
471-
altcha_encrypt_number = 10000
472-
473441
;;;;;;;;;;;;;;;;;;;;;
474442
; External Commands ;
475443
;;;;;;;;;;;;;;;;;;;;;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
root /var/www/ojs;
2+
index index.php;
3+
4+
error_log /dev/stderr;
5+
access_log /dev/stdout combined;
6+
7+
error_log /dev/stderr;
8+
access_log /dev/stdout combined;
9+
10+
# API rewrite with redirect
11+
location ~ ^/api/v1(.*)$ {
12+
return 307 /index.php/api/v1$1;
13+
}
14+
15+
# Main location block
16+
location / {
17+
# Try to serve file directly, otherwise pass to index.php
18+
try_files $uri $uri/ /index.php/$uri?$query_string;
19+
}
20+
21+
# PHP processing
22+
location ~ \.php(/|$) {
23+
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
24+
if (!-f $document_root$fastcgi_script_name) {
25+
return 404;
26+
}
27+
28+
fastcgi_pass unix:/var/run/php-fpm83/php-fpm83.sock;
29+
{{ if eq (getenv "OJS_ENABLE_HTTPS") "true" }}
30+
fastcgi_param HTTPS on;
31+
fastcgi_param HTTP_SCHEME https;
32+
{{ end }}
33+
fastcgi_index index.php;
34+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
35+
fastcgi_param PATH_INFO $fastcgi_path_info;
36+
include fastcgi_params;
37+
}
38+
39+
# Deny access to hidden files
40+
location ~ /\. {
41+
deny all;
42+
}

rootfs/etc/nginx/shared/fpm.conf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Used to validate that PHP-FPM is in a ready state.
2+
# Not accessible outside of the container.
3+
location ~ ^/(status|ping)$ {
4+
access_log off;
5+
allow 127.0.0.1;
6+
allow ::1;
7+
deny all;
8+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
9+
fastcgi_index index.php;
10+
include fastcgi_params;
11+
fastcgi_pass unix:/var/run/php-fpm83/php-fpm83.sock;
12+
}
13+
14+
location = /opcache_stat.php {
15+
access_log off;
16+
allow 127.0.0.1;
17+
allow ::1;
18+
allow 128.180.0.0/16;
19+
deny all;
20+
fastcgi_pass unix:/var/run/php-fpm83/php-fpm83.sock;
21+
fastcgi_index index.php;
22+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
23+
include fastcgi_params;
24+
}

rootfs/etc/s6-overlay/scripts/ojs-setup.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,29 @@ function install_ojs {
5959
echo "OJS Installation Complete!"
6060
echo "=========================================="
6161
rm /tmp/ojs-install.log
62+
set_ojs_installed
6263
else
6364
echo "=========================================="
6465
echo "OJS Installation Failed!"
6566
echo "=========================================="
6667
cat /tmp/ojs-install.log
6768
echo "=========================================="
6869
fi
69-
set_ojs_installed
7070
}
7171

7272
function main {
73-
mysql_create_database
74-
7573
# wait for nginx
7674
if ! timeout 300 wait-for-open-port.sh localhost 80; then
7775
echo "Could not connect to nginx at localhost:80"
7876
exit 1
7977
fi
80-
81-
if ! check_ojs_installed; then
82-
install_ojs &
83-
echo "OJS installation started."
84-
else
85-
echo "OJS is already installed. Skipping installation."
86-
set_ojs_installed
78+
if [ "${DB_HOST}" = "mariadb" ]; then
79+
mysql_create_database
80+
install_ojs &
81+
echo "OJS installation started."
82+
exit 0
8783
fi
84+
85+
set_ojs_installed
8886
}
8987
main

scripts/generate-secrets.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,16 @@ yq -r '.secrets[].file' docker-compose.yaml | uniq | while read -r SECRET; do
1616
(grep -ao "${CHARACTERS}" < /dev/urandom || true) | head "-${LENGTH}" | tr -d '\n' > "${SECRET}"
1717
fi
1818
done
19+
20+
if [ -f docker-compose.override.yaml ]; then
21+
yq -r '.secrets[].file' docker-compose.override.yaml | uniq | while read -r SECRET; do
22+
if [ ! -f "${SECRET}" ]; then
23+
echo "Creating: ${SECRET}" >&2
24+
DIR=$(dirname "${SECRET}")
25+
if [ ! -d "${DIR}" ]; then
26+
mkdir -p "$DIR"
27+
fi
28+
(grep -ao "${CHARACTERS}" < /dev/urandom || true) | head "-${LENGTH}" | tr -d '\n' > "${SECRET}"
29+
fi
30+
done
31+
fi

0 commit comments

Comments
 (0)