Skip to content

Commit

Permalink
Improved Local backend detection (#4006)
Browse files Browse the repository at this point in the history
Co-authored-by: 6543 <6543@obermui.de>
  • Loading branch information
zc-devs and 6543 authored Aug 7, 2024
1 parent 2081ca8 commit 6c9469f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
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

0 comments on commit 6c9469f

Please sign in to comment.