Skip to content

Commit

Permalink
Use ruby from mise
Browse files Browse the repository at this point in the history
  • Loading branch information
abogoyavlensky committed May 27, 2024
1 parent 555e42b commit f0dce40
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 41 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
needs: [ checks ]
steps:
- uses: actions/checkout@v4
- uses: jdx/mise-action@v2
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
Expand All @@ -29,11 +30,6 @@ jobs:
- name: Expose GitHub Runtime for cache
uses: crazy-max/ghaction-github-runtime@v3

- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.0
bundler-cache: true

- name: Install kamal
run: gem install kamal -v 1.5.2

Expand Down
3 changes: 2 additions & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ java temurin-21.0.2+13.0.LTS
clojure 1.11.3.1456
node 20.13.1
cljstyle 0.16.626
clj-kondo 2024.05.22
clj-kondo 2024.05.24
ruby 3.3.0
79 changes: 44 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,61 +26,70 @@ Other tools:

## The app

This setup provides a Clojure/Script web application with an example API route for fetching
a list of movies and displaying them on the main page.
This setup provides a Clojure/Script web application with an example API route for demonstration purposes
with fetching a list of movies and displaying them on the main page.

![App main page](/docs/app_page.png)

## Deploy: summary

You need to have Docker installed on your local machine.
Additionally, you need an empty server that you can access using SSH keys.
First deployment:
### Pre-requisites

- Docker [installed](https://docs.docker.com/engine/install/) on local machine
- Server with public IP
- Domain pointed out to server
- SSH connection from local machine to the server with SSH-keys
- Open 443 and 80 ports on server
- (optional) Configure firewall

#### Install Kamal locally

Install [mise-en-place](https://mise.jdx.dev/getting-started.html#quickstart) (or [asdf](https://asdf-vm.com/guide/getting-started.html)),
and run:

```shell
brew install libyaml # or on Ubuntu: `sudo apt-get install libyaml-dev`
mise install ruby
gem install kamal -v 1.5.2
kamal version
```

### First deployment

```shell
./kamal.sh envify --skip-push # :warning: then fill all variables in the newly created `.env` file
./kamal.sh server bootstrap
kamal envify --skip-push # :warning: then fill all variables in the newly created `.env` file
kamal server bootstrap
ssh [email protected] 'docker network create traefik'
ssh [email protected] 'mkdir -p /root/letsencrypt && touch /root/letsencrypt/acme.json && chmod 600 /root/letsencrypt/acme.json'
./kamal.sh setup
./kamal.sh app exec 'java -jar standalone.jar migrations'
kamal setup
kamal app exec 'java -jar standalone.jar migrations'
```

For subsequent deployments from the local machine:
### Regular deployment

```shell
./kamal.sh deploy
kamal deploy
```

or push to the master branch.

## Deploy: step-by-step

### Requirements

Ensure you have Docker [installed](https://docs.docker.com/engine/install/) on your machine.
Assume that you have Kamal installed and other requirements
from the "Pre-requisites" section above.

We will use a predefined command to run a dockerized version of Kamal,
so you don’t need to install anything else to deploy your app.
---
:information_source: **Note**: _Alternatively you can use dockerized version of
Kamal and use the `./kamal.sh` predefined command instead of Ruby gem version:_

```shell
./kamal.sh version
./kamla.sh version
```

---

:information_source: **Note**: _Alternatively you can install Kamal as Ruby gem
and use the `kamal` command instead of dockerized version:_
It mostly works for initial server setup, but some management commands don't work properly.
For instance, `./kamal.sh app logs -f` or `./kamal.sh build push`.

Install [mise-en-place](https://mise.jdx.dev/getting-started.html#quickstart) (or [asdf](https://asdf-vm.com/guide/getting-started.html)),
add `ruby 3.3.0` to `.tool-versions` file and run:

```shell
brew install libyaml # or on Ubuntu: `sudo apt-get install libyaml-dev`
mise install ruby
gem install kamal -v 1.5.2
kamal version
```
---

### Initial server setup

Expand All @@ -89,7 +98,7 @@ kamal version
Run command `envify` to create a `.env` with all required empty variables:

```shell
./kamal.sh envify --skip-push
kamal envify --skip-push
```

_The `--skip-push` parameter prevents the `.env` file from being pushed to the server._
Expand Down Expand Up @@ -130,7 +139,7 @@ Notes:
Install Docker on a server:

```shell
./kamal.sh server bootstrap
kamal server bootstrap
```

Create a Docker network for access to the database container from the app by container name
Expand All @@ -144,13 +153,13 @@ ssh [email protected] 'mkdir -p /root/letsencrypt && touch /root/letsencrypt/acme
Set up Traefik, the database, environment variables and run app on a server:

```shell
./kamal.sh setup
kamal setup
```

The app is deployed on the server, but it is not fully functional yet. You need to run database migrations:

```shell
./kamal.sh app exec 'java -jar standalone.jar migrations'
kamal app exec 'java -jar standalone.jar migrations'
```

Now, the application is fully deployed on the server.
Expand All @@ -160,7 +169,7 @@ Now, the application is fully deployed on the server.
For subsequent deployments from the local machine, run:

```shell
./kamal.sh deploy
kamal deploy
```

Or just push to the master branch, there is a GitHub Actions pipeline that does
Expand Down

0 comments on commit f0dce40

Please sign in to comment.