diff --git a/Dockerfile b/Dockerfile index f79d85f..8a73ca3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ COPY . . RUN dotnet publish ./AnalysisData/AnalysisData/AnalysisData.csproj -c Release -o out -FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS runtime WORKDIR /app COPY --from=build /app/out ./ @@ -16,6 +16,11 @@ ENV ASPNETCORE_ENVIRONMENT=Development ENV ASPNETCORE_URLS=http://*:80 EXPOSE 80 +COPY . ./app + +#RUN dotnet tool install --global dotnet-ef +#RUN export PATH="${PATH}:/root/.dotnet/tools" +#RUN dotnet ef database update --project AnalysisData/AnalysisData/AnalysisData.csproj # Start the application ENTRYPOINT ["dotnet", "AnalysisData.dll"] diff --git a/Dockerfile2 b/Dockerfile2 new file mode 100644 index 0000000..0f93fc6 --- /dev/null +++ b/Dockerfile2 @@ -0,0 +1,19 @@ +FROM mcr.microsoft.com/dotnet/sdk:8.0 + +RUN dotnet tool install --global dotnet-ef --version 8.0 +ENV PATH="${PATH}:/root/.dotnet/tools" + +WORKDIR /build + +# Copy solution file +#COPY ./AnalysisData/AnalysisData.sln ./ + +# Copy src .csproj files +#COPY ./AnalysisData/AnalysisData/AnalysisData.csproj ./src/AnalysisData/ + +# Copy everything and build +COPY . . + +WORKDIR /build + +CMD ["dotnet", "ef", "--project", "AnalysisData/AnalysisData/AnalysisData.csproj", "database", "update"] diff --git a/docker-compose.yaml b/docker-compose.yaml index c1b4209..0adeac6 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -10,22 +10,26 @@ services: volumes: - pgdata:/var/lib/postgresql/data + migrate: - image: mcr.microsoft.com/dotnet/sdk:8.0 #mcr.microsoft.com/dotnet/runtime:8.0-windowsservercore-ltsc2022 + #image: migrateimage + image: yaghooli/migrateimage:latest depends_on: - postgres - working_dir: /app - volumes: - - .:/app environment: ConnectionStrings__DefaultConnection: Host=postgres;Database=mohaymen;Username=postgres;Password=1234; - command: > - bash -c "dotnet tool install --global dotnet-ef && - export PATH=\"$PATH:/root/.dotnet/tools\" && - dotnet ef database update --project AnalysisData/AnalysisData/AnalysisData.csproj" + + admin: + image: adminer + restart: always + depends_on: + - postgres + ports: + - 8089:8080 web: image: yaghooli/dotnetdev:latest + #build: . depends_on: migrate: condition: service_completed_successfully @@ -37,3 +41,4 @@ services: volumes: pgdata: +