From bcad7e23c6b8ff36c990fa6700673c36d687bfb9 Mon Sep 17 00:00:00 2001 From: msm1984 Date: Thu, 5 Sep 2024 19:12:44 +0330 Subject: [PATCH] fix: fix some bugs in dockerfiles --- backend.Dockerfile | 12 +++++------- migrate.Dockerfile | 8 +++----- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/backend.Dockerfile b/backend.Dockerfile index a2c001b..0ed05f8 100644 --- a/backend.Dockerfile +++ b/backend.Dockerfile @@ -1,27 +1,25 @@ -# Use the official .NET SDK image to build the app FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /app -# Copy everything and restore as distinct layers + COPY . ./ RUN dotnet restore -# Build and publish the app to the out directory + RUN dotnet publish src/Web/Web.csproj -c Release -o out -# Use the official ASP.NET image to serve the app + FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime WORKDIR /app COPY --from=build /app/out ./ -# Environment variables for the database connection + ENV ASPNETCORE_ENVIRONMENT=Development -ENV ConnectionStrings__DefaultConnection=Host=db;Database=YourDatabaseName;Username=yourusername;Password=yourpassword ENV ASPNETCORE_URLS=http://*:80 EXPOSE 80 -# Start the application + ENTRYPOINT ["dotnet", "Web.dll"] diff --git a/migrate.Dockerfile b/migrate.Dockerfile index 2d4001d..719ed48 100644 --- a/migrate.Dockerfile +++ b/migrate.Dockerfile @@ -1,17 +1,15 @@ -# Use the .NET SDK image as the base image FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build -# Set the working directory inside the container + WORKDIR /app RUN dotnet tool install --global dotnet-ef -# Ensure the global tools are in the PATH + ENV PATH="$PATH:/root/.dotnet/tools" -# Copy the project files into the container + COPY . . -# Run the EF database update command directly CMD ["dotnet", "ef", "database", "update", "--project", "src/Infrastructure/Infrastructure.csproj", "--startup-project", "src/Web/Web.csproj"]