Skip to content
Snippets Groups Projects
README.md 2.01 KiB
Newer Older
# Kamal deploy tips

Deploy tool using docker https://kamal-deploy.org/
Create simple server on lxc

## Installation

Install using ruby gem, currently version 2.5.0
```
gem install kamal
```
create `config/deploy.yml` and `.kamal/secrets` file
```
kamal init
```

TODO: try using kamal from docker https://kamal-deploy.org/docs/installation/dockerized/


## Make docker image

Before deploy you can test your image, for example
```
# Dockerfile
FROM nginx:latest
COPY ./public/index.html /usr/share/nginx/html
```
and build image and run container with
```
docker build . -t sample-server
docker run -p 80:80 sample-server
```
Open http://localhost:80 and you should see `hello`
```
curl localhost:80
hello
```
Remove image
```
docker rmi sample-server
```

Also you can test with docker compose
```
# docker-compose.yml
services:
  web:
    build:
      context: .
    ports:
      - 80:80
```
run with
```
docker compose up
```
Open http://localhost:80 and you should see `hello`
```
curl localhost:80
hello
```

Remove image
```
docker compose down --rmi local
```

## Setup

We do not need docker on the server since kamal will automatically install it
```
kamal setup
```

https://kamal-deploy.org/docs/commands/deploy/

By default we use https://hub.docker.com/ to store the image so we need to export key used in `.kamal/secrets`
```
export KAMAL_REGISTRY_PASSWORD=dc....
```
Kamal deploy
```
kamal deploy
```

Note that build is based on latest COMMITED code so if you have some updates, you need to commit them before deploy.

## config/deploy.yml

* `image:` name of the container image should match name of the repository on registry server. For hub.docker.io is it `<username>/<repository>`. For ECR it is `<repository>`

## Destinations

https://kamal-deploy.org/docs/configuration/overview/#destinations
Dusan Orlovic's avatar
Dusan Orlovic committed
You can set up multiple config files, destinations, for example
```
# config/deploy.dule.yml
```
and config will merge with default `config/deploy.yml`
you can check with
```
diff <(kamal config -d dule) <(kamal config)
```