docker composes
This commit is contained in:
parent
71c4f5022c
commit
a90cdc08b8
9 changed files with 88 additions and 54 deletions
54
Dockerfile
54
Dockerfile
|
|
@ -1,32 +1,30 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
# Learn about building .NET container images:
|
||||
# https://github.com/dotnet/dotnet-docker/blob/main/samples/README.md
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
EXPOSE 443
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||
# Build stage
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
WORKDIR /src
|
||||
COPY ["/src", "/src"]
|
||||
COPY "Directory.Packages.props" "Directory.Packages.props"
|
||||
COPY . .
|
||||
RUN dotnet publish src/Yavsc/Yavsc.csproj -c Release -o /app/publish
|
||||
|
||||
RUN dotnet nuget add source https://isn.pschneider.fr/v3/index.json --allow-insecure-connections
|
||||
|
||||
# Just to see if two lines above work
|
||||
RUN dotnet nuget list source
|
||||
|
||||
RUN dotnet restore "/src/Yavsc/Yavsc.csproj"
|
||||
|
||||
# Copy source code and publish app
|
||||
|
||||
WORKDIR "/src/Yavsc"
|
||||
RUN dotnet build "Yavsc.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "Yavsc.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
# Runtime stage
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
|
||||
# Variables d'environnement avec valeurs par défaut
|
||||
ARG POSTGRES_HOST=localhost
|
||||
ARG POSTGRES_PORT=5432
|
||||
ARG POSTGRES_DB=yavsc
|
||||
ARG POSTGRES_USER=yavsc
|
||||
ARG POSTGRES_PASSWORD
|
||||
|
||||
ENV POSTGRES_HOST=${POSTGRES_HOST}
|
||||
ENV POSTGRES_PORT=${POSTGRES_PORT}
|
||||
ENV POSTGRES_DB=${POSTGRES_DB}
|
||||
ENV POSTGRES_USER=${POSTGRES_USER}
|
||||
ENV POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
|
||||
|
||||
# Chaîne de connexion construite depuis les variables
|
||||
ENV ConnectionStrings__DefaultConnection=\
|
||||
"Host=${POSTGRES_HOST};Port=${POSTGRES_PORT};Database=${POSTGRES_DB};Username=${POSTGRES_USER};Password=${POSTGRES_PASSWORD}"
|
||||
|
||||
COPY --from=build /app/publish .
|
||||
EXPOSE 5000
|
||||
ENTRYPOINT ["dotnet", "Yavsc.dll"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue