Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for running Caddy in Docker #296

Open
lodi-g opened this issue Jul 2, 2023 · 2 comments
Open

Documentation for running Caddy in Docker #296

lodi-g opened this issue Jul 2, 2023 · 2 comments
Labels
🛠 type/feature request Requests or implements a new feature

Comments

@lodi-g
Copy link

lodi-g commented Jul 2, 2023

Problem
I have not installed Caddy on my dev machine and do not wish to do so. However, I still want to use caddy fmt.
It's easy to run it manually via Docker but doesn't leverage the full features of this extension.

Solution
I wrote a super simple wrapper script to make this extension work with a dockerized Caddy. It could be interesting to add it to the documentation. It works on MacOS (and most likely on Linux, not tested).

#!/usr/bin/env bash

cat /dev/stdin | docker run --rm -i --entrypoint caddy caddy:2.6-alpine "$@"

Once the script is set up somewhere, just point caddy.executable to it and it works.

@lodi-g lodi-g added the 🛠 type/feature request Requests or implements a new feature label Jul 2, 2023
@Zenuncl
Copy link

Zenuncl commented Jul 18, 2023

I tested it on a Remote SSH editor and it doesn't work well. Not sure why.

After reading the code about using caddy fmt and tested on my vm, i think cat /dev/stdin isn't necessary in this case.

@DevDorrejo
Copy link

DevDorrejo commented Feb 23, 2024

I am tying this too:

this is my code:

cat >/usr/bin/caddy <<EOF
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
podman run --rm -i docker.io/caddy:latest caddy "$@"
EOF

chmod +x /usr/bin/caddy

this will create a file reference for caddy, using this with the extension work

pwd: ${HOME}/caddytxt

inside this folder I have a Caddyfile and executing

caddy fmt --overwrite will edit the file and fix the format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛠 type/feature request Requests or implements a new feature
Projects
None yet
Development

No branches or pull requests

3 participants