I’m trying to use caddy in conjunction with a statically built HTML website that is deployed using docker compose but I think I’ve set it up in a really convoluted manner.
1. Output of caddy version
:
Caddy 2.6
2. How I run Caddy:
a. System environment:
Debian v11 Bullseye
Docker Compose / Docker v20
b. Command:
docker compose up --build
c. Service/unit/compose file:
Docker compose that contains:
caddy:
image: caddy:2.6-alpine
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
client:
build:
context: ./client
ports:
- "3000:80"
The docker compose Caddyfile
http://frontend.webdomaintests.com {
# certificate recovery commented out
# tls my.address@inbox.com
# Another common task is to set up a reverse proxy:
reverse_proxy client:3000
}
I’m just trying to get this to work with regular http before I move everything over to SSL.
The dockerfile contains nothing special, it just copies over static html files
FROM base
WORKDIR /myapp
COPY --from=production-deps /myapp/node_modules /myapp/node_modules
COPY --from=build /myapp/dist /myapp/dist
ADD . .
FROM caddy:2.6-alpine
COPY Caddyfile /etc/caddy/Caddyfile
COPY --from=build /myapp/dist /srv
This single docker image also has a Caddyfile that looks like this:
:3000 {
# certificate recovery
# tls my.address@inbox.com
# Set this path to your site's directory.
root * /srv
# Enable the static file server.
file_server
encode gzip
@static {
file
path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.svg *.woff *.pdf *.webp
}
}
3. The problem I’m having:
I’ve tested this locally and can hit the domain http://frontend.webdomaintests.com
without any issues, but it feels weird to have to run caddy as a service at the compose level, and then caddy again in the docker file.
What happens when I make several docker compose (representing different projects)? Is it possible to not put Caddy in Docker (compose or regular docker) at all, and just have it installed on the VPS server itself?