Skip to content

Instantly share code, notes, and snippets.

@jeffersonsc
Last active February 15, 2024 05:23
Show Gist options
  • Select an option

  • Save jeffersonsc/8cbb4ef3c626f726f8694859f11f84ac to your computer and use it in GitHub Desktop.

Select an option

Save jeffersonsc/8cbb4ef3c626f726f8694859f11f84ac to your computer and use it in GitHub Desktop.
Example deploy yml
#deploy.yml
service: jlivery-app
image: myuser/jlivery-app
registry:
username: myuser
password:
- KAMAL_REGISTRY_PASSWORD
traefik:
options:
publish:
- "443:443"
volume:
- "/home/ubuntu/letsencrypt/acme.json:/letsencrypt/acme.json"
memory: 500m
args:
log: true
log.level: WARN
accesslog: true
accesslog.format: json
entryPoints.web.address: ":80"
entryPoints.web.http.redirections.entrypoint.permanent: true
entryPoints.websecure.address: ":443"
certificatesResolvers.letsencrypt.acme.email: "contato@mail.com"
certificatesResolvers.letsencrypt.acme.storage: "/letsencrypt/acme.json"
certificatesResolvers.letsencrypt.acme.httpchallenge: true
certificatesResolvers.letsencrypt.acme.httpchallenge.entrypoint: web
# Deploy to these servers.
servers:
web:
hosts:
- 0.0.0.0
cmd: -m api
healthcheck:
path: /api/v1/status
port: 5000
interval: 25s
labels:
traefik.http.routers.jlivery-app-web.rule: Host(`api.jlivery.com`)
traefik.http.routers.jlivery-app-web.entrypoints: websecure
traefik.http.routers.jlivery-app-web_secure.rule: Host(`api.jlivery.com`)
traefik.http.routers.jlivery-app-web_secure.tls.certresolver: letsencrypt
traefik.http.routers.jlivery-app-web_secure.tls: true
was-api:
traefik: true
hosts:
- 0.0.0.0
cmd: -m minizap
healthcheck:
path: /api/v1/status
port: 5000
interval: 25s
labels:
traefik.http.routers.jlivery-app-was-api.rule: Host(`was.jlivery.com`)
traefik.http.routers.jlivery-was-api_secure.entrypoints: websecure
traefik.http.routers.jlivery-was-api_secure.rule: Host(`was.jlivery.com`)
traefik.http.routers.jlivery-was-api_secure.tls: true
traefik.http.routers.jlivery-was-api_secure.tls.certresolver: letsencrypt
worker:
traefik: false
hosts:
- 0.0.0.0
cmd: -m worker
options:
memory: 500m
campaign_summary:
traefik: false
hosts:
- 0.0.0.0
cmd: -m campaign-summary
options:
memory: 500m
schedule:
cron: "*/5 * * * *"
# Inject ENV variables into containers (secrets come from .env).
# Remember to run `kamal env push` after making changes!
env:
clear:
ENVIRONMENT: PRODUCTION
APPLICATION_NAME: api
APP_DEFAULT_URL: "https://app.site.com"
AWS_DEFAULT_REGION: us-east-1
S3_IMAGE_BUCKET: my-bucket
S3_INSTANCE_BUCKET: my-bucket
SUPERUSERNAME: superadmin
PORT: 5000
PROXY_MINIZAP_URL: "http://0.0.0.0"
QUEUE_PREFIX: queue-
CONVERT_FILE_DIR: /tmp
secret:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- JWT_SECRET
- SENDBLUE_TOKEN
- SUPERUSERPASS
- DATABASE_APP_URL
- DATABASE_URL
- REDIS_URL
# Use a different ssh user than root
ssh:
user: ubuntu
stop_wait_time: 30
builder:
local:
arch: amd64
healthcheck:
port: 5000
accessories:
db:
image: postgres:15
host: 0.0.0.0
port: 5432:5432
env:
secret:
- POSTGRES_DB
- POSTGRES_USER
- POSTGRES_PASSWORD
volumes:
- /var/postgres/data:/var/lib/postgresql/data
options:
cpus: 1
memory: "3GB"
redis:
image: redis:7.0
host: 0.0.0.0
port: 6379:6379
cmd: --maxmemory 1000m --maxmemory-policy allkeys-lru
volumes:
- /var/redis/data:/data
options:
cpus: 0.5
memory: "1GB"
#deploy.staging.yml
servers:
web:
hosts:
- 0.0.0.0
cmd: -m api
labels:
traefik.http.routers.jlivery-app-staging-web.rule: Host(`api-stag.site.com`)
traefik.http.routers.jlivery-app-staging-web_secure.rule: Host(`api-stag.site.com`)
was-api:
traefik: true
cmd: -m minizap
hosts:
- 0.0.0.0
labels:
traefik.http.routers.jlivery-app-staging-was-api.rule: Host(`was-stag.site.com`)
traefik.http.routers.jlivery-staging-was-api_secure.rule: Host(`was-stag.site.com`)
worker:
traefik: false
hosts:
- 0.0.0.0
cmd: -m worker
options:
memory: 250m
campaign_summary:
traefik: false
cmd: -m campaign-summary
hosts:
- 0.0.0.0
options:
memory: 100m
env:
clear:
APP_DEFAULT_URL: "https://app-dev.site.com"
PROXY_MINIZAP_URL: "http://0.0.0.0"
stop_wait_time: 30
builder:
local:
arch: amd64
healthcheck:
port: 5000
accessories:
db:
host: 0.0.0.0
options:
cpus: 0.5
memory: "1GB"
redis:
host: 0.0.0.0
options:
cpus: 0.5
memory: "500m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment