From 0e022b18a2b509cf75098e4243b4cc141132a6a2 Mon Sep 17 00:00:00 2001 From: aliyaghini <62905408+aliyaghini@users.noreply.github.com> Date: Thu, 15 Aug 2024 09:49:59 +0330 Subject: [PATCH] feat(dockercompose): initial dockercompose created * feat(dockercompose): first structure of dockercompose added * fix(dockercompse): dotenv image added * fix(dockercompose): container port changed --- Dockerfile | 2 +- docker-compose.yaml | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 docker-compose.yaml diff --git a/Dockerfile b/Dockerfile index 533e16f..f79d85f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ WORKDIR /app COPY --from=build /app/out ./ ENV ASPNETCORE_ENVIRONMENT=Development -#ENV ConnectionStrings__DefaultConnection=Host=db;Database=YourDatabaseName;Username=yourusername;Password=yourpassword +#ENV ConnectionStrings__DefaultConnection=Host=postgres;Database=mohaymen;Username=postgres;Password=1234; ENV ASPNETCORE_URLS=http://*:80 EXPOSE 80 diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..ef52896 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,39 @@ +services: + postgres: + image: postgres:15 + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: 1234 + POSTGRES_DB: mohaymen + ports: + - "5432:5432" + volumes: + - pgdata:/var/lib/postgresql/data + + migrate: + image: mcr.microsoft.com/dotnet/sdk:8.0 + 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" + + web: + image: yaghooli/dotnetdev:latest + depends_on: + migrate: + condition: service_completed_successfully + environment: + ASPNETCORE_ENVIRONMENT: Development + ConnectionStrings__DefaultConnection: Host=postgres;Database=mohaymen;Username=postgres;Password=1234; + ports: + - "8085:80" + +volumes: + pgdata: