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

Improve local backend detection #4006

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docker/Dockerfile.agent.alpine.multiarch
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
FROM docker.io/alpine:3.20
RUN apk add -U --no-cache ca-certificates
ENV GODEBUG=netdns=go
# Internal setting do NOT change! Signals that woodpecker is running inside a container
ENV WOODPECKER_IN_CONTAINER=true
EXPOSE 3000

COPY --from=build /src/dist/woodpecker-agent /bin/
Expand Down
2 changes: 2 additions & 0 deletions docker/Dockerfile.agent.multiarch
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ RUN mkdir -p /etc/woodpecker

FROM scratch
ENV GODEBUG=netdns=go
# Internal setting do NOT change! Signals that woodpecker is running inside a container
ENV WOODPECKER_IN_CONTAINER=true
EXPOSE 3000

# copy certs from build image
Expand Down
5 changes: 4 additions & 1 deletion pipeline/backend/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ func (e *local) Name() string {
}

func (e *local) IsAvailable(context.Context) bool {
return true
_, inContainer := os.LookupEnv("WOODPECKER_IN_CONTAINER")
// note: we don't need to check by args as this would indicate we are not in an container anyway ...
backend := os.Getenv("WOODPECKER_BACKEND")
return backend == "local" || !inContainer
}

func (e *local) Flags() []cli.Flag {
Expand Down