test: build and verify addon runtime
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
# syntax=docker/dockerfile:1.7
|
||||
FROM golang:1.27.1-bookworm@sha256:69a7b9788769bec032d238959b61854e9ae87f57be9029ec04e9885fabf99195 AS stelloauth-builder
|
||||
|
||||
ARG TARGETARCH
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends ca-certificates git patch \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /src
|
||||
RUN git clone --filter=blob:none https://github.com/tamcore/stelloauth.git . \
|
||||
&& git checkout --detach 367d4f8c02a3b072c59142c49dffc129edc8548b \
|
||||
&& test "$(git rev-parse HEAD)" = "367d4f8c02a3b072c59142c49dffc129edc8548b"
|
||||
COPY patches/stelloauth-security.patch /tmp/stelloauth-security.patch
|
||||
RUN git apply --check /tmp/stelloauth-security.patch \
|
||||
&& git apply /tmp/stelloauth-security.patch \
|
||||
&& go test ./... \
|
||||
&& CGO_ENABLED=0 GOOS=linux GOARCH="$TARGETARCH" go build -trimpath -ldflags="-s -w" -o /out/stelloauth ./cmd/stelloauth
|
||||
|
||||
FROM cloakhq/cloakbrowser:0.5.10@sha256:2ed5b2d047cbdde22cde7ef1a796526c716aadaa5bccbe1db5ade49282b64a76
|
||||
|
||||
ARG BUILD_ARCH
|
||||
ARG BUILD_DATE
|
||||
ARG BUILD_DESCRIPTION="Local OAuth worker for Stellantis Vehicles using CloakBrowser"
|
||||
ARG BUILD_NAME="Stelloauth"
|
||||
ARG BUILD_REF
|
||||
ARG BUILD_REPOSITORY="https://git.radixadm.dk/dennis/homeassistant-stelloauth-addon"
|
||||
ARG BUILD_VERSION="0.1.0"
|
||||
LABEL io.hass.name="$BUILD_NAME" \
|
||||
io.hass.description="$BUILD_DESCRIPTION" \
|
||||
io.hass.arch="$BUILD_ARCH" \
|
||||
io.hass.type="addon" \
|
||||
io.hass.version="$BUILD_VERSION" \
|
||||
org.opencontainers.image.created="$BUILD_DATE" \
|
||||
org.opencontainers.image.revision="$BUILD_REF" \
|
||||
org.opencontainers.image.source="$BUILD_REPOSITORY" \
|
||||
org.opencontainers.image.version="$BUILD_VERSION"
|
||||
|
||||
USER root
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends patch \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
COPY patches/cloakserve-loopback.patch /tmp/cloakserve-loopback.patch
|
||||
RUN patch --dry-run -p2 -d /usr/local/bin < /tmp/cloakserve-loopback.patch \
|
||||
&& patch -p2 -d /usr/local/bin < /tmp/cloakserve-loopback.patch \
|
||||
&& rm /tmp/cloakserve-loopback.patch \
|
||||
&& apt-get purge -y --auto-remove patch \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=stelloauth-builder /out/stelloauth /usr/local/bin/stelloauth
|
||||
COPY rootfs/ /
|
||||
RUN chmod 0755 /usr/local/bin/stelloauth /usr/local/bin/addon-supervisor /usr/local/bin/cloakserve \
|
||||
&& mkdir -p /data /tmp/cloakserve \
|
||||
&& chmod 0700 /tmp/cloakserve
|
||||
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT []
|
||||
CMD ["/usr/local/bin/addon-supervisor"]
|
||||
@@ -31,6 +31,7 @@ CLOAK_COMMAND = [
|
||||
"--data-dir=/tmp/cloakserve",
|
||||
]
|
||||
STELLOAUTH_COMMAND = ["/usr/local/bin/stelloauth"]
|
||||
SHUTDOWN_GRACE_SECONDS = 9.0
|
||||
|
||||
|
||||
class ConfigError(RuntimeError):
|
||||
@@ -297,7 +298,7 @@ class ProcessManager:
|
||||
|
||||
def _begin_shutdown(self) -> None:
|
||||
if self._shutdown_deadline is None:
|
||||
self._shutdown_deadline = self._monotonic() + 10.0
|
||||
self._shutdown_deadline = self._monotonic() + SHUTDOWN_GRACE_SECONDS
|
||||
if not self._term_sent:
|
||||
self._signal_groups(signal.SIGTERM)
|
||||
self._term_sent = True
|
||||
|
||||
Reference in New Issue
Block a user