feature/user-authentication #2
1 changed files with 32 additions and 20 deletions
|
|
@ -1,35 +1,27 @@
|
||||||
pipeline:
|
pipeline:
|
||||||
# Build and test stage
|
# Build and test backend
|
||||||
build-and-test:
|
build-and-test:
|
||||||
image: mcr.microsoft.com/dotnet/sdk:9.0
|
image: mcr.microsoft.com/dotnet/sdk:9.0
|
||||||
commands:
|
commands:
|
||||||
# Restore dependencies
|
|
||||||
- dotnet restore GermanApp/GermanApp.csproj
|
- dotnet restore GermanApp/GermanApp.csproj
|
||||||
|
|
||||||
# Build the backend
|
|
||||||
- dotnet build GermanApp/GermanApp.csproj --no-restore --configuration Release
|
- dotnet build GermanApp/GermanApp.csproj --no-restore --configuration Release
|
||||||
|
- dotnet test Tests/GermanApp.Tests.Unit.csproj --no-build --configuration Release
|
||||||
# Run unit tests
|
- dotnet test Tests/GermanApp.Tests.Integration.csproj --no-build --configuration Release
|
||||||
- dotnet test Tests/GermanApp.Tests.Unit.csproj --no-build --configuration Release --verbosity normal
|
|
||||||
|
|
||||||
# Run integration tests
|
|
||||||
- dotnet test Tests/GermanApp.Tests.Integration.csproj --no-build --configuration Release --verbosity normal
|
|
||||||
when:
|
when:
|
||||||
# Run on all branches
|
|
||||||
branch:
|
branch:
|
||||||
- main
|
- main
|
||||||
- feature/*
|
- feature/*
|
||||||
- bugfix/*
|
- bugfix/*
|
||||||
- refactor/*
|
- refactor/*
|
||||||
|
|
||||||
# Docker build and push stage
|
# Build and push backend image
|
||||||
docker-build:
|
build-backend:
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
dockerfile: GermanApp/Dockerfile
|
dockerfile: GermanApp/Dockerfile
|
||||||
context: GermanApp
|
context: GermanApp
|
||||||
registry: registry.lrhdev.dk
|
registry: registry.lrhdev.dk
|
||||||
repo: registry.lrhdev.dk/lasserh/deutschlernen
|
repo: registry.lrhdev.dk/lasserh/deutschlernen-backend
|
||||||
tags:
|
tags:
|
||||||
- latest
|
- latest
|
||||||
- ${CI_COMMIT_SHA:0:8}
|
- ${CI_COMMIT_SHA:0:8}
|
||||||
|
|
@ -38,28 +30,48 @@ pipeline:
|
||||||
password:
|
password:
|
||||||
from_secret: docker_password
|
from_secret: docker_password
|
||||||
when:
|
when:
|
||||||
# Only build and push on main branch
|
|
||||||
branch:
|
branch:
|
||||||
- main
|
- main
|
||||||
# Only run if build-and-test succeeded
|
|
||||||
status:
|
status:
|
||||||
- success
|
- success
|
||||||
|
|
||||||
# Deploy stage
|
# Build and push frontend image
|
||||||
|
build-frontend:
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
dockerfile: german-app-frontend/Dockerfile
|
||||||
|
context: german-app-frontend
|
||||||
|
registry: registry.lrhdev.dk
|
||||||
|
repo: registry.lrhdev.dk/lasserh/deutschlernen-frontend
|
||||||
|
tags:
|
||||||
|
- latest
|
||||||
|
- ${CI_COMMIT_SHA:0:8}
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
when:
|
||||||
|
branch:
|
||||||
|
- main
|
||||||
|
status:
|
||||||
|
- success
|
||||||
|
|
||||||
|
# Deploy to production
|
||||||
deploy:
|
deploy:
|
||||||
image: alpine
|
image: alpine
|
||||||
commands:
|
commands:
|
||||||
- echo "Deploying to deutsch.lrhdev.dk..."
|
|
||||||
- apk add --no-cache openssh-client
|
- apk add --no-cache openssh-client
|
||||||
- mkdir -p ~/.ssh
|
- mkdir -p ~/.ssh
|
||||||
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||||
- chmod 600 ~/.ssh/id_rsa
|
- chmod 600 ~/.ssh/id_rsa
|
||||||
- ssh-keyscan deutsch.lrhdev.dk >> ~/.ssh/known_hosts
|
- ssh-keyscan deutsch.lrhdev.dk >> ~/.ssh/known_hosts
|
||||||
- ssh root@deutsch.lrhdev.dk "cd /path/to/app && docker-compose pull backend && docker-compose up -d backend"
|
# Pull new images and restart containers
|
||||||
|
- ssh ci-deploy@deutsch.lrhdev.dk "cd /opt/deutschlernen && docker-compose pull && docker-compose up -d"
|
||||||
|
# Reload nginx to pick up any new configurations
|
||||||
|
- ssh ci-deploy@deutsch.lrhdev.dk "nginx -t && nginx -s reload"
|
||||||
secrets:
|
secrets:
|
||||||
- SSH_PRIVATE_KEY
|
- SSH_PRIVATE_KEY
|
||||||
when:
|
when:
|
||||||
# Only deploy on main branch after successful docker-build
|
|
||||||
branch:
|
branch:
|
||||||
- main
|
- main
|
||||||
status:
|
status:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue