This guide covers:
- Running Locally (for development/testing)
- Deploying to Production
- Managing the Services (starting, stopping, logging, etc.)
- Install Docker and Docker Compose
Run the following command in the same directory as your docker-compose.yml
:
docker compose up -d
- The
-d
flag runs the services in detached mode (background). - This will start:
- Kraken Service (
kraken-service
) - Immortal Service (
immortal
) - MongoDB (
mongo
) - Redis Stack (
redis-stack
)
- Kraken Service (
docker ps
This will show all running services and their exposed ports.
docker compose down
This stops all running containers.
docker compose logs -f
-f
follows logs in real-time.- To check logs of a specific service (e.g.,
kraken-service
):docker compose logs -f kraken-service
If you make changes to your app's code and want to restart:
docker compose down
docker compose up --build -d
- The
--build
flag ensures fresh images are built.
- Use Ubuntu 22.04 or any Linux server.
- Install Docker & Docker Compose:
curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh sudo apt-get install docker-compose-plugin
-
Clone your repository:
git clone https://github.com/your-org/your-repo.git cd your-repo
-
OR upload your
docker-compose.yml
and.env
file manually:scp docker-compose.yml user@your-server:/home/user/
-
Create a
.env
file in the same directory asdocker-compose.yml
:nano .env
-
Add your environment variables:
NODE_ENV=production JWT_SECRET=your-secret-key TRYSPEED_API_KEY=your-secret-api-key
-
Modify
docker-compose.yml
to load from.env
:environment: NODE_ENV: ${NODE_ENV} JWT_SECRET: ${JWT_SECRET} TRYSPEED_API_KEY: ${TRYSPEED_API_KEY}
docker compose up -d
- Services will now run in the background.
Enable the Docker service to auto-start on system boot:
sudo systemctl enable docker
docker ps
docker compose logs -f
docker compose down
docker compose up -d
If you have updated your app and pushed new images:
docker compose pull # Pull latest images
docker compose up -d --build
docker image prune -f # Cleanup old images
For high availability and load balancing, deploy using Docker Swarm:
docker swarm init
docker stack deploy -c docker-compose.yml my-app
- This creates a Swarm stack and ensures it recovers automatically.
Task | Command |
---|---|
Start locally | docker compose up -d |
Stop services | docker compose down |
Check running containers | docker ps |
View logs | docker compose logs -f |
Restart services | docker compose down && docker compose up -d |
Update production | docker compose pull && docker compose up -d --build |
Enable auto-restart | sudo systemctl enable docker |
Now you're ready to run and deploy your app locally & in production! 🚀