Skip to content

Commit

Permalink
Sprint release 08 (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
Corgam authored Jun 19, 2024
2 parents 18ccdc4 + 76ed840 commit 43cccc7
Show file tree
Hide file tree
Showing 189 changed files with 4,946 additions and 43,137 deletions.
25 changes: 21 additions & 4 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,31 @@
# The environment stage set for individual services
ENVIRONMENT_STAGE=development
# The tag used for pulling the docker images
DOCKER_COMPOSE_IMAGES_TAG=test
DOCKER_COMPOSE_IMAGES_TAG=latest

### HOSTS & PORTS ###

# Frontend
FRONTEND_HOST=frontend
FRONTEND_PORT=80

# Backend
VITE_BACKEND_HOST=localhost
VITE_BACKEND_PORT=8081
# Backend - API Gateway
API_GATEWAY_HOST=localhost
API_GATEWAY_PORT=8081

# Backend - API Composer
API_COMPOSER_HOST=localhost
API_COMPOSER_PORT=8082

### METADATA DATABASE ###

METADATA_DATABASE_PORT=27017

### SQL DATABASE ###

SQL_DB_NAME=BIEDB
SQL_DB_PASSWORD=MyPass@1234
SQL_DB_SERVER=sql-database
SQL_DB_USERNAME=sa
SQL_DB_TYPE=SQL
SQL_TRUSTED=False
25 changes: 21 additions & 4 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,31 @@
# The environment stage set for individual services
ENVIRONMENT_STAGE=production
# The tag used for pulling the docker images
DOCKER_COMPOSE_IMAGES_TAG=production
DOCKER_COMPOSE_IMAGES_TAG=latest

### HOSTS & PORTS ###

# Frontend
FRONTEND_HOST=frontend
FRONTEND_PORT=80

# Backend
VITE_BACKEND_HOST=prod.amos.b-ci.de
VITE_BACKEND_PORT=8081
# Backend - API Gateway
API_GATEWAY_HOST=prod.amos.b-ci.de
API_GATEWAY_PORT=8081

# Backend - API Composer
API_COMPOSER_HOST=prod.amos.b-ci.de
API_COMPOSER_PORT=8082

### METADATA DATABASE ###

METADATA_DATABASE_PORT=27017

### SQL DATABASE ###

SQL_DB_NAME=BIEDB
SQL_DB_PASSWORD=MyPass@1234
SQL_DB_SERVER=sql-database
SQL_DB_USERNAME=sa
SQL_DB_TYPE=SQL
SQL_TRUSTED=False
23 changes: 20 additions & 3 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ DOCKER_COMPOSE_IMAGES_TAG=test
FRONTEND_HOST=frontend
FRONTEND_PORT=80

# Backend
VITE_BACKEND_HOST=test.amos.b-ci.de
VITE_BACKEND_PORT=8081
# Backend - API Gateway
API_GATEWAY_HOST=test.amos.b-ci.de
API_GATEWAY_PORT=8081

# Backend - API Composer
API_COMPOSER_HOST=test.amos.b-ci.de
API_COMPOSER_PORT=8082

### METADATA DATABASE ###

METADATA_DATABASE_PORT=27017

### SQL DATABASE ###

SQL_DB_NAME=BIEDB
SQL_DB_PASSWORD=MyPass@1234
SQL_DB_SERVER=sql-database
SQL_DB_USERNAME=sa
SQL_DB_TYPE=SQL
SQL_TRUSTED=False
30 changes: 22 additions & 8 deletions .github/workflows/backend-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,31 @@ on:
jobs:
linting:
name: Check linting
runs-on: ubuntu-latest

runs-on: windows-latest
steps:
- name: Echo Linting
run: echo "linting"
- name: Checkout repository
uses: actions/checkout@v2.1.0

- name: Restore dependencies
run: dotnet restore
working-directory: backend\src\BIE.DataPipeline

- name: Linting
run: dotnet format BIE.DataPipeline.sln
working-directory: backend\src\BIE.DataPipeline

tests:
needs: linting
name: Run Tests
runs-on: ubuntu-latest

runs-on: windows-latest
steps:
- name: Echo Test
run: echo "test"
- name: Checkout repository
uses: actions/checkout@v2.1.0

- name: Restore dependencies
run: dotnet restore
working-directory: backend\src\BIE.DataPipeline

- name: Run unit tests
run: dotnet test
working-directory: backend\src\BIE.DataPipeline
165 changes: 25 additions & 140 deletions .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,138 +11,29 @@ env:
STAGE: production

jobs:
build-and-publish-frontend:
name: Build and publish - Frontend
build-and-publish:
name: Build and publish -
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}

- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-frontend
tags: |
type=ref,event=tag
type=sha
type=raw,value=${{ env.STAGE }}
latest
labels: |
stage=${{ env.STAGE }}
- name: Build and Publish Docker Images
uses: docker/build-push-action@v5
with:
context: ./frontend
file: ./frontend/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
STAGE=${{ env.STAGE }}
build-and-publish-backend-api-gateway:
name: Build and publish - API Gateway
runs-on: ubuntu-latest
strategy:
matrix:
service:
- name: frontend
context: ./frontend
- name: api-gateway
context: ./backend/api-gateway
- name: api-composer
context: ./backend/src/BIE.Core
- name: datapipeline
context: ./backend/src/BIE.DataPipeline
- name: sql-database
context: ./backend/sql-database
- name: metadata-database
context: ./backend/metadata-database

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}

- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-api-gateway
tags: |
type=ref,event=tag
type=sha
type=raw,value=${{ env.STAGE }}
latest
labels: |
stage=${{ env.STAGE }}
- name: Build and Publish Docker Images
uses: docker/build-push-action@v5
with:
context: ./backend/src/BIE.Core
file: ./backend/src/BIE.Core/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
STAGE=${{ env.STAGE }}
build-and-publish-backend-datapipeline:
name: Build and publish - Data Pipeline
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}

- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-datapipeline
tags: |
type=ref,event=tag
type=sha
type=raw,value=${{ env.STAGE }}
latest
labels: |
stage=${{ env.STAGE }}
- name: Build and Publish Docker Images
uses: docker/build-push-action@v5
with:
context: ./backend/src/BIE.DataPipeline
file: ./backend/src/BIE.DataPipeline/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
STAGE=${{ env.STAGE }}
build-and-publish-backend-sql-database:
name: Build and publish - SQL Database
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}

- name: Log in to the container registry
uses: docker/login-action@v3
Expand All @@ -151,11 +42,11 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
- name: Extract metadata for Docker - ${{ matrix.service.name }}
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-sql-database
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.service.name }}
tags: |
type=ref,event=tag
type=sha
Expand All @@ -164,25 +55,19 @@ jobs:
labels: |
stage=${{ env.STAGE }}
- name: Build and Publish Docker Images
- name: Build and Publish Docker Image - ${{ matrix.service.name }}
uses: docker/build-push-action@v5
with:
context: ./backend/database
file: ./backend/database/Dockerfile
context: ${{ matrix.service.context }}
file: ${{ matrix.service.context }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
STAGE=${{ env.STAGE }}
deploy-prod-env:
needs:
[
build-and-publish-frontend,
build-and-publish-backend-api-gateway,
build-and-publish-backend-datapipeline,
build-and-publish-backend-sql-database,
]
deploy-test-env:
needs: build-and-publish
name: Deploy - Production Environment
runs-on: ubuntu-latest

Expand All @@ -201,6 +86,6 @@ jobs:
scp ./docker-compose.yml ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}}:/var/lib/bie
scp ./.env.production ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}}:/var/lib/bie/.env
- name: Connect and Pull
run: ssh ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}} "cd /var/lib/bie && docker compose pull && docker compose up -d --remove-orphans && exit"
run: ssh ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}} "cd /var/lib/bie && docker compose down --remove-orphans && docker compose pull && docker compose up -d --remove-orphans && exit"
- name: Cleanup
run: rm -rf ~/.ssh
Loading

0 comments on commit 43cccc7

Please sign in to comment.