Piwigo automated sync and its container

This commit is contained in:
2020-10-10 19:12:46 +02:00
parent cb2df87e7a
commit 6cc343384e
4 changed files with 191 additions and 0 deletions

BIN
apps/piwigo/.Dockerfile.swp Normal file

Binary file not shown.

9
apps/piwigo/Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
FROM debian:stable-slim
#RUN echo 'Acquire::http::proxy "http://172.23.255.1:3142";' >/etc/apt/apt.conf.d/proxy
RUN apt-get update && apt-get install -y \
libwww-perl && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/apt/* /tmp/* /var/tmp/*
COPY remote_sync.pl /

123
apps/piwigo/deployment.yaml Normal file
View File

@@ -0,0 +1,123 @@
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: piwigo
spec:
selector:
matchLabels:
app: piwigo
strategy:
type: Recreate
template:
metadata:
labels:
app: piwigo
spec:
containers:
- image: linuxserver/piwigo
name: piwigo
imagePullPolicy: IfNotPresent
env:
# Use secret in real usage
- name: TZ
value: Europe/Berlin
livenessProbe:
failureThreshold: 10
httpGet:
path: /index.php
port: http
scheme: HTTP
initialDelaySeconds: 60
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
ports:
- containerPort: 80
name: http
- containerPort: 443
name: https
volumeMounts:
- name: piwigo-persistent-storage
mountPath: /config/www/gallery/galleries
- name: piwigo-config
mountPath: /config
volumes:
- name: piwigo-persistent-storage
persistentVolumeClaim:
claimName: piwigo-pv-claim
- name: piwigo-config
persistentVolumeClaim:
claimName: piwigo-config
---
apiVersion: v1
kind: Service
metadata:
name: piwigo
spec:
ports:
- name: http
port: 80
- name: https
port: 443
selector:
app: piwigo
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: piwigo
spec:
rules:
- host: foto.lan
http:
paths:
- backend:
serviceName: piwigo
servicePort: http
---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: piwigo-quicksync
spec:
schedule: "*/10 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: piwigo-quicksync
image: docker-registry.lan/piwigo-sync:arm64
imagePullPolicy: Always
args:
- /remote_sync.pl
- --base_url=http://piwigo.default.svc.cluster.local/
- --username=api
- --password='{D8G~y:<tPq::/(Yt.'
restartPolicy: OnFailure
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: piwigo-pv-claim
spec:
storageClassName: nfs-ssd
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 60Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: piwigo-config
spec:
storageClassName: nfs-ssd
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi

59
apps/piwigo/remote_sync.pl Executable file
View File

@@ -0,0 +1,59 @@
#!/usr/bin/perl
# perl remote_sync.pl --base_url=http://localhost/piwigo/dev/branches/2.0 --username=plg --password=plg
use strict;
use warnings;
use LWP::UserAgent;
use Getopt::Long;
my %opt = ();
GetOptions(
\%opt,
qw/
base_url=s
username=s
password=s
/
);
our $ua = LWP::UserAgent->new;
$ua->agent('Mozilla/remote_sync.pl');
$ua->cookie_jar({});
$ua->default_headers->authorization_basic(
$opt{username},
$opt{password}
);
my $form = {
method => 'pwg.session.login',
username => $opt{username},
password => $opt{password},
};
my $result = $ua->post(
$opt{base_url}.'/ws.php?format=json',
$form
);
# perform the synchronization
$form = {
'sync' => 'files',
'display_info' => 1,
'add_to_caddie' => 1,
'privacy_level' => 0,
'sync_meta' => 1, # remove this parameter, turning to 0 is not enough
'simulate' => 0,
'subcats-included' => 1,
'submit' => 1,
};
$result = $ua->post(
$opt{base_url}.'/admin.php?page=site_update&site=1',
$form
);
use Data::Dumper;
print Dumper($result);