diff options
Diffstat (limited to 'docker/prod')
-rw-r--r-- | docker/prod/Dockerfile | 10 | ||||
-rw-r--r-- | docker/prod/docker-compose.yml | 4 | ||||
-rw-r--r-- | docker/prod/migrate-pictshare-to-pictrs.bash | 46 |
3 files changed, 49 insertions, 11 deletions
diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile index 54485a37..9000ca3a 100644 --- a/docker/prod/Dockerfile +++ b/docker/prod/Dockerfile @@ -10,13 +10,19 @@ WORKDIR /app RUN sudo chown -R rust:rust . RUN USER=root cargo new server WORKDIR /app/server +RUN mkdir -p lemmy_db/src/ lemmy_utils/src/ COPY --chown=rust:rust server/Cargo.toml server/Cargo.lock ./ -#RUN sudo chown -R rust:rust . +COPY --chown=rust:rust server/lemmy_db/Cargo.toml ./lemmy_db/ +COPY --chown=rust:rust server/lemmy_utils/Cargo.toml ./lemmy_utils/ RUN mkdir -p ./src/bin \ - && echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs + && echo 'fn main() { println!("Dummy") }' > ./src/bin/main.rs \ + && cp ./src/bin/main.rs ./lemmy_db/src/main.rs \ + && cp ./src/bin/main.rs ./lemmy_utils/src/main.rs RUN cargo build --release RUN rm -f ./target/$CARGO_BUILD_TARGET/$RUSTRELEASEDIR/deps/lemmy_server* COPY --chown=rust:rust server/src ./src/ +COPY --chown=rust:rust server/lemmy_db ./lemmy_db/ +COPY --chown=rust:rust server/lemmy_utils ./lemmy_utils/ COPY --chown=rust:rust server/migrations ./migrations/ # build for release diff --git a/docker/prod/docker-compose.yml b/docker/prod/docker-compose.yml index 5ccb1ec5..6c3bccb0 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.7.8 + image: dessalines/lemmy:v0.7.16 ports: - "127.0.0.1:8536:8536" restart: always @@ -35,7 +35,7 @@ services: restart: always iframely: - image: jolt/iframely:v1.4.3 + image: dogbin/iframely:latest ports: - "127.0.0.1:8061:80" volumes: diff --git a/docker/prod/migrate-pictshare-to-pictrs.bash b/docker/prod/migrate-pictshare-to-pictrs.bash index 8229eb28..667183a0 100644 --- a/docker/prod/migrate-pictshare-to-pictrs.bash +++ b/docker/prod/migrate-pictshare-to-pictrs.bash @@ -1,16 +1,21 @@ #!/bin/bash set -e -if [[ $(id -u) != 0 ]]; then +if [[ $(id -u) != 0 ]]; then echo "This migration needs to be run as root" exit fi -if [[ ! -f docker-compose.yml ]]; then +if [[ ! -f docker-compose.yml ]]; then echo "No docker-compose.yml found in current directory. Is this the right folder?" exit fi +if ! which jq > /dev/null; then + echo "jq must be installed to run this migration. On ubuntu systems, try 'sudo apt-get install jq'" + exit +fi + # Fixing pictrs permissions mkdir -p volumes/pictrs sudo chown -R 991:991 volumes/pictrs @@ -26,6 +31,8 @@ fi # echo "Stopping Lemmy so that users dont upload new images during the migration" # docker-compose stop lemmy +CRASHED_ON=() + pushd volumes/pictshare/ echo "Importing pictshare images to pict-rs..." IMAGE_NAMES=* @@ -34,11 +41,36 @@ for image in $IMAGE_NAMES; do 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" + res=$(curl -s -F "images[]=@$IMAGE_PATH" http://127.0.0.1:8537/import | jq .msg) + if [ "${res}" == "" ]; then + echo -n "C" >&2 + echo "" + CRASHED_ON+=("${IMAGE_PATH}") + echo "Failed to import $IMAGE_PATH with no error message" + echo " assuming crash, sleeping" + sleep 10 + continue + fi + if [ "${res}" != "\"ok\"" ]; then + echo -n "F" >&2 + echo "" + echo "Failed to import $IMAGE_PATH" + echo " Reason: ${res}" + else + echo -n "." >&2 + fi +done + +for image in ${CRASHED_ON[@]}; do + echo "Retrying ${image}" + res=$(curl -s -F "images[]=@$IMAGE_PATH" http://127.0.0.1:8537/import | jq .msg) + if [ "${res}" != "\"ok\"" ]; then + echo -n "F" >&2 + echo "" + echo "Failed to upload ${image} on 2nd attempt" + echo " Reason: ${res}" + else + echo -n "." >&2 fi done |