Skip to content

Commit d907ba1

Browse files
authored
Merge pull request #27 from andersinno/ansible
Add Ansible playbooks for deployment
2 parents 1104cc2 + 7318f7e commit d907ba1

12 files changed

+175
-128
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
[submodule "passari-web-ui"]
88
path = passari-web-ui
99
url = ../passari-web-ui
10+
[submodule "ansible"]
11+
path = ansible
12+
url = ../passari-ansible

Dockerfile

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,9 @@ RUN --mount=type=cache,sharing=locked,target=/var/cache/dnf \
6262
# Install pipx
6363
RUN pip install --root-user-action=ignore pipx
6464

65-
66-
###############################################################################
67-
FROM base AS wheels
65+
# Install packages needed to build Python dependencies
6866
RUN --mount=type=cache,sharing=locked,target=/var/cache/dnf \
6967
dnf install -y python3.12-devel swig # For building M2Crypto
70-
COPY requirements-siptools.txt /
71-
RUN mkdir wheels
72-
WORKDIR /wheels
73-
RUN pip wheel -r ../requirements-siptools.txt
7468

7569
###############################################################################
7670
FROM base AS app
@@ -87,12 +81,6 @@ RUN pipx install pip-tools
8781
# Set a working directory for the application
8882
WORKDIR /app
8983

90-
# Install siptools
91-
COPY --from=wheels /wheels /siptools-wheels
92-
COPY requirements-siptools.txt .
93-
RUN --mount=type=cache,sharing=locked,uid=1000,target=/home/appuser/.cache/pip \
94-
pip install --user --no-index -f /siptools-wheels -r requirements-siptools.txt
95-
9684
# Copy the sources
9785
#
9886
# Note: The dirs are intentionally created as root. There should be no

Makefile

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
.PHONY: up down start stop restart logs ps build requirements
1+
.PHONY: \
2+
up down start stop restart logs ps build \
3+
clean-wheels wheels \
4+
ansible-update ansible-wheel-update \
5+
ansible-requirements requirements
6+
7+
ANSIBLE_DESTDIR ?= ansible/roles/passari_packages/files
28

39
up:
410
docker-compose up
@@ -24,7 +30,28 @@ ps:
2430
build:
2531
docker-compose build
2632

