Skip to content

Commit

Permalink
🔧 (workflows/get-build-stable-artifacts-with-memogram-and-push-image…
Browse files Browse the repository at this point in the history
….yml): update workflow to use new script names

  🔧 (Dockerfile): update Dockerfile to use new script names
  🔧 (Dockerfile.memogram): update Dockerfile.memogram to use new script names
  🔧 (etc/Procfile): update Procfile to use new script names
  🚀 (scripts/run-memogram.sh): add new script to run memogram service
  🔧 (scripts/run-memos-with-litestream.sh): rename script and remove memogram related code
  • Loading branch information
hu3rror committed May 19, 2024
1 parent e047560 commit fb27486
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
paths:
- 'Dockerfile.memogram'
- 'scripts/run.sh'
- 'scripts/run-memogram.sh'
workflow_dispatch:

jobs:
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
10 changes: 7 additions & 3 deletions Dockerfile.memogram
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions etc/Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
memos: ./run.sh
memogram: sleep 5 && ./memogram
memos: ./run-memos-with-litestream.sh
memogram: sleep 5 && ./run-memogram.sh
17 changes: 17 additions & 0 deletions scripts/run-memogram.sh
Original file line number Diff line number Diff line change
@@ -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>/'"$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
11 changes: 0 additions & 11 deletions scripts/run.sh → scripts/run-memos-with-litestream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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>/'"$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"

0 comments on commit fb27486

Please sign in to comment.