fix(docker): windows container (#1710)

* Update ciwindows.Dockerfile
This commit is contained in:
Kyle Sanderson 2024-09-09 01:18:31 -07:00 committed by GitHub
parent 80426e4773
commit e603b262f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 11 deletions

View file

@ -26,24 +26,24 @@ export GOARCH=$TARGETARCH; \
[[ "$GOARCH" == "arm" ]] && [[ "$TARGETVARIANT" == "v6" ]] && export GOARM=6; \
[[ "$GOARCH" == "arm" ]] && [[ "$TARGETVARIANT" == "v7" ]] && export GOARM=7; \
echo $GOARCH $GOOS $GOARM$GOAMD64; \
go build -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${REVISION} -X main.date=${BUILDTIME}" -o /out/bin/autobrr cmd/autobrr/main.go && \
go build -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${REVISION} -X main.date=${BUILDTIME}" -o /out/bin/autobrrctl cmd/autobrrctl/main.go
go build -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${REVISION} -X main.date=${BUILDTIME}" -o /out/bin/autobrr.exe cmd/autobrr/main.go && \
go build -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${REVISION} -X main.date=${BUILDTIME}" -o /out/bin/autobrrctl.exe cmd/autobrrctl/main.go
# build runner
FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 AS runner
FROM mcr.microsoft.com/windows/nanoserver:ltsc2019 AS runner
LABEL org.opencontainers.image.source="https://github.com/autobrr/autobrr"
LABEL org.opencontainers.image.licenses="GPL-2.0-or-later"
LABEL org.opencontainers.image.base.name="mcr.microsoft.com/windows/nanoserver:ltsc2022"
LABEL org.opencontainers.image.base.name="mcr.microsoft.com/windows/nanoserver:ltsc2019"
ENV HOME="/config" \
XDG_CONFIG_HOME="/config" \
XDG_DATA_HOME="/config"
ENV HOME="C:\config" \
XDG_CONFIG_HOME="C:\config" \
XDG_DATA_HOME="C:\config"
WORKDIR /app
VOLUME /config
WORKDIR "C:\\app"
VOLUME "C:\\config"
EXPOSE 7474
COPY --link --from=app-builder /out/bin/autobrr* /
COPY --from=app-builder /out/bin/autobrr* /
ENTRYPOINT ["/autobrr", "--config", "/config"]
ENTRYPOINT C:\autobrr.exe --config C:\config

View file

@ -130,6 +130,15 @@ func (c *AppConfig) writeConfig(configPath string, configFile string) error {
// but there's a good chance this is an isolated namespace
// or a container.
host = "0.0.0.0"
} else if user := os.Getenv("USERNAME"); user == "ContainerAdministrator" || user == "ContainerUser" {
/* this is the correct code below, but golang helpfully Panics when it can't find netapi32.dll
the issue was first reported 7 years ago, but is fixed in go 1.24 where the below code works.
*/
/*
u, err := user.Current(); err == nil && u != nil &&
(u.Name == "ContainerAdministrator" || u.Name == "ContainerUser") {
// Windows conatiners run containers as ContainerAdministrator by default */
host = "0.0.0.0"
} else if pd, _ := os.Open("/proc/1/cgroup"); pd != nil {
defer pd.Close()
b := make([]byte, 4096)