diff --git a/.gitea/workflows/merge.yaml b/.gitea/workflows/merge.yaml index 29f0a3b..9d6e170 100644 --- a/.gitea/workflows/merge.yaml +++ b/.gitea/workflows/merge.yaml @@ -1,34 +1,40 @@ -name: "Main Build Process" +name: "Generation data pour merge sur master" -# Runs on main branch commits, -# every commit in a pull request, any published release. on: push: branches: ["main"] pull_request: + types: + - closed branches: ["main"] release: types: [published] jobs: - asciidoc: - name: "generate documentation" + generateData: + if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Get build container - id: adocbuild - uses: tonynv/asciidoctor-action@master - with: - program: "asciidoctor -D docs --backend=html5 -o index.html documentation/readme.adoc" - - name: Print execution time - run: echo "Time ${{ steps.adocbuild.outputs.time }}" - - name: Deploy docs to ghpages - uses: actions/upload-artifact@v3 - with: - name: Doc - path: ./docs - retention-days: 5 + - name: Checkout code + uses: actions/checkout@v2 + - name: Get build container + id: adocbuild + uses: tonynv/asciidoctor-action@master + with: + program: "asciidoctor -D docs --backend=html5 -o index.html documentation/readme.adoc" + - name: Print execution time + run: echo "Time ${{ steps.adocbuild.outputs.time }}" + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: Doc + path: ./docs + retention-days: 5 + - name: build docker images + run: docker build -t gitea.borealian.ovh/mcmuzzle/ludikzone:latest -f ./docker-prod/Dockerfile . + - name: upload image + run: | + echo "${{ secrets.PERSO_GITEAPASSWORD}}" | docker login gitea.borealian.ovh --username mcmuzzle --password-stdin + docker push gitea.borealian.ovh/mcmuzzle/ludikzone:latest diff --git a/.gitea/workflows/review.yaml b/.gitea/workflows/review.yaml new file mode 100644 index 0000000..c29cb76 --- /dev/null +++ b/.gitea/workflows/review.yaml @@ -0,0 +1,27 @@ +name: "Generation data pour merge sur master" + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + + reviewProcess: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Setup dotnet + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' + - name: Install dependencies + run: dotnet restore ./src/LudikZone.sln + - name: Build + run: dotnet build ./src/LudikZone.sln + - name: Test with the dotnet CLI + run: dotnet test ./src/LudikZone.sln + diff --git a/.gitignore b/.gitignore index 17e658c..1df4381 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ tools/ TestResults #docker data -/docker-dev/data \ No newline at end of file +/docker-dev/data +/docker-prod/data \ No newline at end of file diff --git a/docker-prod/.env b/docker-prod/.env new file mode 100644 index 0000000..b496967 --- /dev/null +++ b/docker-prod/.env @@ -0,0 +1,5 @@ +DB_HOST="postgresql" +DB_PORT=5432 +DB_USER="admin" +DB_PASSWORD="admin" +DB_DATABASE="ludikZone" \ No newline at end of file diff --git a/docker-prod/.env.example b/docker-prod/.env.example new file mode 100644 index 0000000..a9f8a9c --- /dev/null +++ b/docker-prod/.env.example @@ -0,0 +1,5 @@ +DB_HOST="localhost" +DB_PORT=5432 +DB_USER="admin" +DB_PASSWORD="admin" +DB_DATABASE="ludikZone" \ No newline at end of file diff --git a/docker-prod/Dockerfile b/docker-prod/Dockerfile new file mode 100644 index 0000000..df86a26 --- /dev/null +++ b/docker-prod/Dockerfile @@ -0,0 +1,21 @@ +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +WORKDIR /app +EXPOSE 80 +EXPOSE 443 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /src +COPY ["src/LudikZoneBlazor/LudikZoneBlazor.csproj", "src/LudikZoneBlazor/LudikZoneBlazor.csproj"] +RUN dotnet restore "src/LudikZoneBlazor/LudikZoneBlazor.csproj" +COPY src src +RUN ls -a -l +RUN dotnet build "src/LudikZoneBlazor/LudikZoneBlazor.csproj" -c Release -o /app/build + +FROM build AS publish +WORKDIR /src +RUN dotnet publish "src/LudikZoneBlazor/LudikZoneBlazor.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "LudikZoneBlazor.dll"] \ No newline at end of file diff --git a/docker-prod/compose.yml b/docker-prod/compose.yml new file mode 100644 index 0000000..6b1b7ba --- /dev/null +++ b/docker-prod/compose.yml @@ -0,0 +1,24 @@ +services: + postgresql: + image: postgres:16 + ports: + - "${DB_PORT:-5432}:5432" + volumes: + - ./data/postgres/:/var/lib/postgresql/data + environment: + - POSTGRES_DB=${DB_DATABASE:-ludikZone} + - POSTGRES_USER=${DB_USER:-admin} + - POSTGRES_PASSWORD=${DB_PASSWORD:-admin} + + ludikzone: + image: gitea.borealian.ovh/mcmuzzle/ludikzone:latest + ports: + - 8080:8080 + environment: + - DB_HOST=${DB_HOST:-"postgresql"} + - DB_PORT=${DB_PORT:-5432} + - DB_USER=${DB_USER:-"admin"} + - DB_PASSWORD=${DB_PASSWORD:-"admin"} + - DB_DATABASE=${DB_DATABASE:-"ludikZone"} + depends_on: + - postgresql diff --git a/src/LudikZoneBlazor/LudikZoneBlazor.csproj b/src/LudikZoneBlazor/LudikZoneBlazor.csproj index a9e2c9c..7e31e71 100644 --- a/src/LudikZoneBlazor/LudikZoneBlazor.csproj +++ b/src/LudikZoneBlazor/LudikZoneBlazor.csproj @@ -7,10 +7,6 @@ aspnet-LudikZoneBlazor-b18f2a2e-d082-4232-8521-6cacaa2a4ba2 - - - - diff --git a/src/LudikZoneBlazor/Program.cs b/src/LudikZoneBlazor/Program.cs index fa4f86e..bb9b649 100644 --- a/src/LudikZoneBlazor/Program.cs +++ b/src/LudikZoneBlazor/Program.cs @@ -74,4 +74,11 @@ app.MapRazorComponents() // Add additional endpoints required by the Identity /Account Razor components. app.MapAdditionalIdentityEndpoints(); +// Appliquer les migrations automatiquement lors du démarrage +using (var scope = app.Services.CreateScope()) +{ + var dbContext = scope.ServiceProvider.GetRequiredService(); + dbContext.Database.Migrate(); // Applique les migrations +} + app.Run(); diff --git a/src/LudikZoneBlazor/appsettings.json b/src/LudikZoneBlazor/appsettings.json index 9daf2e9..df5993f 100644 --- a/src/LudikZoneBlazor/appsettings.json +++ b/src/LudikZoneBlazor/appsettings.json @@ -1,12 +1,12 @@ { - "ConnectionStrings": { - "DefaultConnection": "DataSource=Data\\app.db;Cache=Shared" - }, "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } }, + "ConnectionStrings": { + "DefaultConnection": "host=localhost;username=admin;database=ludikZone;Pooling=false;Timeout=300;CommandTimeout=300;Port=5432;" + }, "AllowedHosts": "*" } \ No newline at end of file