kamal icon indicating copy to clipboard operation
kamal copied to clipboard

Make configuration path configurable

Open 99linesofcode opened this issue 2 years ago • 1 comments
trafficstars

I would like to be able to use MRSK in other projects and environments (ie. Laravel). While Laravel also stores it's project configuration in the /config folder, it uses .php files as opposed to .yml. Within the context of a Laravel app it would make more sense to me to store the deploy.yml file in the project root which is why I would like to be able to configure it.

Think this will be a nice issue for me to dabble with Ruby a bit. There are also quite a few directions we could take this in. I'm currently thinking about writing out a .mrskrc on init that will contain this and similar configuration settings in the future. Thoughts?

99linesofcode avatar Mar 10 '23 17:03 99linesofcode

          You can pass `-c` to specify a different path for the deploy configuration 👍

Originally posted by @dhh in https://github.com/mrsked/mrsk/issues/75#issuecomment-1454656935

Try with:

mv config/deploy.yml .mrskrc
mrsk deploy -c .mrskrc

It doesn't work with mrsk init -c .mrskrc though, so that's something thats needs a fix 🎉

config/deploy.yaml is hardcoded here:

https://github.com/mrsked/mrsk/blob/3026a92c9850be79f0e4f0f691552867bc0b14d6/lib/mrsk/cli/main.rb#L104

kjellberg avatar Mar 10 '23 18:03 kjellberg

Thanks @kjellberg, missed that option. Let's park the idea of a .mrskrc configuration file for now and see whether other usecases arrive that may warrant adding something like that in the future.

99linesofcode avatar Mar 15 '23 13:03 99linesofcode

Hi @99linesofcode you metioned Laravel. Do you have some example repo integrating Kamal with Laravel. Thanks and sorry if this a bit off-topic on this issue

andresgutgon avatar Sep 19 '23 18:09 andresgutgon

Hi @andresgutgon,

No example repository unfortunately but here's the gist of what I did to deploy a Laravel application succesfully:

  1. Create a base image that copies your source code into /app and host it on a container registry (for example on Github);
  2. Add a healthcheck endpoint (i.e. /up). I've used Spatie's Laravel Health;
  3. Define your deploy.yml and secrets;
  4. Run Kamal. Here is the alias I used when it was still mrsk:
# mrsk
alias mrsk="docker run -it --rm -v $PWD:/workdir -v $HOME/.gitconfig:/root/.gitconfig -v $SSH_AUTH_SOCK:/ssh-agent -v /var/run/docker.sock:/var/run/docker.sock -e SSH_AUTH_SOCK=/ssh-agent ghcr.io/mrsked/mrsk:latest"

Below is an example of the deploy.yml I used:

service: APP_NAME

image: GITHUB_ACCOUNT/IMAGE_NAME
servers:
  - SERVER_IP

registry:
  server: ghcr.io
  username: 99linesofcode
  password:
    - MRSK_REGISTRY_PASSWORD

builder:
  multiarch: false

healthcheck:
  path: /up
  port: 80

Good luck!

99linesofcode avatar Sep 22 '23 09:09 99linesofcode

Thanks! I'll try and let you know

andresgutgon avatar Sep 22 '23 09:09 andresgutgon