27-
requirements: requirements.txt requirements-siptools.txt requirements-dev.txt
33+
clean-wheels:
34+
rm -fr wheels
35+
36+
wheels:
37+
./build-wheels
38+
39+
ansible-update: clean-wheels wheels ansible-wheel-update ansible-requirements
40+
41+
ansible-wheel-update:
42+
rm -fr $(ANSIBLE_DESTDIR)/wheels
43+
mkdir -p $(ANSIBLE_DESTDIR)/wheels
44+
cp -vf wheels/*.whl $(ANSIBLE_DESTDIR)/wheels/
45+
46+
ansible-requirements: requirements.txt
47+
rm -f $(ANSIBLE_DESTDIR)/requirements*.txt
48+
cp -vf requirements.txt $(ANSIBLE_DESTDIR)/
49+
./compile-requirements --hashes \
50+
$(ANSIBLE_DESTDIR)/requirements-workflow.in
51+
./compile-requirements --hashes \
52+
$(ANSIBLE_DESTDIR)/requirements-web-ui.in
53+
54+
requirements: requirements.txt requirements-dev.txt
2855

2956
%.txt: %.in
3057
./compile-requirements $<

ansible

Submodule ansible added at 92e1bce

build-wheels

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
# Build Passari wheels
3+
4+
set -e
5+
6+
pip install build
7+
8+
mkdir -p wheels
9+
10+
for i in passari passari-workflow passari-web-ui; do
11+
# The SOURCE_DATE_EPOCH variable makes the dates inside the wheel
12+
# ZIP files reproducible so that the whl files are reproducible
13+
SOURCE_DATE_EPOCH=0 python -m build --outdir ./wheels --wheel ./$i
14+
done

compile-requirements

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
#!/bin/bash
22
set -e
3-
infile=${1:?Give a name of requirements*.in file as first argument}
4-
txtfile=${infile%.in}.txt
3+
4+
called_as=("$0" "$@")
5+
pip_compile_args=(--quiet --strip-extras --no-emit-find-links --allow-unsafe)
6+
7+
while [[ $1 == -* ]]; do
8+
case "$1" in
9+
-H|--hashes)
10+
pip_compile_args+=(--generate-hashes --reuse-hashes)
11+
;;
12+
*)
13+
echo "Unknown option: $1" >&2
14+
exit 1
15+
;;
16+
esac
17+
shift
18+
done
19+
20+
infile_path=${1:?Give a name of requirements*.in file as an argument}
21+
txtfile_path=${infile_path%.in}.txt
22+
23+
# Change to the dir of the infile_path and use basenames for the files
24+
cd "$(dirname "$infile_path")"
25+
infile=${infile_path##*/}
26+
txtfile=${txtfile_path##*/}
527

628
# If pip-compile is in PATH use it, otherwise run through pipx
729
pip_compile=(pip-compile)
@@ -26,9 +48,9 @@ if grep -q "^-c" "$infile"; then
2648
done
2749
fi
2850

29-
echo -n "Generating $txtfile from $infile..."
51+
echo -n "Generating $txtfile_path from $infile_path..."
3052

31-
"${pip_compile[@]}" --quiet --strip-extras "$infile"
53+
"${pip_compile[@]}" "${pip_compile_args[@]}" "$infile"
3254

3355
# Post-process the output file with sed:
3456
#
@@ -38,7 +60,7 @@ cwd_url="\(file://\)\?$PWD\(/\.\)\?"
3860
sed -i "
3961
s%^.* @ $cwd_url%.%;
4062
s%$cwd_url%.%g;
41-
s|^\(# *\)pip-compile.*|\1$0${1:+ }$*|;
63+
s|^\(# *\)pip-compile.*|\1${called_as[*]}|;
4264
" "$txtfile"
4365

4466
echo "done"

requirements-dev.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ passlib==1.7.4
216216
# -c ./requirements.txt.constraints
217217
# flask-security-too
218218
pillow==11.1.0
219-
# via passari
219+
# via
220+
# -c ./requirements.txt.constraints
221+
# passari
220222
pluggy==1.5.0
221223
# via pytest
222224
propcache==0.2.1
@@ -337,4 +339,7 @@ yarl==1.18.3
337339
# aiohttp
338340

339341
# The following packages are considered to be unsafe in a requirements file:
340-
# setuptools
342+
setuptools==75.8.1
343+
# via
344+
# -c ./requirements.txt.constraints
345+
# sftpserver

requirements-siptools.in

Lines changed: 0 additions & 2 deletions
This file was deleted.

requirements-siptools.txt

Lines changed: 0 additions & 86 deletions
This file was deleted.

requirements.in

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,25 @@
22
-e ./passari-workflow
33
-e ./passari-web-ui
44

5-
-c ./siptools-deps.txt
5+
# Siptools requirements
6+
#
7+
# These must be listed here, because passari uses dpres-siptools-ng and
8+
# dpres-mets-builder, and these are required them. If those packages
9+
# are pushed to PyPI with proper requirements then this entire section
10+
# can be removed from here.
11+
dpres-siptools-ng @ https://github.com/andersinno/dpres-siptools-ng/releases/download/v1.0.0/dpres_siptools_ng-1.0.0-py3-none-any.whl
12+
dpres-mets-builder @ https://github.com/andersinno/dpres-mets-builder/releases/download/v1.0.0/dpres_mets_builder-1.0.0-py3-none-any.whl
13+
xml-helpers @ https://github.com/Digital-Preservation-Finland/xml-helpers/archive/refs/tags/v0.18.zip
14+
mets @ https://github.com/Digital-Preservation-Finland/mets/archive/refs/tags/v0.22.zip
15+
premis @ https://github.com/Digital-Preservation-Finland/premis/archive/refs/tags/v0.30.zip
16+
dpres-signature @ https://github.com/Digital-Preservation-Finland/dpres-signature/archive/refs/tags/v0.18.zip
17+
nisomix @ https://github.com/Digital-Preservation-Finland/nisomix/archive/refs/tags/v0.17.zip
18+
addml @ https://github.com/Digital-Preservation-Finland/addml/archive/refs/tags/v0.14.zip
19+
audiomd @ https://github.com/Digital-Preservation-Finland/audiomd/archive/refs/tags/v0.13.zip
20+
videomd @ https://github.com/Digital-Preservation-Finland/videomd/archive/refs/tags/v0.12.zip
21+
ffmpeg-python @ https://github.com/Digital-Preservation-Finland/ffmpeg-python/archive/refs/tags/0.2.0.zip
22+
opf-fido @ https://github.com/Digital-Preservation-Finland/fido/archive/refs/tags/v1.4.0-dpres5.zip
23+
file-scraper @ https://github.com/Digital-Preservation-Finland/file-scraper/archive/refs/tags/v0.78.zip
624

725
# Limit upper version of some requirements, because the code doesn't
826
# work with the newest versions (yet)
@@ -13,12 +31,19 @@ sqlalchemy<2
1331
rq-dashboard<0.6.2
1432
werkzeug<3
1533

34+
# Install premis, because dpres-mets-builder requires it
35+
premis
36+
1637
# Install pytz, because flask-security-too 3.4 requires flask-babelex
1738
# and flask-babelex uses pytz even though it doesn't list it as a
1839
# requirement. NOTE: Newer flask-security-too (e.g. 5.5.2) doesn't seem
1940
# to require flask-babelex and pytz might become unnecessary.
2041
pytz
2142

43+
# Install setuptools, because flask-security-too imports pkg_resources
44+
# which is provided by setuptools. Note: pkg_resources is deprecated.
45+
setuptools
46+
2247
# Pin psycopg2 to the version which is shipped by AlmaLinux 9 (from
2348
# package python3.12-psycopg2)
2449
psycopg2==2.9.6

0 commit comments

Comments
 (0)