diff --git a/ciwindows.Dockerfile b/ciwindows.Dockerfile index 3817878..d8d5bd1 100644 --- a/ciwindows.Dockerfile +++ b/ciwindows.Dockerfile @@ -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 diff --git a/internal/config/config.go b/internal/config/config.go index b41e298..f59039a 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -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)