1
0
forked from noxious/server
This commit is contained in:
Dennis Postma 2024-09-30 21:23:38 +02:00
parent 72159cdc17
commit 34ed2ba7cb

View File

@ -1,8 +1,8 @@
# Use the official Node.js 22.4.1 image # Use the official Node.js 22.4.1 image
FROM node:22.4.1-alpine FROM node:22.4.1-alpine
# Install Redis and screen # Install Redis and tmux
RUN apk add --no-cache redis screen RUN apk add --no-cache redis tmux
# Set the working directory in the container # Set the working directory in the container
WORKDIR /usr/src/ WORKDIR /usr/src/
@ -28,12 +28,13 @@ RUN npm run build
# Expose the ports your Node.js application and Redis will listen on # Expose the ports your Node.js application and Redis will listen on
EXPOSE 80 6379 EXPOSE 80 6379
# Create a shell script to run Redis, run migrations, and start the application in a screen session # Create a shell script to run Redis, run migrations, and start the application in a tmux session
RUN echo '#!/bin/sh' > /usr/src/start.sh && \ RUN echo '#!/bin/sh' > /usr/src/start.sh && \
echo 'redis-server --daemonize yes' >> /usr/src/start.sh && \ echo 'redis-server --daemonize yes' >> /usr/src/start.sh && \
echo 'npx prisma migrate deploy' >> /usr/src/start.sh && \ echo 'npx prisma migrate deploy' >> /usr/src/start.sh && \
echo 'screen -dmS nodeapp node dist/server.js' >> /usr/src/start.sh && \ echo 'tmux new-session -d -s nodeapp "node dist/server.js"' >> /usr/src/start.sh && \
echo 'exec /bin/sh' >> /usr/src/start.sh && \ echo 'echo "App is running in tmux session. Attach with: tmux attach-session -t nodeapp"' >> /usr/src/start.sh && \
echo 'tail -f /dev/null' >> /usr/src/start.sh && \
chmod +x /usr/src/start.sh chmod +x /usr/src/start.sh
# Use the shell script as the entry point # Use the shell script as the entry point