1. The problem I’m having:
Trying to build Caddy 2.6.4 using Docker and xcaddy (with the Cloudflare DNS module). The build works but the image is double the size of the version you can customize and download from the website (86MB vs 40MB).
I’m trying to learn how to run servers, use Docker/Podman, and a bunch of other things all at once. If this belongs in a Docker or xcaddy forum, please feel free to delete. I’m still new to all of this. I received great help a couple of weeks ago in this forum so I thought I would start here to see if anyone could help me understand what I’m missing.
2. Error messages and/or full log output:
No error messages. Full Github image build log can be viewed on Github.
3. Caddy version:
v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=
4. How I installed and ran Caddy:
I used the following multi-stage Dockerfile to keep the file size down (theoretically):
FROM caddy:2.6.4-builder-alpine AS build
RUN XCADDY_SKIP_CLEANUP=0 xcaddy build --with github.com/caddy-dns/cloudflare
FROM caddy:2.6.4-alpine AS final
COPY --from=build /usr/bin/caddy /usr/bin/caddy
a. System environment:
- Linode with Fedora 37 image—all software and security updates installed
- AMD EPYC 7713 64-Core Processor
- Podman: v4.4.2 w/ Go v1.19.6 for OS/Arch linux/amd64
b. Command:
I use Github actions to automatically build and tag my Docker images. This is the Github Action to build the image:
name: Docker Image
on:
push:
branches:
- main
- seed
tags:
- v*
pull_request:
env:
IMAGE_NAME: caddy-cf
jobs:
push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
This builds the image and then I pull and create a container. It runs great. Just curious about the file size differential.
podman pull ghcr.io/jaredhowland/caddy-cf:2.6.4
# Run with the following command:
caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
c. Service/unit/compose file:
Included above
d. My complete Caddy config:
Not relevant as Caddy runs perfectly. I can include it if it would really help. But the file size differential is there before even spinning up the container so that is my only problem. So it is more Caddy adjacent than necessarily a Caddy issue (but I don’t know enough to say for sure so I’m starting here).
5. Links to relevant resources:
All of this can be seen in my Github repository where I’m trying to create this:
https://github.com/jaredhowland/caddy-cloudflare
I know there are probably better ways of doing this, and several other projects that already do this, or similar things. But I’m trying to learn so that I can expand on this later and do things I haven’t seen in other projects.