1
0
forked from noxious/server

Moved bash code into .sh file

This commit is contained in:
2025-02-07 00:59:59 +01:00
parent 67a4c6763b
commit 9ea12ee458
2 changed files with 27 additions and 13 deletions

View File

@ -16,9 +16,6 @@ COPY package*.json ./
# Install application dependencies
RUN npm install
# Import migrations
RUN npx mikro-orm migration:up
# Copy the rest of your application code to the container
COPY . .
@ -28,16 +25,9 @@ RUN npm run build
# Expose the ports your Node.js application, Redis, and MySQL will listen on
EXPOSE 80 6379 3306
# Create a shell script to run Redis, MySQL, run migrations, and start the application in a tmux session
RUN echo '#!/bin/sh' > /usr/src/start.sh && \
echo 'redis-server --daemonize yes' >> /usr/src/start.sh && \
echo 'mysqld --user=mysql --datadir=/var/lib/mysql &' >> /usr/src/start.sh && \
echo 'sleep 10' >> /usr/src/start.sh && \
echo 'npx prisma migrate deploy' >> /usr/src/start.sh && \
echo 'tmux new-session -d -s nodeapp "node dist/server.js"' >> /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
# Copy and make the startup script executable
COPY docker-start.sh /usr/src/start.sh
RUN chmod +x /usr/src/start.sh
# Use the shell script as the entry point
CMD ["/usr/src/start.sh"]