Files
soroush.asadi e73d47a875
CI/CD / CI · dotnet build (push) Successful in 40s
CI/CD / Deploy · drsousan (push) Successful in 15s
fix: remove apt-get curl install — use bash TCP health check instead
archive.ubuntu.com is unreachable from the build server, causing
apt-get to time out and fail every build. curl was only used for
the HEALTHCHECK. Replace with a zero-dependency bash TCP check:
  bash -c 'echo > /dev/tcp/localhost/8080'
No packages needed, no external network access required.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-06-02 16:03:08 +03:30

44 lines
1.6 KiB
Docker

# ── Stage 1: Build ────────────────────────────────────────────────────────────
FROM mirror.soroushasadi.com/dotnet/sdk:10.0 AS build
WORKDIR /src
# Restore dependencies first (layer-cache friendly)
COPY DrSousan.Api.csproj NuGet.Config ./
RUN ok=0; \
for i in 1 2 3 4 5; do \
dotnet restore DrSousan.Api.csproj --configfile NuGet.Config && ok=1 && break; \
echo "Restore attempt $i failed, retrying in 30s..."; sleep 30; \
done; \
[ "$ok" = "1" ]
# Copy everything and publish
COPY . .
RUN dotnet publish DrSousan.Api.csproj \
-c Release \
-o /app/publish \
--no-restore
# ── Stage 2: Runtime ──────────────────────────────────────────────────────────
FROM mirror.soroushasadi.com/dotnet/aspnet:10.0 AS runtime
WORKDIR /app
# Create directories for persistent volumes and set ownership
# .NET 10 aspnet image ships with a built-in non-root user "app" (uid 1654)
RUN mkdir -p /data /app/wwwroot/uploads
COPY --from=build /app/publish .
EXPOSE 8080
# /data → SQLite DB (mount as named volume)
# /app/wwwroot/uploads → uploaded images (mount as named volume)
VOLUME ["/data", "/app/wwwroot/uploads"]
ENV ASPNETCORE_URLS=http://+:8080
ENV ASPNETCORE_ENVIRONMENT=Production
HEALTHCHECK --interval=15s --timeout=10s --start-period=30s --retries=3 \
CMD bash -c 'echo > /dev/tcp/localhost/8080' || exit 1
ENTRYPOINT ["dotnet", "DrSousan.Api.dll"]