Switch to net 10 and create gitlbab yml

This commit is contained in:
Maxime Boulay
2026-05-01 14:36:52 +02:00
parent 5fc97febfb
commit 95a7fd1ad5
2 changed files with 123 additions and 2 deletions

121
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,121 @@
stages:
- restore
- build
- test
- docker_build
- deploy
variables:
# Use Docker-in-Docker for building images
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
# Cache for NuGet packages
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .nuget/packages/
- frontend/node_modules/
# -------------------------------------------------------------------
# Backend (ASP.NET Core) jobs
# -------------------------------------------------------------------
restore_backend:
stage: restore
image: mcr.microsoft.com/dotnet/sdk:10.0
script:
- dotnet restore backend/GiecChallenge/GiecChallenge.csproj
artifacts:
paths:
- backend/GiecChallenge/obj/
- backend/GiecChallenge/bin/
expire_in: 1 hour
build_backend:
stage: build
image: mcr.microsoft.com/dotnet/sdk:10.0
needs: [restore_backend]
script:
- dotnet build backend/GiecChallenge/GiecChallenge.csproj -c Release -o out
artifacts:
paths:
- out/
expire_in: 1 hour
test_backend:
stage: test
image: mcr.microsoft.com/dotnet/sdk:10.0
needs: [build_backend]
script:
- dotnet test backend/GiecChallenge.test/GiecChallenge.test.csproj --no-build --verbosity normal
artifacts:
when: always
reports:
junit: test-results.xml
expire_in: 1 hour
# -------------------------------------------------------------------
# Frontend (React) jobs
# -------------------------------------------------------------------
install_frontend:
stage: restore
image: node:14-alpine
script:
- cd frontend
- npm ci
cache:
key: ${CI_COMMIT_REF_SLUG}-frontend
paths:
- frontend/node_modules/
artifacts:
paths:
- frontend/node_modules/
expire_in: 1 hour
build_frontend:
stage: build
image: node:14-alpine
needs: [install_frontend]
script:
- cd frontend
- npm run build
artifacts:
paths:
- frontend/build/
expire_in: 1 hour
# -------------------------------------------------------------------
# Docker images
# -------------------------------------------------------------------
docker_build_backend:
stage: docker_build
image: docker:latest
services:
- docker:dind
needs: [test_backend]
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE/backend:${CI_COMMIT_SHA:0:8} -f backend/GiecChallenge/Dockerfile .
- docker push $CI_REGISTRY_IMAGE/backend:${CI_COMMIT_SHA:0:8}
docker_build_frontend:
stage: docker_build
image: docker:latest
services:
- docker:dind
needs: [build_frontend]
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE/frontend:${CI_COMMIT_SHA:0:8} -f frontend/Dockerfile .
- docker push $CI_REGISTRY_IMAGE/frontend:${CI_COMMIT_SHA:0:8}
# -------------------------------------------------------------------
# Deploy (optional placeholder)
# -------------------------------------------------------------------
deploy:
stage: deploy
image: alpine:latest
script:
- echo "Deploy step placeholder add your deployment commands here."
only:
- main

View File

@@ -1,10 +1,10 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
ENV ASPNETCORE_ENVIRONMENT Docker
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
ENV ASPNETCORE_ENVIRONMENT Docker
WORKDIR /src-backend
COPY ./backend/GiecChallenge/GiecChallenge.csproj .