121 lines
3.1 KiB
YAML
121 lines
3.1 KiB
YAML
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 |