feat(Docker): add EF Core migrations

This commit is contained in:
shiyu
2025-05-24 16:51:11 +08:00
parent ab5351d250
commit 28ecc9615f

View File

@@ -16,7 +16,10 @@ COPY ["Foxel.csproj", "./"]
RUN dotnet restore "Foxel.csproj"
COPY . .
WORKDIR "/src/"
RUN dotnet tool install --global dotnet-ef
ENV PATH="${PATH}:/root/.dotnet/tools"
RUN dotnet build "./Foxel.csproj" -c $BUILD_CONFIGURATION -o /app/build
RUN dotnet ef migrations add InitialCreate
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
@@ -25,12 +28,13 @@ RUN dotnet publish "./Foxel.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:U
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
COPY --from=build /src/Migrations /app/Migrations
RUN apt-get update && apt-get install -y nginx && rm -rf /var/lib/apt/lists/*
COPY --from=build-frontend /src/Web/dist /var/www/html
COPY /Web/nginx.conf /etc/nginx/nginx.conf
RUN mkdir -p /var/lib/nginx/body /var/cache/nginx /var/run/nginx /app/Uploads \
&& chown -R $APP_UID:$APP_UID /var/lib/nginx /var/cache/nginx /var/run/nginx /var/log/nginx /etc/nginx /var/www/html /app/Uploads \
&& chown -R $APP_UID:$APP_UID /var/lib/nginx /var/cache/nginx /var/run/nginx /var/log/nginx /etc/nginx /var/www/html /app/Uploads /app/Migrations \
&& mkdir -p /run \
&& chmod 777 /run