Skip to content

Commit

Permalink
Redo add config variables on build
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-arthur committed Jul 26, 2024
1 parent 822e0e2 commit 70571c6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 13 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ RUN set -xe \
&& NODE_OPTIONS=--openssl-legacy-provider npm run build \
# Create directories
&& mkdir -p /var/www/files /run/apache2 \
&& cp config.TEMPLATE.inc.php config.inc.php \
&& if test -f /home/config.inc.php; then \
cp /home/config.inc.php config.inc.php; \
else cp config.TEMPLATE.inc.php config.inc.php; \
fi\
&& chown -R apache:apache /var/www/* \
# Prepare freefont for captcha
&& ln -s /usr/share/fonts/TTF/FreeSerif.ttf /usr/share/fonts/FreeSerif.ttf \
Expand Down
56 changes: 44 additions & 12 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,54 @@ chmod +x /usr/local/bin/ojs-variable
# Temporary fix for error in ojs-variable (fixed here https://gitlab.com/pkp-org/docker/ojs/-/commit/f4f33f370e7c765b599868f0ca701898c875b47f, but not in stable-3_4_0 branch)
sed -i 's:/tmp/ojs.config.inc.php:/tmp/config.inc.php:' /usr/local/bin/ojs-variable

# Set config variables using env variables https://github.com/pkp/ojs/blob/main/config.TEMPLATE.inc.php
echo "Updating OJS config based on env variables..."

if ! test -f /home/files; then
mkdir /home/files;
chmod 755 /home/files;
chown apache /home/files;
chgrp apache /home/files;
fi


declare -A configVariable
configVariable["installed"]="On"
configVariable["base_url"]=$WEBSITE_HOSTNAME
configVariable["restful_urls"]="On"
configVariable["host"]=$OJS_DB_HOST
configVariable["username"]=$OJS_DB_USER
configVariable["password"]=$OJS_DB_PASSWORD
configVariable["name"]=$OJS_DB_NAME
configVariable["locale"]="en_US"
configVariable["time_zone"]=$TIME_ZONE
if ! test -f /home/config.inc.php; then
# Set config variables using env variables https://github.com/pkp/ojs/blob/main/config.TEMPLATE.inc.php
echo "Updating OJS config based on env variables..."
# General
configVariable["installed"]="On"
configVariable["base_url"]=$WEBSITE_HOSTNAME
configVariable["time_zone"]=$TIME_ZONE
configVariable["restful_urls"]="On"
# Database
configVariable["host"]=$OJS_DB_HOST
configVariable["username"]=$OJS_DB_USER
configVariable["password"]=$OJS_DB_PASSWORD
configVariable["name"]=$OJS_DB_NAME
# Locatlization
configVariable["locale"]="en"
# Files
configVariable["files_dir"]="/home/files"
# Security
configVariable["force_ssl"]="On"
configVariable["salt"]=$SALT
configVariable["api_key_secret"]=$API_KEY_SECRET
# Email
configVariable["smtp_server"]="smtp-relay.gmail.com"
configVariable["smtp_port"]="587"
configVariable["smtp_auth"]="tls"
configVariable["smtp_username"]=$SMTP_USERNAME
configVariable["smtp_password"]=$SMTP_PASSWORD
configVariable["allow_envelope_sender"]="On"
configVariable["default_envelope_sender"]="[email protected]"
# OAI
configVariable["oai"]="Off"
fi

for key in "${!configVariable[@]}"; do
ojs-variable $key ${configVariable[$key]}
done

chmod +x /usr/local/bin/ojs-start
ojs-start
ojs-start
# Note: Fresh installs are async, so /home/config.inc.php may not be correct
cp config.inc.php /home/config.inc.php

0 comments on commit 70571c6

Please sign in to comment.