Xcaddy Build with Docker Issues

1. The problem I’m having:

Can’t built xcaddy with plugin via docker.

I need this for running in AWS EC2 with dynamoDb.

2. Error messages and/or full log output:

1746.3 get "bazil.org/fuse": found meta tag vcs.metaImport{Prefix:"bazil.org/fuse", VCS:"git", RepoRoot:"https://github.com/bazil/fuse"} at //bazil.org/fuse?go-get=1
1747.0 get "cloud.google.com/go/firestore": found meta tag vcs.metaImport{Prefix:"cloud.google.com/go", VCS:"git", RepoRoot:"https://github.com/googleapis/google-cloud-go"} at //cloud.google.com/go/firestore?go-get=1
1747.0 get "cloud.google.com/go/firestore": verifying non-authoritative meta tag
1747.2 get "golang.org/x/xerrors": found meta tag vcs.metaImport{Prefix:"golang.org/x/xerrors", VCS:"git", RepoRoot:"https://go.googlesource.com/xerrors"} at //golang.org/x/xerrors?go-get=1
1749.1 get "golang.org/x/exp": found meta tag vcs.metaImport{Prefix:"golang.org/x/exp", VCS:"git", RepoRoot:"https://go.googlesource.com/exp"} at //golang.org/x/exp?go-get=1
1764.6 go: github.com/caddyserver/caddy/v2@v2.7.6 requires
1764.6 	github.com/go-kit/kit@v0.10.0 requires
1764.6 	sourcegraph.com/sourcegraph/appdash@v0.0.0-20190731080439-ebfcffb1b5c0: unrecognized import path "sourcegraph.com/sourcegraph/appdash": reading https://sourcegraph.com/sourcegraph/appdash?go-get=1: 404 Not Found
1764.6 2023/12/27 09:48:33 [FATAL] exit status 1
------
Dockerfile:12
--------------------
  11 |     
  12 | >>> RUN mkdir -p /tmp/caddy-build && \
  13 | >>>   GOOS=${OS} xcaddy build ${CADDY_VERSION} --with github.com/ss098/certmagic-s3 \
  14 | >>>     --with github.com/silinternational/certmagic-storage-dynamodb/v3 \
  15 | >>>         --output /tmp/caddy-build/aws_caddy_${CADDY_VERSION}_${OS}
--------------------
ERROR: failed to solve: process "/bin/sh -c mkdir -p /tmp/caddy-build &&   GOOS=${OS} xcaddy build ${CADDY_VERSION} --with github.com/ss098/certmagic-s3     --with github.com/silinternational/certmagic-storage-dynamodb/v3         --output /tmp/caddy-build/aws_caddy_${CADDY_VERSION}_${OS}" did not complete successfully: exit code: 1

3. Caddy version:

v2.7.6

4. How I installed and ran Caddy:

a. System environment:

b. Command:

#!/usr/bin/env bash

set -e

# Set OS (first script argument)
OS=${1:-linux}

# Set Caddy version (second script argument)
CADDY_VERSION=${2:-v2.7.6}

# Create release folders
mkdir -p $PWD/releases $PWD/temp_release

# Run build
docker build --build-arg OS=$OS --build-arg CADDY_VERSION=$CADDY_VERSION -t custom-caddy-build .

# Copy release from image to temporary folder
docker run -v $PWD/temp_release:/opt/mount --rm -ti custom-caddy-build bash -c "cp /tmp/caddy-build/* /opt/mount/"

c. Service/unit/compose file:

FROM amazonlinux:2023

ARG CADDY_VERSION=v2.7.6
ARG OS=linux

# Install dependencies
RUN yum update -y && \
  yum install golang -y

RUN GOBIN=/usr/local/bin/ go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest

RUN mkdir -p /tmp/caddy-build && \
  GOOS=${OS} xcaddy build ${CADDY_VERSION} --with github.com/ss098/certmagic-s3 \
    --with github.com/silinternational/certmagic-storage-dynamodb/v3 \
        --output /tmp/caddy-build/aws_caddy_${CADDY_VERSION}_${OS}

You’re using amazonlinux, which is based on RedHat/CentOS. They set GOPROXY to direct to disable the global Go Module Proxy and causes build failures when packages disappear, such as in your case with sourcegraph.com/sourcegraph/appdash. See:

https://bugzilla.redhat.com/show_bug.cgi?id=1794110

https://www.mail-archive.com/golang@lists.fedoraproject.org/msg14364.html

I recommend you use our -builder variant Docker images instead of hacking your own. Look for the section Adding custom Caddy modules on this page.

https://hub.docker.com/_/caddy/

Ya can understand but cant use this directly in the AWS EC2,

He somehow used the same method to build which is not working for me,
here is the link for the repo: GitHub - tobilg/aws-caddy-build

I’m not sure how they managed to build it, but you should be able to build it by setting the GOPROXY environment variable inside the image/container to GOPROXY=https://proxy.golang.org,direct. That should resolve it. Give it a shot and report back.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.