Deploying with PM2 + Docker
Do you recommend using pm2 in combination with Docker when deploying the backend in a VPS like Hetzner? Do you have any suggestions on how to configure this?
6 Replies
Hi @Ramon. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the knowledge sources provided, there isn't specific information about using PM2 with Docker when deploying a Wasp app to a VPS like Hetzner. However, I can share what's available about Docker deployment for Wasp apps.
When deploying a Wasp app, you have several options:
1. Wasp generates a Dockerfile for your server in the
.wasp/build directory when you run wasp build. This Dockerfile can be used to deploy your backend to any hosting provider that supports Docker containers, including a VPS like Hetzner Deploying Manually.
2. There is an open issue in the Wasp GitHub repository discussing deployment to bare metal with Docker containers and docker-compose.yml, which would be relevant for VPS deployment GitHub Issue #1481.
3. In one of the GitHub issues, there's a mention of potentially using PM2 in the Dockerfile with a TODO comment: "TODO: Use pm2?" GitHub Issue #726. This suggests that PM2 integration with Docker for Wasp apps is being considered but may not be officially supported or documented yet.
For deploying to a VPS like Hetzner, you would generally:
1. Run wasp build to generate deployable code
2. Use the Docker image in .wasp/build for the server
3. Set up the required environment variables
4. Deploy your PostgreSQL database
5. Deploy your client (frontend)
If you want to use PM2 within your Docker container, you might need to customize the Dockerfile. The GitHub issue #726 suggests that there might be ways to override certain stages of the Dockerfile, but specific instructions for PM2 integration aren't provided in the knowledge sources.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Ramon, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?Running the Docker container should be enough 🙂
Could this crash if an error occurs and it is not restarted automatically by default? This is my main concern, which is why I considered exploring PM2
Wohooo @Ramon, you just became a Waspeteer level 3!
IIRC we already have some protection against this, but a good tip is to
docker run the containers with the option --restart unless-stopped (docs). This will make sure Docker restarts everything if there's a catastrophic failure.Docker Documentation
docker container run
Thanks!!