caddy-docker icon indicating copy to clipboard operation
caddy-docker copied to clipboard

Cannot install plugin ratelimit

Open lpellegr opened this issue 5 years ago • 13 comments

Here is the command used:

docker build --build-arg plugins=ratelimit -t local/caddy github.com/abiosoft/caddy-docker.git

and the ouput error:

can't load package: package caddy: ratelimit.go:2:10: invalid import path: "" error at 'building caddy'

The plugin name ratelimit is found when I test with caddyplug install ratelimit.

Any idea what the problem is? how can I build this great caddy image with the ratelimit plugin?

lpellegr avatar Sep 18 '19 20:09 lpellegr

Did something upstream break the build system? I was getting this with plugins="git,login,jwt" and so I tried:

  caddy:
    image: abiosoft/caddy
    build:
      context: https://github.com/abiosoft/caddy-docker.git
      # args:
        # - plugins="git,login,jwt"
        # - enable_telemetry="false"
    restart: unless-stopped
    ...

i.e. default build variables. I got:

...
can't load package: package caddy: 
cors.go:2:10: invalid import path: ""
error at 'building caddy'
ERROR: Service 'caddy' failed to build: The command '/bin/sh -c VERSION=${version} PLUGINS=${plugins} ENABLE_TELEMETRY=${enable_telemetry} /bin/sh /usr/bin/builder.sh' returned a non-zero code: 1

jeslinmx avatar Sep 19 '19 09:09 jeslinmx

@abiosoft Any idea what the problem is?

lpellegr avatar Sep 19 '19 18:09 lpellegr

I'm experiencing this too, with cors, expires and git plugins. I've tried updating from 1.0.1 to 1.0.3 and no luck.

Has previously been working on a slight variation of the Dockerfile-no-stats, now with no changes it suddenly won't build.

andrewandante avatar Sep 20 '19 09:09 andrewandante

For reference, my dockerfile is

#
# Builder copied and amended from https://github.com/abiosoft/caddy-docker/blob/master/Dockerfile-no-stats
#
FROM abiosoft/caddy:builder as builder

ARG version="1.0.3"
ARG plugins="realip,expires,cache,ipfilter"

# process wrapper
RUN go get -v github.com/abiosoft/parent

RUN VERSION=${version} PLUGINS=${plugins} ENABLE_TELEMETRY=false /bin/sh /usr/bin/builder.sh

#
# Final stage
#
FROM alpine:3.10
LABEL maintainer "Abiola Ibrahim <[email protected]>"

ARG version="1.0.3"
LABEL caddy_version="$version"

# Let's Encrypt Agreement
ENV ACME_AGREE="false"

# Telemetry Stats
ENV ENABLE_TELEMETRY="false"

RUN apk add --no-cache \
    ca-certificates \
    git \
    mailcap \
    openssh-client \
    tzdata

# install caddy
COPY --from=builder /install/caddy /usr/bin/caddy

# validate install
RUN /usr/bin/caddy -version
RUN /usr/bin/caddy -plugins

## Only expose 80
EXPOSE 80
WORKDIR /srv

# Set up our config and log file dirs
COPY ./conf/Caddyfile /etc/Caddyfile
RUN mkdir -p /etc/caddy/imports
COPY ./conf/imports/* /etc/caddy/imports/
COPY ./healthz.html /srv/healthz/index.html
COPY ./healthz.html /srv/index.html
COPY ./forbidden.html /srv/forbidden.html

# install process wrapper
COPY --from=builder /go/bin/parent /bin/parent

ENTRYPOINT ["/bin/parent", "caddy"]
CMD ["--conf", "/etc/Caddyfile", "--log", "stdout", "--agree=$ACME_AGREE"]

and my error output is similar:

go: extracting gopkg.in/yaml.v2 v2.2.2
can't load package: package caddy:
expires.go:2:10: invalid import path: ""
error at 'building caddy'
ERROR: Service 'caddy' failed to build: The command '/bin/sh -c VERSION=${version} PLUGINS=${plugins} ENABLE_TELEMETRY=false /bin/sh /usr/bin/builder.sh' returned a non-zero code: 1

andrewandante avatar Sep 20 '19 09:09 andrewandante

Let me try to reproduce this.

abiosoft avatar Sep 20 '19 09:09 abiosoft

@abiosoft Did you succeed to reproduce the issue?

lpellegr avatar Sep 26 '19 12:09 lpellegr

I have the same problem since last week. But I'm wondering that this breaks because there was no new changes in the builder image.

flecno avatar Sep 26 '19 18:09 flecno

Small update from me - I had to rebuild it quickly, so ended up using the Dockerfile from https://hub.docker.com/r/productionwentdown/caddy/dockerfile as my base. However, what I did notice was this: https://github.com/productionwentdown/caddy/issues/4#issuecomment-508986178

Basically, you have to use the full name of the package, such as "github.com/captncraig/caddy-realip"

Mine is now up and running so I won't be re-trying this one, but it might be worth a quick test with the full plugin name, to see if that fixes it.

andrewandante avatar Sep 27 '19 09:09 andrewandante

Some things have changed since the release of Caddy 2 beta. I'm working on updating caddy-docker to be compatible with Caddy 2. After that, these issues would be resolved.

abiosoft avatar Sep 28 '19 07:09 abiosoft

i've started seeing the same with other plugins too but wasn't able to get it working with @andrewandante's workaround.

@abiosoft anything we can do to help?

mcfilib avatar Oct 07 '19 09:10 mcfilib

FYI, the change proposed in https://github.com/abiosoft/caddy-docker/pull/223 as a workaround allows building an image with the desired plugins.

lpellegr avatar Oct 07 '19 11:10 lpellegr

@lpellegr aha, thanks for pointing that out!

mcfilib avatar Oct 07 '19 12:10 mcfilib

Can confirm this fixes the issue for me.

elsbrock avatar Oct 13 '19 11:10 elsbrock