Skip to content

Instantly share code, notes, and snippets.

@lvnilesh
Forked from pythoninthegrass/kamal.md
Created April 19, 2024 04:14
Show Gist options
  • Select an option

  • Save lvnilesh/43e81f23082975d767669acda9c4b64c to your computer and use it in GitHub Desktop.

Select an option

Save lvnilesh/43e81f23082975d767669acda9c4b64c to your computer and use it in GitHub Desktop.

Revisions

  1. @pythoninthegrass pythoninthegrass revised this gist Jan 12, 2024. No changes.
  2. @pythoninthegrass pythoninthegrass renamed this gist Jan 12, 2024. 1 changed file with 9 additions and 13 deletions.
    22 changes: 9 additions & 13 deletions mrsk.md → kamal.md
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,17 @@
    # MRSK
    # kamal

    This documentation adds important additions to the docs for mrsk deploy tool (see [github.com/mrsked/mrsk](https://github.com/mrsked/mrsk))
    This documentation adds important additions to the docs for kamal deploy tool (see [github.com/basecamp/kamal](https://github.com/basecamp/kamal))

    ### Destination flag

    You can use `mrsk deploy --destination staging`
    You can use `kamal deploy --destination staging`

    This will read config/deploy.yml and config/deploy.staging.yml files,
    and also will read .env.staging file if it exists.

    https://github.com/mrsked/mrsk/blob/9ec3895dab2772915c44f3a348e54de58981857d/lib/mrsk/cli/base.rb#L34

    ### ENV vars

    Both .env and .env.#destination are loaded into process env vars. So you can naturally use just process env and tools like [chamber](https://github.com/segmentio/chamber) to load secrets.
    Both `.env` and `.env.#destination` are loaded into process env vars. So you can naturally use just process env and tools like [chamber](https://github.com/segmentio/chamber) to load secrets.

    So you can use them in deploy.yml this way:
    ```yaml
    @@ -28,7 +26,7 @@ servers:
    You can reference other parts of structure using `&anchor` and `*ancho` to keep to D.R.Y. principle,
    for example:

    ```
    ```yaml
    servers:
    web:
    hosts:
    @@ -41,13 +39,11 @@ accessories:

    ### Using vars in config/deploy.yml

    mrsk uses [ERB](https://docs.ruby-lang.org/en/2.3.0/ERB.html#class-ERB-label-Recognized+Tags) Ruby module to read config:

    https://github.com/mrsked/mrsk/blob/9ec3895dab2772915c44f3a348e54de58981857d/lib/mrsk/configuration.rb#L29
    kamal uses [ERB](https://docs.ruby-lang.org/en/2.3.0/ERB.html#class-ERB-label-Recognized+Tags)

    So you can use all of these in deploy.yml:

    ```
    ```yaml
    <% Ruby code -- inline with output %>
    <%= Ruby expression -- replace with result %>
    ```
    @@ -59,7 +55,7 @@ Files are uploaded and put into the home folder for SSH user.

    For example:

    ```yml
    ```yaml
    service: test
    accessories:
    registry:
    @@ -79,7 +75,7 @@ accessories:
    REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
    ```

    When you do `mrsk accessory boot registry`
    When you do `kamal accessory boot registry`

    It will upload the local file config/htpasswd to the host, and then launch docker with the --volume ${LOCALPATH}:/etc/docker/registry/htpasswd argument.

  3. @huksley huksley revised this gist May 15, 2023. 1 changed file with 14 additions and 1 deletion.
    15 changes: 14 additions & 1 deletion mrsk.md
    Original file line number Diff line number Diff line change
    @@ -90,6 +90,19 @@ It will upload the local file config/htpasswd to the host, and then launch docke

    ### Mounting directories in accessories

    ```yaml
    service: test
    accessories:
    registry:
    image: registry:2
    host: 10.1.1.1
    port: 5000
    directories:
    # Will be copied to ${USER}/test-registry folder
    # and mounted inside the container at the specified path
    - ./config:/etc/docker/registry/
    ```

    The same syntax allows to mount local directories inside accessories, by copying local files to the remote host first, then constructing a volume argument to the docker command.

    Please note, that files in that directory are removed automatically when you remove accessory and copied from local host only when you boot accessory.
    Please note, that files in that directory are removed automatically when you remove accessory and copied from local host only when you boot accessory.
  4. @huksley huksley revised this gist May 13, 2023. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions mrsk.md
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,14 @@ https://github.com/mrsked/mrsk/blob/9ec3895dab2772915c44f3a348e54de58981857d/lib

    Both .env and .env.#destination are loaded into process env vars. So you can naturally use just process env and tools like [chamber](https://github.com/segmentio/chamber) to load secrets.

    So you can use them in deploy.yml this way:
    ```yaml
    servers:
    web:
    hosts:
    - <%= ENV["APPHOST"] %>
    ```
    ### YAML anchors
    You can reference other parts of structure using `&anchor` and `*ancho` to keep to D.R.Y. principle,
  5. @huksley huksley revised this gist Apr 23, 2023. 1 changed file with 12 additions and 5 deletions.
    17 changes: 12 additions & 5 deletions mrsk.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # MRSK

    This documentation adds important additions to the docs for mrsk deploy tool (see github.com/mrsked/mrsk)
    This documentation adds important additions to the docs for mrsk deploy tool (see [github.com/mrsked/mrsk](https://github.com/mrsked/mrsk))

    ### Destination flag

    @@ -56,10 +56,8 @@ service: test
    accessories:
    registry:
    image: registry:2
    host: *host
    host: 10.1.1.1
    port: 5000
    volumes:
    - registry:/var/lib/registry
    files:
    # Will be placed to ${USER}/test-registry folder
    # and mounted inside the container at the specified path
    @@ -77,4 +75,13 @@ When you do `mrsk accessory boot registry`

    It will upload the local file config/htpasswd to the host, and then launch docker with the --volume ${LOCALPATH}:/etc/docker/registry/htpasswd argument.

    *NB*: File will never be updated, to update it you need to remove the accessory (sic!) and then boot it again manually.
    **Notes**

    - File will never be updated, to update it you need to remove the accessory (sic!) and then boot it again manually.
    - If local file ends with .erb it will be read as [ERB](https://docs.ruby-lang.org/en/2.3.0/ERB.html#class-ERB-label-Recognized+Tags) template, with env.clear: vars available.

    ### Mounting directories in accessories

    The same syntax allows to mount local directories inside accessories, by copying local files to the remote host first, then constructing a volume argument to the docker command.

    Please note, that files in that directory are removed automatically when you remove accessory and copied from local host only when you boot accessory.
  6. @huksley huksley revised this gist Apr 23, 2023. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions mrsk.md
    Original file line number Diff line number Diff line change
    @@ -76,3 +76,5 @@ accessories:
    When you do `mrsk accessory boot registry`

    It will upload the local file config/htpasswd to the host, and then launch docker with the --volume ${LOCALPATH}:/etc/docker/registry/htpasswd argument.

    *NB*: File will never be updated, to update it you need to remove the accessory (sic!) and then boot it again manually.
  7. @huksley huksley revised this gist Apr 23, 2023. 1 changed file with 34 additions and 1 deletion.
    35 changes: 34 additions & 1 deletion mrsk.md
    Original file line number Diff line number Diff line change
    @@ -42,4 +42,37 @@ So you can use all of these in deploy.yml:
    ```
    <% Ruby code -- inline with output %>
    <%= Ruby expression -- replace with result %>
    ```
    ```

    ### Mounting files in accessories

    You can provide locally located file to be mounted as volume for the accessories.
    Files are uploaded and put into the home folder for SSH user.

    For example:

    ```yml
    service: test
    accessories:
    registry:
    image: registry:2
    host: *host
    port: 5000
    volumes:
    - registry:/var/lib/registry
    files:
    # Will be placed to ${USER}/test-registry folder
    # and mounted inside the container at the specified path
    - ./config/htpasswd:/etc/docker/registry/htpasswd
    env:
    clear:
    REGISTRY_HTTP_ADDR: 0.0.0.0:5000
    REGISTRY_AUTH: htpasswd
    REGISTRY_HTTP_SECRET: asecretforlocaldevelopment
    REGISTRY_AUTH_HTPASSWD_PATH: /etc/docker/registry/htpasswd
    REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
    ```
    When you do `mrsk accessory boot registry`

    It will upload the local file config/htpasswd to the host, and then launch docker with the --volume ${LOCALPATH}:/etc/docker/registry/htpasswd argument.
  8. @huksley huksley revised this gist Apr 19, 2023. 1 changed file with 18 additions and 1 deletion.
    19 changes: 18 additions & 1 deletion mrsk.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,11 @@ and also will read .env.staging file if it exists.

    https://github.com/mrsked/mrsk/blob/9ec3895dab2772915c44f3a348e54de58981857d/lib/mrsk/cli/base.rb#L34

    ## YAML anchors
    ### ENV vars

    Both .env and .env.#destination are loaded into process env vars. So you can naturally use just process env and tools like [chamber](https://github.com/segmentio/chamber) to load secrets.

    ### YAML anchors

    You can reference other parts of structure using `&anchor` and `*ancho` to keep to D.R.Y. principle,
    for example:
    @@ -25,4 +29,17 @@ accessories:
    redis:
    image: redis:latest
    host: *host
    ```

    ### Using vars in config/deploy.yml

    mrsk uses [ERB](https://docs.ruby-lang.org/en/2.3.0/ERB.html#class-ERB-label-Recognized+Tags) Ruby module to read config:

    https://github.com/mrsked/mrsk/blob/9ec3895dab2772915c44f3a348e54de58981857d/lib/mrsk/configuration.rb#L29

    So you can use all of these in deploy.yml:

    ```
    <% Ruby code -- inline with output %>
    <%= Ruby expression -- replace with result %>
    ```
  9. @huksley huksley created this gist Apr 19, 2023.
    28 changes: 28 additions & 0 deletions mrsk.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    # MRSK

    This documentation adds important additions to the docs for mrsk deploy tool (see github.com/mrsked/mrsk)

    ### Destination flag

    You can use `mrsk deploy --destination staging`

    This will read config/deploy.yml and config/deploy.staging.yml files,
    and also will read .env.staging file if it exists.

    https://github.com/mrsked/mrsk/blob/9ec3895dab2772915c44f3a348e54de58981857d/lib/mrsk/cli/base.rb#L34

    ## YAML anchors

    You can reference other parts of structure using `&anchor` and `*ancho` to keep to D.R.Y. principle,
    for example:

    ```
    servers:
    web:
    hosts:
    - &host 10.1.1.1
    accessories:
    redis:
    image: redis:latest
    host: *host
    ```