Publish the image on version tags and test what is delivered
A v* tag now builds, tries and publishes the image: the version must be the one of Directory.Build.props, latest only moves forward and the registry token is in one step, given to docker on its input. The same script works by hand. The image says its version and commit, and its health check also covers the engine loop and the live prices. The Unraid template is final: a test compares it with appendix E and with the variables the loader really reads, and another reads the workflow. refs #70 refs #71 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4d92a39fef
commit
3cd214ae78
16 files changed
+859
-27
No files matched your search
@@ -17,9 +17,11 @@ COPY docs/design/logo/ docs/design/logo/
|
||||
# The backtest outcomes are read at the first start (SPEC 12.3); .dockerignore lets only their JSON files through.
|
||||
COPY docs/backtests/ docs/backtests/
|
||||
COPY docs/learning/ docs/learning/
|
||||
RUN dotnet publish src/Anubis.Server/Anubis.Server.csproj -c Release --no-restore -o /app
|
||||
# The commit goes into the version shown by the diagnostics report; empty when not given.
|
||||
ARG ANUBIS_COMMIT=
|
||||
RUN dotnet publish src/Anubis.Server/Anubis.Server.csproj -c Release --no-restore -o /app ${ANUBIS_COMMIT:+-p:SourceRevisionId=$ANUBIS_COMMIT}
|
||||
# The guard (SPEC 9.3, ADR 0012) is the main process and starts the engine next to it, from the same folder.
|
||||
RUN dotnet publish src/Anubis.Guard/Anubis.Guard.csproj -c Release --no-restore -o /app
|
||||
RUN dotnet publish src/Anubis.Guard/Anubis.Guard.csproj -c Release --no-restore -o /app ${ANUBIS_COMMIT:+-p:SourceRevisionId=$ANUBIS_COMMIT}
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0
|
||||
WORKDIR /app
|
||||
@@ -35,7 +37,16 @@ EXPOSE 8787
|
||||
VOLUME /data
|
||||
# Starts as root only to give /data to PUID:PGID, then runs the guard as that user (entrypoint.sh); the guard starts
|
||||
# the engine. "docker run --rm <image> drill" runs the guard drill instead (issue #48).
|
||||
# Health through bash's /dev/tcp: no curl or wget in the image. 503 (database down) counts as unhealthy.
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
|
||||
# Health through bash's /dev/tcp: no curl or wget in the image. 503 (database down, loops stopped, no prices) counts as unhealthy.
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
||||
CMD ["bash", "-c", "exec 3<>/dev/tcp/127.0.0.1/${PORT:-8787} && printf 'GET /health HTTP/1.0\r\nHost: localhost\r\n\r\n' >&3 && head -n 1 <&3 | grep -q ' 200 '"]
|
||||
ENTRYPOINT ["anubis-entrypoint"]
|
||||
ARG ANUBIS_VERSION=dev
|
||||
ARG ANUBIS_COMMIT=
|
||||
LABEL org.opencontainers.image.title="Anubis" \
|
||||
org.opencontainers.image.description="Bot di trading personale: azioni USA e crypto spot, senza leva" \
|
||||
org.opencontainers.image.vendor="BalboSoft" \
|
||||
org.opencontainers.image.url="https://gitea.encke-hake.ts.net/BalboSoft/Anubis" \
|
||||
org.opencontainers.image.source="https://gitea.encke-hake.ts.net/BalboSoft/Anubis" \
|
||||
org.opencontainers.image.version="$ANUBIS_VERSION" \
|
||||
org.opencontainers.image.revision="$ANUBIS_COMMIT"
|
||||
@@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
# Publishes an image already built and tried (SPEC 15.5, ADR 0002 and 0020).
|
||||
# Usage: publish.sh <local image> <tag vX.Y.Z[-something]>
|
||||
# From the environment: REGISTRY, REGISTRY_USER, REGISTRY_TOKEN (write:package). The token reaches docker only on its
|
||||
# input and stays in a temporary folder removed at the end.
|
||||
set -eu
|
||||
|
||||
image="$1"
|
||||
tag="$2"
|
||||
root=$(cd "$(dirname "$0")/../.." && pwd)
|
||||
fail() {
|
||||
echo "Pubblicazione non riuscita: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
printf '%s\n' "$tag" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$' || fail "il tag '$tag' non è una versione (vX.Y.Z)."
|
||||
version=${tag#v}
|
||||
expected=$(sed -n 's:.*<Version>\(.*\)</Version>.*:\1:p' "$root/Directory.Build.props")
|
||||
[ "${version%%-*}" = "$expected" ] || fail "il tag $tag non corrisponde alla versione $expected di Directory.Build.props."
|
||||
[ -n "${REGISTRY:-}" ] || fail "manca REGISTRY."
|
||||
[ -n "${REGISTRY_USER:-}" ] || fail "manca REGISTRY_USER."
|
||||
[ -n "${REGISTRY_TOKEN:-}" ] || fail "manca il segreto REGISTRY_TOKEN (token Gitea con il permesso write:package)."
|
||||
name="$REGISTRY/balbosoft/anubis"
|
||||
|
||||
# latest moves only for the highest plain version among the tags of the repository.
|
||||
latest=""
|
||||
case "$version" in
|
||||
*-*) ;;
|
||||
*)
|
||||
tags=$(git -C "$root" ls-remote --tags --refs origin 'v*') || fail "non riesco a leggere i tag del repository."
|
||||
newest=$(printf '%s\n' "$tags" "x refs/tags/$tag" | sed -n 's:.*refs/tags/v\([0-9]*\.[0-9]*\.[0-9]*\)$:\1:p' | sort -t. -k1,1n -k2,2n -k3,3n | tail -n 1)
|
||||
if [ "$newest" = "$version" ]; then latest=1; fi
|
||||
;;
|
||||
esac
|
||||
|
||||
DOCKER_CONFIG=$(mktemp -d)
|
||||
export DOCKER_CONFIG
|
||||
trap 'rm -rf "$DOCKER_CONFIG"' EXIT
|
||||
printf '%s' "$REGISTRY_TOKEN" | docker login "$REGISTRY" --username "$REGISTRY_USER" --password-stdin
|
||||
docker tag "$image" "$name:$version"
|
||||
docker push "$name:$version"
|
||||
if [ -n "$latest" ]; then
|
||||
docker tag "$image" "$name:latest"
|
||||
docker push "$name:latest"
|
||||
fi
|
||||
|
||||
echo "Pubblicata $name:$version${latest:+ (e latest)}."
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
Anubis: bozza del template Docker per Unraid (si completa nella Fase 9).
|
||||
Anubis: template Docker per Unraid (SPEC 15.3, appendice E). Le istruzioni sono in docs/MANUALE.md.
|
||||
L'immagine e' pubblicata nel registry dei pacchetti di Gitea, sotto l'organizzazione BalboSoft.
|
||||
Copia il file in /boot/config/plugins/dockerMan/templates-user/ e scegli
|
||||
"anubis" tra i template nella scheda Docker di Unraid.
|
||||
|
||||
Reference in new issue
Block a user