summaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-06-22 14:57:55 -0400
committerDessalines <tyhou13@gmx.com>2020-06-22 14:57:55 -0400
commit983a45e17884bf9ab5b52a859d47dc4c9168a181 (patch)
tree6abd0d3aa598b453cfff293f9a9860c670dccf2f /docker
parentceb1284f2733a8fc5e089be823bc109034589cfe (diff)
parent96c9f801a956adb2fdc5e6afb061c01c58962e00 (diff)
Merge branch 'master' into iav-arm-musl-dessalines
Diffstat (limited to 'docker')
-rw-r--r--docker/dev/docker-compose.yml32
-rw-r--r--docker/prod/docker-compose.yml16
-rw-r--r--docker/prod/migrate-pictshare-to-pictrs.bash60
3 files changed, 85 insertions, 23 deletions
diff --git a/docker/dev/docker-compose.yml b/docker/dev/docker-compose.yml
index 1702f66d..bdcb4308 100644
--- a/docker/dev/docker-compose.yml
+++ b/docker/dev/docker-compose.yml
@@ -1,15 +1,6 @@
version: '3.3'
services:
- postgres:
- image: postgres:12-alpine
- environment:
- - POSTGRES_USER=lemmy
- - POSTGRES_PASSWORD=password
- - POSTGRES_DB=lemmy
- volumes:
- - ./volumes/postgres:/var/lib/postgresql/data
- restart: always
lemmy:
build:
@@ -23,16 +14,27 @@ services:
volumes:
- ../lemmy.hjson:/config/config.hjson
depends_on:
+ - pictrs
- postgres
- - pictshare
- iframely
- pictshare:
- image: hascheksolutions/pictshare:latest
- ports:
- - "127.0.0.1:8537:80"
+ postgres:
+ image: postgres:12-alpine
+ environment:
+ - POSTGRES_USER=lemmy
+ - POSTGRES_PASSWORD=password
+ - POSTGRES_DB=lemmy
+ volumes:
+ - ./volumes/postgres:/var/lib/postgresql/data
+ restart: always
+
+ pictrs:
+ image: asonix/pictrs:v0.1.13-r0
+ ports:
+ - "127.0.0.1:8537:8080"
+ user: 991:991
volumes:
- - ./volumes/pictshare:/usr/share/nginx/html/data
+ - ./volumes/pictrs:/mnt
restart: always
iframely:
diff --git a/docker/prod/docker-compose.yml b/docker/prod/docker-compose.yml
index eab5cab2..863ff593 100644
--- a/docker/prod/docker-compose.yml
+++ b/docker/prod/docker-compose.yml
@@ -12,7 +12,7 @@ services:
restart: always
lemmy:
- image: dessalines/lemmy:v0.6.77
+ image: dessalines/lemmy:v0.6.79
ports:
- "127.0.0.1:8536:8536"
restart: always
@@ -22,17 +22,17 @@ services:
- ./lemmy.hjson:/config/config.hjson
depends_on:
- postgres
- - pictshare
+ - pictrs
- iframely
- pictshare:
- image: hascheksolutions/pictshare:latest
- ports:
- - "127.0.0.1:8537:80"
+ pictrs:
+ image: asonix/pictrs:v0.1.13-r0
+ ports:
+ - "127.0.0.1:8537:8080"
+ user: 991:991
volumes:
- - ./volumes/pictshare:/usr/share/nginx/html/data
+ - ./volumes/pictrs:/mnt
restart: always
- mem_limit: 100m
iframely:
image: dogbin/iframely:latest
diff --git a/docker/prod/migrate-pictshare-to-pictrs.bash b/docker/prod/migrate-pictshare-to-pictrs.bash
new file mode 100644
index 00000000..8229eb28
--- /dev/null
+++ b/docker/prod/migrate-pictshare-to-pictrs.bash
@@ -0,0 +1,60 @@
+#!/bin/bash
+set -e
+
+if [[ $(id -u) != 0 ]]; then
+ echo "This migration needs to be run as root"
+ exit
+fi
+
+if [[ ! -f docker-compose.yml ]]; then
+ echo "No docker-compose.yml found in current directory. Is this the right folder?"
+ exit
+fi
+
+# Fixing pictrs permissions
+mkdir -p volumes/pictrs
+sudo chown -R 991:991 volumes/pictrs
+
+echo "Restarting docker-compose, making sure that pictrs is started and pictshare is removed"
+docker-compose up -d --remove-orphans
+
+if [[ -z $(docker-compose ps | grep pictrs) ]]; then
+ echo "Pict-rs is not running, make sure you update Lemmy first"
+ exit
+fi
+
+# echo "Stopping Lemmy so that users dont upload new images during the migration"
+# docker-compose stop lemmy
+
+pushd volumes/pictshare/
+echo "Importing pictshare images to pict-rs..."
+IMAGE_NAMES=*
+for image in $IMAGE_NAMES; do
+ IMAGE_PATH="$(pwd)/$image/$image"
+ if [[ ! -f $IMAGE_PATH ]]; then
+ continue
+ fi
+ echo -e "\nImporting $IMAGE_PATH"
+ ret=0
+ curl --silent --fail -F "images[]=@$IMAGE_PATH" http://127.0.0.1:8537/import || ret=$?
+ if [[ $ret != 0 ]]; then
+ echo "Error for $IMAGE_PATH : $ret"
+ fi
+done
+
+echo "Fixing permissions on pictshare folder"
+find . -type d -exec chmod 755 {} \;
+find . -type f -exec chmod 644 {} \;
+
+popd
+
+echo "Rewrite image links in Lemmy database"
+docker-compose exec -u postgres postgres psql -U lemmy -c "UPDATE user_ SET avatar = REPLACE(avatar, 'pictshare', 'pictrs/image') WHERE avatar is not null;"
+docker-compose exec -u postgres postgres psql -U lemmy -c "UPDATE post SET url = REPLACE(url, 'pictshare', 'pictrs/image') WHERE url is not null;"
+
+echo "Moving pictshare data folder to pictshare_backup"
+mv volumes/pictshare volumes/pictshare_backup
+
+echo "Migration done, starting Lemmy again"
+echo "If everything went well, you can delete ./volumes/pictshare_backup/"
+docker-compose start lemmy