-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
555e42b
commit f0dce40
Showing
3 changed files
with
47 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 }} | ||
|
@@ -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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -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._ | ||
|
@@ -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 | ||
|
@@ -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. | ||
|
@@ -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 | ||
|