basecamp / kamal

Deploy web apps anywhere.
https://kamal-deploy.org
MIT License
9.41k stars 362 forks source link

enable volumes, directories and files for any role #695

Closed aka47 closed 4 months ago

aka47 commented 4 months ago

For the app, the traefic role, and any accessory you can configure files, volumes, and directories from your project to be accessible inside the docker container.

The files and directories are uploaded to the host and mounted via docker volumes to the docker container. This worked previously only for accessories. So I moved code related to this from accessory configuration to a new class to make it useable for the traefik proxy and the main app as well.

With this change we can add in the config for traefik volumes, files and folders

traefik:
  files:
    - config/traefik.yaml:/etc/traefik/traefik.yaml
  directories:
    - config/traefik.d:/etc/traefik/traefik.d
  volumes:
    - /mnt/volume-data/letsencrypt/acme.json:/letsencrypt/acme.json

For the main app config it looks like this:

volumes:
  - "/mnt/volume-data/wordpress-data:/var/www/html"
files:
  - apache.conf:/etc/apache2/sites-enabled/wp3.conf
directories:
  - config/apache/:/etc/conf-avail

And it works as it currently does for accessories.

accessories:
  redis:
    files:
      - config/redis.conf:/etc/redis/redis.conf
    directories:
      - config/conf.d:/etc/conf/conf.d
    volumes:
      - /mnt/volume-data/conf/conf.json:/conf/conf.json