This document outlines the steps to deploy TinyAPI using Kamal, a deployment tool for Ruby on Rails applications.
- Ruby 3.3.4
- Rails 7.2.1
- Redis
- Docker
- Kamal
-
Install Kamal on your local machine:
gem install kamal
-
Set up your
.env
file with the necessary environment variables (see.env.example
for required variables). -
Ensure your
config/deploy.yml
file is set up correctly, referencing environment variables for sensitive information. -
Add both
.env
andconfig/deploy.yml
to your.gitignore
file to prevent committing sensitive information.
-
Build your Docker image:
docker build -t $DOCKER_USERNAME/tinyapi:latest .
-
Push your Docker image to the registry:
docker push $DOCKER_USERNAME/tinyapi:latest
-
Set up the deployment environment:
kamal setup
-
Deploy your application:
kamal deploy
- If you encounter connection issues, ensure you can SSH into your server using the IP specified in your
.env
file. - Use the
-v
flag with Kamal commands for verbose output:kamal deploy -v
To update your deployment after making changes:
- Rebuild and push your Docker image.
- Run
kamal deploy
again.
- Keep all sensitive information in the
.env
file, which should not be checked into version control. - Use environment variables in
config/deploy.yml
to reference sensitive information. - Consider using a secrets management system for production deployments.
-
Check the application status:
kamal app status
-
View application logs:
kamal app logs
-
Restart the application:
kamal app restart