mirror of
https://github.com/ggogel/seafile-containerized.git
synced 2024-11-16 09:01:38 +00:00
Merge branch 'lifecycle-management'
This commit is contained in:
commit
0b63fe2fca
|
@ -10,12 +10,17 @@ services:
|
|||
- TIME_ZONE=Europe/Berlin
|
||||
- HTTPS=false
|
||||
- SEAFILE_URL=localhost
|
||||
depends_on:
|
||||
- db
|
||||
- memcached
|
||||
- seafile-caddy
|
||||
networks:
|
||||
- seafile-net
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-z", "localhost", "8082"]
|
||||
interval: 10s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
restart: unless-stopped
|
||||
|
||||
seahub:
|
||||
build: ../seahub/.
|
||||
|
@ -26,22 +31,23 @@ services:
|
|||
environment:
|
||||
- SEAFILE_ADMIN_EMAIL=me@example.com
|
||||
- SEAFILE_ADMIN_PASSWORD=asecret
|
||||
depends_on:
|
||||
- seafile-server
|
||||
- seafile-caddy
|
||||
- seahub-media
|
||||
networks:
|
||||
- seafile-net
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
seafile-server:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
|
||||
seahub-media:
|
||||
build: ../seahub-media/.
|
||||
volumes:
|
||||
- seahub-avatars:/usr/share/caddy/media/avatars
|
||||
- seahub-custom:/usr/share/caddy/media/custom
|
||||
depends_on:
|
||||
- seafile-caddy
|
||||
networks:
|
||||
- seafile-net
|
||||
restart: unless-stopped
|
||||
|
||||
db:
|
||||
image: mariadb:10.11.7
|
||||
|
@ -53,20 +59,28 @@ services:
|
|||
- seafile-mariadb:/var/lib/mysql
|
||||
networks:
|
||||
- seafile-net
|
||||
healthcheck:
|
||||
test: ["CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized"]
|
||||
interval: 10s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
restart: unless-stopped
|
||||
|
||||
memcached:
|
||||
image: memcached:1.6.23
|
||||
entrypoint: memcached -m 1024
|
||||
networks:
|
||||
- seafile-net
|
||||
restart: unless-stopped
|
||||
|
||||
seafile-caddy:
|
||||
build: ../seafile-caddy/.
|
||||
ports:
|
||||
- "80:80"
|
||||
- "8080:80"
|
||||
networks:
|
||||
- seafile-net
|
||||
- default
|
||||
restart: unless-stopped
|
||||
|
||||
networks:
|
||||
seafile-net:
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# This is a compose file with additional fields for the tool kompose.
|
||||
# Generate Kubernetes manifests with the following command:
|
||||
# kompose convert --with-kompose-annotation=false -o k8s -f compose/docker-compose-kompose.yml
|
||||
version: '3.8'
|
||||
services:
|
||||
seafile-server:
|
||||
|
@ -10,10 +13,6 @@ services:
|
|||
- TIME_ZONE=Europe/Berlin
|
||||
- HTTPS=true
|
||||
- SEAFILE_URL=seafile.mydomain.com # Mandatory on first deployment!
|
||||
depends_on:
|
||||
- db
|
||||
- memcached
|
||||
- seafile-caddy
|
||||
networks:
|
||||
- seafile-net
|
||||
expose:
|
||||
|
@ -24,6 +23,10 @@ services:
|
|||
labels:
|
||||
kompose.volume.size: 1Gi
|
||||
kompose.service.expose.storage-class-name: default
|
||||
kompose.service.healthcheck.readiness.tcp_port: 8082
|
||||
kompose.service.healthcheck.readiness.interval: 10s
|
||||
kompose.service.healthcheck.readiness.timeout: 10s
|
||||
restart: always
|
||||
|
||||
seahub:
|
||||
image: ggogel/seahub:11.0.4
|
||||
|
@ -34,22 +37,17 @@ services:
|
|||
environment:
|
||||
- SEAFILE_ADMIN_EMAIL=me@example.com
|
||||
- SEAFILE_ADMIN_PASSWORD=asecret
|
||||
depends_on:
|
||||
- seafile-server
|
||||
- seafile-caddy
|
||||
- seahub-media
|
||||
networks:
|
||||
- seafile-net
|
||||
expose:
|
||||
- 8000
|
||||
restart: always
|
||||
|
||||
seahub-media:
|
||||
image: ggogel/seahub-media:11.0.4
|
||||
volumes:
|
||||
- seahub-avatars:/usr/share/caddy/media/avatars
|
||||
- seahub-custom:/usr/share/caddy/media/custom
|
||||
depends_on:
|
||||
- seafile-caddy
|
||||
networks:
|
||||
- seafile-net
|
||||
expose:
|
||||
|
@ -57,6 +55,7 @@ services:
|
|||
labels:
|
||||
kompose.volume.size: 100Mi
|
||||
kompose.service.expose.storage-class-name: default
|
||||
restart: always
|
||||
|
||||
db:
|
||||
image: mariadb:10.11.7
|
||||
|
@ -73,6 +72,11 @@ services:
|
|||
labels:
|
||||
kompose.volume.size: 1Gi
|
||||
kompose.service.expose.storage-class-name: default
|
||||
kompose.service.healthcheck.readiness.test: "healthcheck.sh --su-mysql --connect --innodb_initialized"
|
||||
kompose.service.healthcheck.readiness.interval: 10s
|
||||
kompose.service.healthcheck.readiness.timeout: 10s
|
||||
kompose.service.healthcheck.readiness.retries: 3
|
||||
restart: always
|
||||
|
||||
memcached:
|
||||
image: memcached:1.6.23
|
||||
|
@ -81,22 +85,7 @@ services:
|
|||
- seafile-net
|
||||
expose:
|
||||
- 11211
|
||||
|
||||
seafile-caddy:
|
||||
image: ggogel/seafile-caddy:2.7.6
|
||||
networks:
|
||||
- seafile-net
|
||||
- default
|
||||
labels:
|
||||
kompose.service.expose: localhost
|
||||
kompose.service.expose.ingress-class-name: nginx
|
||||
nginx.ingress.kubernetes.io/proxy-body-size: 0
|
||||
nginx.ingress.kubernetes.io/proxy-connect-timeout: 36000
|
||||
nginx.ingress.kubernetes.io/proxy-read-timeout: 36000
|
||||
nginx.ingress.kubernetes.io/proxy-send-timeout: 36000
|
||||
nginx.ingress.kubernetes.io/send-timeout: 36000
|
||||
expose:
|
||||
- 80
|
||||
restart: always
|
||||
|
||||
networks:
|
||||
seafile-net:
|
||||
|
|
|
@ -3,45 +3,51 @@ services:
|
|||
seafile-server:
|
||||
image: ggogel/seafile-server:11.0.4
|
||||
volumes:
|
||||
- seafile-data:/shared
|
||||
- seafile-data:/shared
|
||||
environment:
|
||||
- DB_HOST=db
|
||||
- DB_ROOT_PASSWD=db_dev
|
||||
- TIME_ZONE=Europe/Berlin
|
||||
- HTTPS=true
|
||||
- SEAFILE_URL=seafile.mydomain.com # Mandatory on first deployment!
|
||||
depends_on:
|
||||
- db
|
||||
- memcached
|
||||
- seafile-caddy
|
||||
networks:
|
||||
- seafile-net
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-z", "localhost", "8082"]
|
||||
interval: 10s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
restart: unless-stopped
|
||||
|
||||
seahub:
|
||||
image: ggogel/seahub:11.0.4
|
||||
volumes:
|
||||
- seafile-data:/shared
|
||||
- seahub-avatars:/shared/seafile/seahub-data/avatars
|
||||
- seahub-custom:/shared/seafile/seahub-data/custom
|
||||
- seahub-custom:/shared/seafile/seahub-data/custom
|
||||
environment:
|
||||
- SEAFILE_ADMIN_EMAIL=me@example.com
|
||||
- SEAFILE_ADMIN_PASSWORD=asecret
|
||||
depends_on:
|
||||
- seafile-server
|
||||
- seafile-caddy
|
||||
- seahub-media
|
||||
networks:
|
||||
- seafile-net
|
||||
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
seafile-server:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
|
||||
seahub-media:
|
||||
image: ggogel/seahub-media:11.0.4
|
||||
volumes:
|
||||
- seahub-avatars:/usr/share/caddy/media/avatars
|
||||
- seahub-custom:/usr/share/caddy/media/custom
|
||||
depends_on:
|
||||
- seafile-caddy
|
||||
- seahub-avatars:/usr/share/caddy/media/avatars
|
||||
- seahub-custom:/usr/share/caddy/media/custom
|
||||
networks:
|
||||
- seafile-net
|
||||
restart: unless-stopped
|
||||
|
||||
db:
|
||||
image: mariadb:10.11.7
|
||||
|
@ -53,12 +59,19 @@ services:
|
|||
- seafile-mariadb:/var/lib/mysql
|
||||
networks:
|
||||
- seafile-net
|
||||
healthcheck:
|
||||
test: ["CMD", "healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized"]
|
||||
interval: 10s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
restart: unless-stopped
|
||||
|
||||
memcached:
|
||||
image: memcached:1.6.23
|
||||
entrypoint: memcached -m 1024
|
||||
networks:
|
||||
- seafile-net
|
||||
restart: unless-stopped
|
||||
|
||||
seafile-caddy:
|
||||
image: ggogel/seafile-caddy:2.7.6
|
||||
|
@ -67,6 +80,7 @@ services:
|
|||
networks:
|
||||
- seafile-net
|
||||
- default
|
||||
restart: unless-stopped
|
||||
|
||||
networks:
|
||||
seafile-net:
|
||||
|
|
|
@ -3,6 +3,10 @@ kind: Deployment
|
|||
metadata:
|
||||
annotations:
|
||||
kompose.service.expose.storage-class-name: default
|
||||
kompose.service.healthcheck.readiness.interval: 10s
|
||||
kompose.service.healthcheck.readiness.retries: "3"
|
||||
kompose.service.healthcheck.readiness.test: healthcheck.sh --su-mysql --connect --innodb_initialized
|
||||
kompose.service.healthcheck.readiness.timeout: 10s
|
||||
kompose.volume.size: 1Gi
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
|
@ -19,6 +23,10 @@ spec:
|
|||
metadata:
|
||||
annotations:
|
||||
kompose.service.expose.storage-class-name: default
|
||||
kompose.service.healthcheck.readiness.interval: 10s
|
||||
kompose.service.healthcheck.readiness.retries: "3"
|
||||
kompose.service.healthcheck.readiness.test: healthcheck.sh --su-mysql --connect --innodb_initialized
|
||||
kompose.service.healthcheck.readiness.timeout: 10s
|
||||
kompose.volume.size: 1Gi
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
|
@ -38,6 +46,16 @@ spec:
|
|||
ports:
|
||||
- containerPort: 3306
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- healthcheck.sh
|
||||
- --su-mysql
|
||||
- --connect
|
||||
- --innodb_initialized
|
||||
failureThreshold: 3
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 10
|
||||
resources: {}
|
||||
volumeMounts:
|
||||
- mountPath: /var/lib/mysql
|
||||
|
|
|
@ -3,6 +3,10 @@ kind: Service
|
|||
metadata:
|
||||
annotations:
|
||||
kompose.service.expose.storage-class-name: default
|
||||
kompose.service.healthcheck.readiness.interval: 10s
|
||||
kompose.service.healthcheck.readiness.retries: "3"
|
||||
kompose.service.healthcheck.readiness.test: healthcheck.sh --su-mysql --connect --innodb_initialized
|
||||
kompose.service.healthcheck.readiness.timeout: 10s
|
||||
kompose.volume.size: 1Gi
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
|
|
|
@ -3,6 +3,9 @@ kind: Deployment
|
|||
metadata:
|
||||
annotations:
|
||||
kompose.service.expose.storage-class-name: default
|
||||
kompose.service.healthcheck.readiness.interval: 10s
|
||||
kompose.service.healthcheck.readiness.tcp_port: "8082"
|
||||
kompose.service.healthcheck.readiness.timeout: 10s
|
||||
kompose.volume.size: 1Gi
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
|
@ -19,6 +22,9 @@ spec:
|
|||
metadata:
|
||||
annotations:
|
||||
kompose.service.expose.storage-class-name: default
|
||||
kompose.service.healthcheck.readiness.interval: 10s
|
||||
kompose.service.healthcheck.readiness.tcp_port: "8082"
|
||||
kompose.service.healthcheck.readiness.timeout: 10s
|
||||
kompose.volume.size: 1Gi
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
|
@ -48,6 +54,11 @@ spec:
|
|||
protocol: TCP
|
||||
- containerPort: 8083
|
||||
protocol: TCP
|
||||
readinessProbe:
|
||||
periodSeconds: 10
|
||||
tcpSocket:
|
||||
port: 8082
|
||||
timeoutSeconds: 10
|
||||
resources: {}
|
||||
volumeMounts:
|
||||
- mountPath: /shared
|
||||
|
|
|
@ -3,6 +3,9 @@ kind: Service
|
|||
metadata:
|
||||
annotations:
|
||||
kompose.service.expose.storage-class-name: default
|
||||
kompose.service.healthcheck.readiness.interval: 10s
|
||||
kompose.service.healthcheck.readiness.tcp_port: "8082"
|
||||
kompose.service.healthcheck.readiness.timeout: 10s
|
||||
kompose.volume.size: 1Gi
|
||||
creationTimestamp: null
|
||||
labels:
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
/scripts/swarm-dns.sh &
|
||||
if [ "$SWARM_DNS" = true ]; then
|
||||
/scripts/swarm-dns.sh &
|
||||
fi
|
||||
|
||||
caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
|
||||
caddy run --config /etc/caddy/Caddyfile --adapter caddyfile &
|
||||
|
||||
wait -n
|
||||
|
||||
exit $?
|
|
@ -1,28 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ "$SWARM_DNS" = true ]; then
|
||||
|
||||
cp /etc/caddy/Caddyfile /etc/caddy/Caddyfile.default
|
||||
|
||||
while true; do
|
||||
cp /etc/caddy/Caddyfile /etc/caddy/Caddyfile.default
|
||||
|
||||
SEAHUB_IPS=$(dig +short $SEAHUB_HOSTNAME | sed -e 's/$/:8000/' | tr ' ' '\n' | sort | tr '\n' ' ')
|
||||
SEAHUB_MEDIA_IPS=$(dig +short $SEAHUB_MEDIA_HOSTNAME | sed -e 's/$/:80/' | tr ' ' '\n' | sort | tr '\n' ' ')
|
||||
while true; do
|
||||
|
||||
cp /etc/caddy/Caddyfile.default /etc/caddy/Caddyfile.tmp
|
||||
SEAHUB_IPS=$(dig +short $SEAHUB_HOSTNAME | sed -e 's/$/:8000/' | tr ' ' '\n' | sort | tr '\n' ' ')
|
||||
SEAHUB_MEDIA_IPS=$(dig +short $SEAHUB_MEDIA_HOSTNAME | sed -e 's/$/:80/' | tr ' ' '\n' | sort | tr '\n' ' ')
|
||||
|
||||
sed -i "s/$SEAHUB_HOSTNAME:8000/$(echo $SEAHUB_IPS)/g" /etc/caddy/Caddyfile.tmp
|
||||
sed -i "s/$SEAHUB_MEDIA_HOSTNAME:80/$(echo $SEAHUB_MEDIA_IPS)/g" /etc/caddy/Caddyfile.tmp
|
||||
cp /etc/caddy/Caddyfile.default /etc/caddy/Caddyfile.tmp
|
||||
|
||||
if ! diff -q "/etc/caddy/Caddyfile" "/etc/caddy/Caddyfile.tmp"; then
|
||||
rm -f /etc/caddy/Caddyfile
|
||||
mv /etc/caddy/Caddyfile.tmp /etc/caddy/Caddyfile
|
||||
echo "Applying new Caddyfile:"
|
||||
cat /etc/caddy/Caddyfile
|
||||
caddy reload --config /etc/caddy/Caddyfile
|
||||
fi
|
||||
sed -i "s/$SEAHUB_HOSTNAME:8000/$(echo $SEAHUB_IPS)/g" /etc/caddy/Caddyfile.tmp
|
||||
sed -i "s/$SEAHUB_MEDIA_HOSTNAME:80/$(echo $SEAHUB_MEDIA_IPS)/g" /etc/caddy/Caddyfile.tmp
|
||||
|
||||
sleep 10
|
||||
if ! diff -q "/etc/caddy/Caddyfile" "/etc/caddy/Caddyfile.tmp"; then
|
||||
rm -f /etc/caddy/Caddyfile
|
||||
mv /etc/caddy/Caddyfile.tmp /etc/caddy/Caddyfile
|
||||
echo "Applying new Caddyfile:"
|
||||
cat /etc/caddy/Caddyfile
|
||||
caddy reload --config /etc/caddy/Caddyfile
|
||||
fi
|
||||
|
||||
done
|
||||
fi
|
||||
sleep 10
|
||||
|
||||
done
|
|
@ -29,6 +29,7 @@ ENV SEAFILE_VERSION=11.0.5
|
|||
|
||||
RUN apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
netcat-openbsd \
|
||||
socat \
|
||||
cron \
|
||||
tzdata \
|
||||
|
|
|
@ -3,6 +3,7 @@ source /scripts/utils.sh
|
|||
SEAFILE_DIR=/opt/seafile/seafile-server-latest
|
||||
|
||||
if [[ $SEAFILE_SERVER != *"pro"* ]]; then
|
||||
touch /tmp/gc_active
|
||||
echo "Seafile CE: Stop Seafile to perform offline garbage collection."
|
||||
stop_socat
|
||||
$SEAFILE_DIR/seafile.sh stop
|
||||
|
@ -17,8 +18,7 @@ fi
|
|||
$SEAFILE_DIR/seaf-gc.sh "$@"
|
||||
|
||||
if [[ $SEAFILE_SERVER != *"pro"* ]]; then
|
||||
echo "Seafile CE: Offline garbage collection completed. Starting Seafile."
|
||||
sleep 3
|
||||
$SEAFILE_DIR/seafile.sh start
|
||||
start_socat &
|
||||
echo "Seafile CE: Offline garbage collection completed. Exiting..."
|
||||
echo "Set the restart policy of this container to unless-stopped to restart it automatically after garbage collection."
|
||||
rm -f /tmp/gc_active
|
||||
fi
|
||||
|
|
|
@ -3,8 +3,17 @@
|
|||
source /scripts/utils.sh
|
||||
trap 'sigterm' SIGTERM
|
||||
|
||||
gc_cron &
|
||||
rm -f /tmp/gc_active
|
||||
|
||||
gc_cron
|
||||
start_server &
|
||||
start_socat &
|
||||
logger &
|
||||
keep_running
|
||||
|
||||
wait -n
|
||||
|
||||
while [ -f /tmp/gc_active ]; do
|
||||
sleep 10
|
||||
done
|
||||
|
||||
exit $?
|
|
@ -47,12 +47,6 @@ function logger {
|
|||
tail -f /opt/seafile/logs/common.log | tee
|
||||
}
|
||||
|
||||
function keep_running {
|
||||
while true; do
|
||||
tail -f /dev/null & wait ${!}
|
||||
done
|
||||
}
|
||||
|
||||
function sig_kill_all () {
|
||||
pkill -SIGKILL -f "seaf-server -c ${default_ccnet_conf_dir}"
|
||||
pkill -SIGKILL -f "fileserver -c ${default_ccnet_conf_dir}"
|
||||
|
|
|
@ -23,30 +23,36 @@ function start_socat {
|
|||
|
||||
function watch_server {
|
||||
while true; do
|
||||
sleep 2
|
||||
sleep 1
|
||||
if ! nc -z ${SEAFILE_SERVER_HOSTNAME} 8082 2>/dev/null; then
|
||||
echo "Lost connection to seafiler-server. Stopping seahub..."
|
||||
/opt/seafile/seafile-server-latest/seahub.sh stop
|
||||
while ! nc -z ${SEAFILE_SERVER_HOSTNAME} 8082 2>/dev/null; do
|
||||
sleep 1
|
||||
done
|
||||
start_seahub &
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function watch_seahub {
|
||||
while true; do
|
||||
sleep 1
|
||||
if ! pgrep -f "seahub.wsgi:application" >/dev/null; then
|
||||
echo "Seahub process was stopped. Exiting container..."
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function logger {
|
||||
tail -f /opt/seafile/logs/seahub.log | tee /proc/1/fd/1
|
||||
tail -f /opt/seafile/logs/seahub.log | tee
|
||||
}
|
||||
|
||||
function keep_running {
|
||||
while true; do
|
||||
tail -f /dev/null & wait ${!}
|
||||
done
|
||||
}
|
||||
init_seahub
|
||||
start_seahub
|
||||
|
||||
start_socat &
|
||||
init_seahub
|
||||
start_seahub &
|
||||
watch_server &
|
||||
logger
|
||||
keep_running
|
||||
watch_seahub &
|
||||
logger &
|
||||
|
||||
wait -n
|
||||
|
||||
exit $?
|
Loading…
Reference in a new issue