From 72159cdc175549fcffabfdd3dcb1f0d79b113df3 Mon Sep 17 00:00:00 2001 From: Dennis Postma Date: Mon, 30 Sep 2024 21:14:19 +0200 Subject: [PATCH] Add screen --- Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index b7baa97..9bb2b2d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ # Use the official Node.js 22.4.1 image FROM node:22.4.1-alpine -# Install Redis -RUN apk add --no-cache redis +# Install Redis and screen +RUN apk add --no-cache redis screen # Set the working directory in the container WORKDIR /usr/src/ @@ -28,11 +28,12 @@ RUN npm run build # Expose the ports your Node.js application and Redis will listen on EXPOSE 80 6379 -# Create a shell script to run Redis, run migrations, and start the application +# Create a shell script to run Redis, run migrations, and start the application in a screen session RUN echo '#!/bin/sh' > /usr/src/start.sh && \ echo 'redis-server --daemonize yes' >> /usr/src/start.sh && \ echo 'npx prisma migrate deploy' >> /usr/src/start.sh && \ - echo 'node dist/server.js' >> /usr/src/start.sh && \ + echo 'screen -dmS nodeapp node dist/server.js' >> /usr/src/start.sh && \ + echo 'exec /bin/sh' >> /usr/src/start.sh && \ chmod +x /usr/src/start.sh # Use the shell script as the entry point