Skip to content

Commit

Permalink
split skosmos and vocab loader containers
Browse files Browse the repository at this point in the history
  • Loading branch information
jarno-knaw committed Oct 2, 2024
1 parent ea37e5b commit e717346
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ data/*.ttl
data/*.trig
data/*.config
data/*.yaml
data/*.yaml.bak
12 changes: 2 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM library/php:7.3-apache
FROM library/php:8.1-apache

# set skosmos release version and download link
ARG version=v2.18.1-1.0.0
ARG SKOSMOS_TARGZ_RELEASE_URL=https://github.com/knaw-huc/Skosmos/archive/refs/tags/${version}.tar.gz

# general server setup and locale
RUN apt-get update && \
apt-get -y install gettext locales curl unzip vim git libicu-dev libxslt-dev python3 pip cron && \
apt-get -y install gettext locales curl unzip vim git libicu-dev libxslt-dev && \
for locale in en_GB en_US fi_FI fr_FR sv_SE; do \
echo "${locale}.UTF-8 UTF-8" >> /etc/locale.gen ; \
done && \
Expand All @@ -33,9 +33,6 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local
# Install Skosmos dependencies
RUN /usr/local/bin/composer install --no-dev --no-interaction

COPY requirements.txt /var/www/
# Install python dependencies
RUN /usr/bin/env pip install -r /var/www/requirements.txt

# Configure Skosmos
COPY skosmos-repository.ttl /var/www/
Expand All @@ -45,9 +42,4 @@ COPY ./src /var/www/src
COPY entrypoint.py /var/www/
COPY config-docker-compose.ttl /var/www/html/

# Prepare CRON
COPY crontab /var/www/crontab
COPY entrypoint_cron.sh /var/www/
COPY crontask.sh /var/www/

ENTRYPOINT ["/var/www/entrypoint.sh"]
2 changes: 1 addition & 1 deletion crontab
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SPARQL_ENDPOINT=$SPARQL_ENDPOINT
DATA=$DATA

0 * * * * /var/www/crontask.sh >> /var/log/cron.log 2>&1
0 * * * * /app/crontask.sh >> /var/log/cron.log 2>&1
11 changes: 6 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ services:
- skosmos-configuration:/config
depends_on:
- graphdb
skosmos-cron:
container_name: 'skosmos-cron'
- vocab-loader
vocab-loader:
container_name: 'vocab-loader'
build:
context: .
dockerfile: Dockerfile
dockerfile: loader.Dockerfile
environment:
- SPARQL_ENDPOINT=http://host.docker.internal:7200/repositories/skosmos
- DATA=${DATA:-/data}
Expand All @@ -50,8 +51,8 @@ services:
volumes:
- ./data:/data
- skosmos-configuration:/config
entrypoint:
- /var/www/entrypoint_cron.sh
depends_on:
- graphdb

networks:
skosmos:
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def main() -> None:
if os.path.isfile(f'{data}/config.ttl'):
shutil.copy(f'{data}/config.ttl', '/config/config-docker-compose.ttl')
else:
shutil.copy('/var/www/html/config-docker-compose.ttl', '/config/config-docker-compose.ttl')
shutil.copy('/app/config-docker-compose.ttl', '/config/config-docker-compose.ttl')

if os.path.isfile(f'{data}/config-ext.ttl'):
with open(f'{data}/config-ext.ttl', 'r', encoding='utf-8') as f:
Expand Down
6 changes: 3 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ set -x

ls -al $DATA

/var/www/entrypoint.py

/usr/bin/envsubst < /config/config-docker-compose.ttl > /config/config.ttl
#/var/www/entrypoint.py
#
#/usr/bin/envsubst < /config/config-docker-compose.ttl > /config/config.ttl

ln -s /config/config.ttl /var/www/html/config.ttl
cat /var/www/html/config.ttl
Expand Down
6 changes: 5 additions & 1 deletion entrypoint_cron.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env bash

/usr/bin/envsubst < /var/www/crontab > /etc/cron.d/crontab
/usr/bin/envsubst < /app/crontab > /etc/cron.d/crontab

/app/entrypoint.py

/usr/bin/envsubst < /config/config-docker-compose.ttl > /config/config.ttl

crontab /etc/cron.d/crontab
touch /var/log/cron.log
Expand Down
19 changes: 19 additions & 0 deletions loader.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:3.10

RUN apt-get update && apt-get -y install cron gettext

WORKDIR /app

COPY crontab /app/crontab
COPY entrypoint_cron.sh /app/
COPY config-docker-compose.ttl /app/
COPY skosmos-repository.ttl /app/
COPY crontask.sh /app/

COPY src /app/src
COPY entrypoint.py /app/entrypoint.py

COPY requirements.txt /app/
RUN pip install -r /app/requirements.txt

ENTRYPOINT ["/app/entrypoint_cron.sh"]
2 changes: 1 addition & 1 deletion src/graphdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def setup_graphdb() -> None:
headers = {
'Content-Type': 'text/turtle',
}
with open("/var/www/skosmos-repository.ttl", "rb") as fp:
with open("/app/skosmos-repository.ttl", "rb") as fp:
requests.put(
f"{endpoint}",
headers=headers,
Expand Down

0 comments on commit e717346

Please sign in to comment.