33 lines
1.5 KiB
Docker
33 lines
1.5 KiB
Docker
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
|
WORKDIR /src
|
|
COPY API/API.csproj API/
|
|
COPY Application/Application.csproj Application/
|
|
COPY Domain/Domain.csproj Domain/
|
|
COPY Infrastructure/Infrastructure.csproj Infrastructure/
|
|
RUN dotnet restore API/API.csproj
|
|
COPY API/ API/
|
|
COPY Application/ Application/
|
|
COPY Domain/ Domain/
|
|
COPY Infrastructure/ Infrastructure/
|
|
RUN dotnet publish API/API.csproj -c Release -o /app/publish --no-restore /p:UseAppHost=false
|
|
|
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends curl ca-certificates gnupg \
|
|
&& install -d /usr/share/postgresql-common/pgdg \
|
|
&& curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail 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 $(. /etc/os-release && echo $VERSION_CODENAME)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
|
|
&& apt-get update \
|
|
&& apt-get install -y --no-install-recommends postgresql-client-17 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
WORKDIR /app
|
|
COPY --from=build /app/publish .
|
|
ENV ASPNETCORE_ENVIRONMENT=Production \
|
|
ASPNETCORE_HTTP_PORTS=8080
|
|
EXPOSE 8080
|
|
RUN mkdir -p /app/backups && chown $APP_UID:$APP_UID /app/backups
|
|
USER $APP_UID
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
|
|
CMD curl -fsS http://localhost:8080/health || exit 1
|
|
ENTRYPOINT ["dotnet", "API.dll"]
|