docker run -d -p 80:80 -p 443:443 files-nikiv-dev
8861c656d4e3cf8ad7b21bea3aadc957fc2e61cef83df31b1fbd59b85cd12757
But I don’t get what to do next.
Remember that you need to ensure your domain name files.nikiv.dev is correctly configured to point to the server where you're running your Caddy server. This would typically involve creating A (or AAAA for IPv6) record in your domain's DNS settings, pointing to the public IP address of your server.
ChatGPT said above but its confusing what that means. I have to go to cloudflare dashboard and do something? Edit more things in Caddyfile?
In your docker-compose.yml where you have image: you instead want to refer to the Dockerfile to build a custom container instead of pulling one from the registry. You’d use build: /path/to/folder.
Since I put my Dockerfile for Caddy right next to the docker-compose.yml file, in my case the context is the current folder, and in my Compose file looks like simply: build: .
And my Dockerfile looks something like:
FROM caddy:2.6.4-alpine-builder AS builder
RUN xcaddy build v2.6.4 \
--with github.com/caddy-dns/cloudflare
FROM caddy:2.6.4-alpine
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
There’s no need to start from caddy and copy files into builder and then back to caddy again. Just start from the builder and then go to caddy and you’ll have everything there, as it should inherit from caddy:2.6.4-alpine.
Since you’re relying on {env.CF_API_TOKEN} you’ll also need to make sure you add an environment: stanza in the Compose file, something like:
environment:
- "CF_API_TOKEN=44.."
Or use Docker secrets.
Once you’ve got build: in your Compose file, you run docker compose build caddy and it will run the Dockerfile. Then run docker compose up caddy and watch the first run to make sure it’s configured and gets a certificate correctly before daemonising it with -d.
This part sounds a little odd, though. Is this still a current issue with the Compose file in the repository you linked?