feat: bootstrap solution, Docker image and Gitea pipelines (M0)
CI / Build and test (SQLite) (pull_request) Successful in 43s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / YAML check (pull_request) Successful in 15s
CI / Docker image (pull_request) Successful in 59s

Start development with the skeleton every later milestone builds on, so
that code, image and release path exist and are verified from day one.

- Khaemhat.sln with the ten projects of SPEC section 3 and six MSTest
  projects; shared build rules with warnings as errors, analyzers and
  Central Package Management restricted to the allowlist.
- Architecture tests and scripts/check-packages.sh fail on any project
  reference or package that SPEC does not allow.
- Khaemhat.Web serves an Italian "under construction" page with the
  official icons and version, plus /health/live, /health/ready and
  /health (ADR 0012); honours KHAEMHAT_URLS and KHAEMHAT_LOG_LEVEL.
- docker/Dockerfile (non-root app user aligned to PUID/PGID by the
  entrypoint, pg_dump 17, healthcheck, OCI and Unraid labels) and
  compose files for PostgreSQL and a standalone SQLite demo.
- Gitea Actions: ci.yml (build, tests, image smoke test, PostgreSQL
  16/17 on tags, YAML check), release.yml (image and release from a
  vX.Y.Z tag, skipping versions already published) and wiki.yml.
- Development scripts, VS Code launch/tasks for debugging, and ADR
  0012-0017 deciding the M0 open points of docs/STATUS.md.

Closes #1, #2, #3, #4, #5, #114

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-11 11:53:39 +01:00
1 parent 88de272b3e
commit 12277733f5
101 files changed
+3245 -67

No files matched your search

+90
View File
@@ -0,0 +1,90 @@
# syntax=docker/dockerfile:1
# Khaemhat image (SPEC §16.1, ADR 0009, 0010, 0013, 0015, 0016, 0017). Build from the repository root:
# docker build -f docker/Dockerfile --build-arg VERSION=0.0.1 --build-arg GIT_SHA=$(git rev-parse --short HEAD) .
ARG DOTNET_VERSION=10.0
# ---------------------------------------------------------------------------------------------------------------------
FROM mcr.microsoft.com/dotnet/sdk:${DOTNET_VERSION} AS build
ARG VERSION=0.0.0-dev
ARG GIT_SHA=unknown
ARG RUN_TESTS=false
ENV DOTNET_NOLOGO=1 DOTNET_CLI_TELEMETRY_OPTOUT=1 DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
WORKDIR /src
# Restore first, from the build files only, so the layer is reused while no project or package changes.
COPY global.json Directory.Build.props Directory.Build.targets Directory.Packages.props .editorconfig ./
COPY src/Khaemhat.Core/Khaemhat.Core.csproj src/Khaemhat.Core/
COPY src/Khaemhat.Fiscal.Abstractions/Khaemhat.Fiscal.Abstractions.csproj src/Khaemhat.Fiscal.Abstractions/
COPY src/Khaemhat.Fiscal.Italy/Khaemhat.Fiscal.Italy.csproj src/Khaemhat.Fiscal.Italy/
COPY src/Khaemhat.Data/Khaemhat.Data.csproj src/Khaemhat.Data/
COPY src/Khaemhat.Data.Sqlite/Khaemhat.Data.Sqlite.csproj src/Khaemhat.Data.Sqlite/
COPY src/Khaemhat.Data.PostgreSql/Khaemhat.Data.PostgreSql.csproj src/Khaemhat.Data.PostgreSql/
COPY src/Khaemhat.Infrastructure/Khaemhat.Infrastructure.csproj src/Khaemhat.Infrastructure/
COPY src/Khaemhat.Application/Khaemhat.Application.csproj src/Khaemhat.Application/
COPY src/Khaemhat.Web/Khaemhat.Web.csproj src/Khaemhat.Web/
RUN dotnet restore src/Khaemhat.Web/Khaemhat.Web.csproj
COPY . .
RUN bash scripts/check-packages.sh
RUN if [ "$RUN_TESTS" = "true" ]; then \
dotnet test Khaemhat.sln -c Release /p:Version="$VERSION" /p:SourceRevisionId="$GIT_SHA"; \
fi
RUN dotnet publish src/Khaemhat.Web/Khaemhat.Web.csproj -c Release -o /app --no-restore \
/p:Version="$VERSION" /p:SourceRevisionId="$GIT_SHA" /p:UseAppHost=false
# ---------------------------------------------------------------------------------------------------------------------
FROM mcr.microsoft.com/dotnet/aspnet:${DOTNET_VERSION} AS runtime
ARG VERSION=0.0.0-dev
ARG GIT_SHA=unknown
ARG CREATED=unknown
ARG SOURCE_URL=https://gitea.encke-hake.ts.net/BalboSoft/Khaemhat
ARG ICON_URL=https://gitea.encke-hake.ts.net/BalboSoft/Khaemhat/raw/branch/main/assets/icon-256.png
# OS tools allowed by SPEC §1.2 (not application components): pg_dump/pg_restore 17 from the PGDG repository (a
# client >= the server: works with PostgreSQL 16 and 17), curl for the health check, tzdata for TZ.
RUN set -eux; \
apt-get update; \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl tzdata; \
. /etc/os-release; \
install -d /usr/share/postgresql-common/pgdg; \
curl -fsSL -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc https://www.postgresql.org/media/keys/ACCC4CF8.asc; \
echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt ${VERSION_CODENAME}-pgdg main" \
> /etc/apt/sources.list.d/pgdg.list; \
apt-get update; \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends postgresql-client-17; \
rm -rf /var/lib/apt/lists/*; \
pg_dump --version
ENV ASPNETCORE_ENVIRONMENT=Production \
ASPNETCORE_HTTP_PORTS=8080 \
KHAEMHAT_DATA_DIR=/data \
DOTNET_NOLOGO=1 \
TZ=Europe/Rome
WORKDIR /app
COPY --from=build /app ./
COPY docker/entrypoint.sh /app/entrypoint.sh
COPY scripts/restore-system.sh /app/scripts/restore-system.sh
RUN chmod 0755 /app/entrypoint.sh /app/scripts/restore-system.sh \
&& install -d -o app -g app -m 0750 /data
LABEL org.opencontainers.image.title="Khaemhat" \
org.opencontainers.image.description="Gestionale ERP e CRM per PMI italiane" \
org.opencontainers.image.vendor="BalboSoft" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.revision="${GIT_SHA}" \
org.opencontainers.image.created="${CREATED}" \
org.opencontainers.image.source="${SOURCE_URL}" \
org.opencontainers.image.url="${SOURCE_URL}" \
org.opencontainers.image.documentation="${SOURCE_URL}/wiki" \
net.unraid.docker.icon="${ICON_URL}" \
net.unraid.docker.webui="http://[IP]:[PORT:8080]/"
VOLUME /data
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD curl -fs http://localhost:8080/health/live || exit 1
# Starts as root only to align the app user with PUID/PGID; the .NET process runs as "app" (ADR 0013).
ENTRYPOINT ["/app/entrypoint.sh"]