Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy using Kamal #145

Merged
merged 14 commits into from
Aug 23, 2024
Merged

Deploy using Kamal #145

merged 14 commits into from
Aug 23, 2024

Conversation

santiagorodriguez96
Copy link
Contributor

Motivation

This PR configures kamal so that we can start using it for deploying to our AWS servers.

Details

You will need an .env file with these secrets SECRET_KEY_BASE and POSTGRES_PASSWORD

Steps to set up the servers in AWS:

  1. Run this to install docker
sudo apt update
sudo apt install -y docker.io curl git
sudo usermod -a -G docker ubuntu
  1. Add any authorized keys for people that need to connect with ssh
  2. For the web server run this (needed to auto generate SSL certificates using LetsEncrypt)
mkdir -p /home/ubuntu/letsencrypt && touch /home/ubuntu/letsencrypt/acme.json && chmod 600 /home/ubuntu/letsencrypt/acme.json
  1. Enable HTTPS (443) incoming traffic in web instance
  2. Enable ports 5432 for incoming traffic in DB instance
  3. Run kamal setup

For normal deploys run kamal deploy.
If env vars change you will have to push them with kamal env push

To prevent the docker container from using too much memory from the
server, we are adding a memory limit.

By adding a memory limit, docker will kill the container when it gets to
the limit of memory usage and the docker container will be restarted – as
its started up with the `--restart unless-stopped` option.

However, we need to add the logic for cleaning the `server.pid` if
exists when starting the server given that when the docker container
starts itself after being killed it runs into an error when starting the
server as the `server.pid` already exists:

```
a server is already running (pid: 1, file: /rails/tmp/pids/server.pid)
```
@santiagorodriguez96 santiagorodriguez96 merged commit 7e27aa7 into master Aug 23, 2024
1 check passed
@santiagorodriguez96 santiagorodriguez96 deleted the sr--setup-kamal branch August 23, 2024 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant