1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-24 08:02:18 +02:00

Improved Local backend detection (#4006)

Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
Thomas Anderson 2024-08-07 13:04:10 +03:00 committed by GitHub
parent 2081ca85db
commit 6c9469f610
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

View File

@ -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/

View File

@ -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

View File

@ -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 {