diff --git a/.github/workflows/get-build-stable-artifacts-with-memogram-and-push-image.yml b/.github/workflows/get-build-stable-artifacts-with-memogram-and-push-image.yml index f97b9f7..edfbfe5 100644 --- a/.github/workflows/get-build-stable-artifacts-with-memogram-and-push-image.yml +++ b/.github/workflows/get-build-stable-artifacts-with-memogram-and-push-image.yml @@ -4,7 +4,7 @@ on: push: paths: - 'Dockerfile.memogram' - - 'scripts/run.sh' + - 'scripts/run-memogram.sh' workflow_dispatch: jobs: diff --git a/Dockerfile b/Dockerfile index a2788b0..97f044b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,11 +16,11 @@ COPY --from=package /usr/local/bin/litestream /usr/local/bin/litestream COPY etc/litestream.yml /etc/litestream.yml # Copy startup script and make it executable. -COPY scripts/run.sh /usr/local/memos/run.sh -RUN chmod +x /usr/local/memos/run.sh +COPY scripts/run-memos-with-litestream.sh /usr/local/memos/run-memos-with-litestream.sh +RUN chmod +x /usr/local/memos/run-memos-with-litestream.sh # Define ENV ENV DB_PATH="/var/opt/memos/memos_prod.db" # Run memos with litestream (Default WORKDIR is `/usr/local/memos/`) -CMD ["./run.sh"] +CMD ["./run-memos-with-litestream.sh"] diff --git a/Dockerfile.memogram b/Dockerfile.memogram index dd27f78..8354d98 100644 --- a/Dockerfile.memogram +++ b/Dockerfile.memogram @@ -53,9 +53,13 @@ COPY etc/memogram.env /usr/local/memos/.env # Copy Litestream global configuration file COPY etc/litestream.yml /etc/litestream.yml -# Copy startup script and make it executable -COPY scripts/run.sh /usr/local/memos/run.sh -RUN chmod +x /usr/local/memos/run.sh +# Copy memos script and make it executable +COPY scripts/run-memos-with-litestream.sh /usr/local/memos/run-memos-with-litestream.sh +RUN chmod +x /usr/local/memos/run-memos-with-litestream.sh + +# Copy Memogram script and make it executable +COPY scripts/run-memogram.sh /usr/local/memos/run-memogram.sh +RUN chmod +x /usr/local/memos/run-memogram.sh # Copy overmind configuration file COPY etc/Procfile /usr/local/memos/Procfile diff --git a/etc/Procfile b/etc/Procfile index e2d202e..ac094ce 100644 --- a/etc/Procfile +++ b/etc/Procfile @@ -1,2 +1,2 @@ -memos: ./run.sh -memogram: sleep 5 && ./memogram \ No newline at end of file +memos: ./run-memos-with-litestream.sh +memogram: sleep 5 && ./run-memogram.sh \ No newline at end of file diff --git a/scripts/run-memogram.sh b/scripts/run-memogram.sh new file mode 100755 index 0000000..bd0a909 --- /dev/null +++ b/scripts/run-memogram.sh @@ -0,0 +1,17 @@ +#!/bin/sh +set -e + +# Replace MEMOGRAM_BOT_TOKEN in .env +if [ -f "./memogram" ] && [ -f "./.env" ] && [ -n "$MEMOGRAM_BOT_TOKEN" ]; then + # Replace MEMOGRAM_BOT_TOKEN in .env + sed -i 's//'"$MEMOGRAM_BOT_TOKEN"'/g' ./.env + + # Replace MEMOS_PORT in .env + if [ "$MEMOS_PORT" != "5230" ]; then + sed -i 's/5230/'"$MEMOS_PORT"'/g' ./.env + fi + + # Run memogram + echo "Starting memogram service." + exec ./memogram +fi \ No newline at end of file diff --git a/scripts/run.sh b/scripts/run-memos-with-litestream.sh similarity index 56% rename from scripts/run.sh rename to scripts/run-memos-with-litestream.sh index a86f24b..23cf61d 100755 --- a/scripts/run.sh +++ b/scripts/run-memos-with-litestream.sh @@ -10,17 +10,6 @@ else echo "Finished restoring the database." fi -# Replace MEMOGRAM_BOT_TOKEN in .env -if [ -f "./memogram" ] && [ -f "./.env" ] && [ -n "$MEMOGRAM_BOT_TOKEN" ]; then - # Replace MEMOGRAM_BOT_TOKEN in .env - sed -i 's//'"$MEMOGRAM_BOT_TOKEN"'/g' ./.env - - # Replace MEMOS_PORT in .env - if [ "$MEMOS_PORT" != "5230" ]; then - sed -i 's/5230/'"$MEMOS_PORT"'/g' ./.env - fi -fi - # Run litestream with your app as the subprocess. echo "Starting litestream & memos service." exec litestream replicate -exec "./memos"