Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary fix: check import_package before writing #223

Closed
wants to merge 1 commit into from
Closed

Temporary fix: check import_package before writing #223

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Sep 21, 2019

This pull request tries to fix invalid import path: "" (related issues: #222 #220 )

I've noticed this behavior recently in my build pipline and tried caddyplug package alone: it fails for the first one or two times and works all the following try.

I've checked the source code, but found nothing could result this behavior, so I decide to make this temporary fix, hope this will work for everyone else.

@gabegundy
Copy link

gabegundy commented Sep 22, 2019

Just FYI, this didn't work for me. Fails in the same way that master does.

docker build --build-arg \
    plugins="git,cors,realip,expires,cache,googlecloud" \
    github.com/abiosoft/caddy-docker.git#pull/223/head

...

can't load package: package caddy: 
cors.go:2:10: invalid import path: ""
error at 'building caddy'
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

@ghost
Copy link
Author

ghost commented Sep 23, 2019

@gabegundy you have to rebuild abiosoft/caddy:builder first, the builder.sh is bundled inside it.

@jffin
Copy link

jffin commented Sep 23, 2019

Hello, can you make an advice please
is there a way to use your pull in DockerFile?

RUN go get -v github.com/abiosoft/parent

As i understand builder.sh is downloading here
but how can be downloaded your pull instead?

@ghost
Copy link
Author

ghost commented Sep 23, 2019

@jffin just replace builder.sh in the abiosoft/caddy:builder, if you are using the default dockerfile in this repo, here is the example:

#
# Builder
#
FROM abiosoft/caddy:builder

# add this line before you run `/bin/sh /usr/bin/builder.sh`
ADD https://raw.githubusercontent.com/jeffreystoke/caddy-docker/master/builder/builder.sh /usr/bin/builder.sh

# ... 

#
# Final stage
#
FROM alpine:3.10

# ...

@jffin
Copy link

jffin commented Sep 23, 2019

it works
thanks a lot

@tobiasmuehl
Copy link

Gets stuck forever here:

starting stage: installing plugin helper
go get: warning: modules disabled by GO111MODULE=auto in GOPATH/src;
        ignoring go.mod;
        see 'go help modules'
github.com/abiosoft/caddyplug (download)
github.com/abiosoft/errs (download)
github.com/fatih/color (download)
Fetching https://golang.org/x/sys/unix?go-get=1
Parsing meta tags from https://golang.org/x/sys/unix?go-get=1 (status code 200)
get "golang.org/x/sys/unix": found meta tag get.metaImport{Prefix:"golang.org/x/sys", VCS:"git", RepoRoot:"https://go.googlesource.com/sys"} at https://golang.org/x/sys/unix?go-get=1
get "golang.org/x/sys/unix": verifying non-authoritative meta tag
Fetching https://golang.org/x/sys?go-get=1
Parsing meta tags from https://golang.org/x/sys?go-get=1 (status code 200)
golang.org/x/sys (download)
github.com/abiosoft/errs
github.com/fatih/color/vendor/github.com/mattn/go-isatty
golang.org/x/sys/unix
github.com/abiosoft/caddyplug/internal
github.com/fatih/color/vendor/github.com/mattn/go-colorable
github.com/fatih/color
github.com/abiosoft/caddyplug/caddyplug
finished stage: installing plugin helper ✓


starting stage: fetching dns plugin sources
Cloning into '/dnsproviders'...
finished stage: fetching dns plugin sources ✓


starting stage: generating plugins

@ghost
Copy link
Author

ghost commented Sep 23, 2019

@tobiasmuehl that could happen since there is no limit to the retry, can you make sure your plugin is properly annotated with package here: https://github.com/caddyserver/caddy/blob/96579b97f687c95aeb85f09029d48122d84c668e/caddyhttp/httpserver/plugin.go#L626

Note: change the file version to match yours.

@tobiasmuehl
Copy link

@jeffreystoke That explains it, the redis plugin is missing from the list. Using the build service from caddyserver.com for now but would prefer to self-build.

@tobiasmuehl
Copy link

Redis is a clustering plugin so it probably belongs somewhere else, not in directives.

// directives is the list of all directives known to exist for the
// http server type, including non-standard (3rd-party) directives.

@gabegundy
Copy link

@tobiasmuehl I see that now. Thanks. I reworked the build to be muti-stage (seems cleaner anyway) and it works great. Thanks.

@SimJoSt
Copy link

SimJoSt commented Apr 11, 2020

Unfortunately it doesn't seem to work anymore. I just tried it with the Dockerfile snippet and didn't have any luck.

@sparampalli
Copy link

@tobiasmuehl that could happen since there is no limit to the retry, can you make sure your plugin is properly annotated with package here: https://github.com/caddyserver/caddy/blob/96579b97f687c95aeb85f09029d48122d84c668e/caddyhttp/httpserver/plugin.go#L626

Note: change the file version to match yours.

Redis is a clustering plugin so it probably belongs somewhere else, not in directives.

// directives is the list of all directives known to exist for the
// http server type, including non-standard (3rd-party) directives.

Hi,

I am also running into the same issue. Can you please elaborate on the steps that you followed?

@aguglie
Copy link

aguglie commented Jun 15, 2020

Anyone managed to solve?
@jeffreystoke 's fix seems not to be working anymore:

docker build --build-arg \
    plugins=git \
    github.com/jeffreystoke/caddy-docker.git

Got same error:

can't load package: package caddy: 
git.go:2:10: invalid import path: ""
error at 'building caddy'
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

@tobiasmuehl
Copy link

@sparampalli I'm not self building, using the commercial installer provided. Here's my dockerfile:

FROM alpine

RUN apk update && apk add bash curl
RUN curl https://getcaddy.com | bash -s personal redis
ADD Caddyfile /etc/Caddyfile
ENTRYPOINT ["caddy"]
CMD ["--conf", "/etc/Caddyfile", "--agree=true"]

@oslah212
Copy link

oslah212 commented Dec 8, 2020

Someone managed to solve this problem.
I can't build.
I've tried using the script above but it freezes when loading the plugins.

It only works with the "cloudflare" plugin, but I need to include other plugins.

Does anyone find a solution to this error?

@aguglie
Copy link

aguglie commented Dec 8, 2020

@oslah212 i found no way. I solved it bundling the pre-compiled Caddy executable in the docker container. Dirty fix but needed.

@oslah212
Copy link

oslah212 commented Dec 9, 2020

hi @Guglio95 . How can I solve it this way? My goal is to use it with some additional plugins.

@ghost
Copy link

ghost commented Dec 9, 2020

When I want to use plugin namesilo, i build caddy in this way. Hope it would help.

#
FROM abiosoft/caddy:builder as builder1

ARG version="1.0.3"
ARG plugins="namesilo"

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

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

@tobiasmuehl
Copy link

Please note that this issue was created for Caddy 1, not Caddy 2.

@aguglie
Copy link

aguglie commented Dec 11, 2020

@oslah212 you should get the Caddy v1 binary, or compile it by yourself if you need additional plugins.
Then you should create a docker container bundling in it the compiled executable.
This is a bad trick, but I needed to get it working; then I migrated to Caddy v2 😄

FROM alpine:3.10

ADD caddy /usr/bin/caddy
COPY Caddyfile /etc/Caddyfile

VOLUME /root/.caddy
VOLUME /var/log

ENTRYPOINT ["/bin/sh"]
CMD ["/usr/bin/caddy", "--conf", "/etc/Caddyfile", "--log", "stdout", "--agree=false"]

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants