Skip to content

Commit

Permalink
Sprint release 05 (#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
Corgam authored May 29, 2024
2 parents 42f1f45 + 8e6cac4 commit f263eb3
Show file tree
Hide file tree
Showing 42 changed files with 1,234 additions and 292 deletions.
14 changes: 9 additions & 5 deletions .env
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
### Config ###
ENVIRONMENT_STAGE=Development
### CONFIG ###

### Ports and hosts ###
# The environment stage set for individual services
ENVIRONMENT_STAGE=development
# The tag used for pulling the docker images
DOCKER_COMPOSE_IMAGES_TAG=test

### HOSTS & PORTS ###

# Frontend
FRONTEND_HOST=frontend
FRONTEND_PORT=80

# Backend
BACKEND_HOST=api-gateway
BACKEND_PORT=8081
VITE_BACKEND_HOST=localhost
VITE_BACKEND_PORT=8081
16 changes: 16 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### CONFIG ###

# The environment stage set for individual services
ENVIRONMENT_STAGE=production
# The tag used for pulling the docker images
DOCKER_COMPOSE_IMAGES_TAG=production

### HOSTS & PORTS ###

# Frontend
FRONTEND_HOST=frontend
FRONTEND_PORT=80

# Backend
VITE_BACKEND_HOST=prod.amos.b-ci.de
VITE_BACKEND_PORT=8081
16 changes: 16 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### CONFIG ###

# The environment stage set for individual services
ENVIRONMENT_STAGE=test
# The tag used for pulling the docker images
DOCKER_COMPOSE_IMAGES_TAG=test

### HOSTS & PORTS ###

# Frontend
FRONTEND_HOST=frontend
FRONTEND_PORT=80

# Backend
VITE_BACKEND_HOST=test.amos.b-ci.de
VITE_BACKEND_PORT=8081
75 changes: 48 additions & 27 deletions .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,25 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: amosproj/amos2024ss04-building-information-enhancer
STAGE: production

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

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{github.ref_name}}
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}}
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
Expand All @@ -35,16 +36,21 @@ jobs:
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}}
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
Expand All @@ -54,14 +60,14 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{github.ref_name}}
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}}
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
Expand All @@ -71,16 +77,21 @@ jobs:
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}}
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
Expand All @@ -90,14 +101,14 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{github.ref_name}}
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}}
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
Expand All @@ -107,16 +118,21 @@ jobs:
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}}
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
Expand All @@ -126,14 +142,14 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{github.ref_name}}
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}}
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
Expand All @@ -143,16 +159,21 @@ jobs:
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/database
file: ./backend/database/Dockerfile
push: true
tags: ${{steps.meta.outputs.tags}}
labels: ${{steps.meta.outputs.labels}}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
STAGE=${{ env.STAGE }}
deploy-prod-env:
needs:
Expand All @@ -162,7 +183,7 @@ jobs:
build-and-publish-backend-datapipeline,
build-and-publish-backend-sql-database,
]
name: Deploy Image in the Production Environment
name: Deploy - Production Environment
runs-on: ubuntu-latest

steps:
Expand All @@ -178,7 +199,7 @@ jobs:
- name: Copy necessary files
run: |
scp ./docker-compose.yml ${{secrets.PROD_ENV_SSH_USER}}@${{secrets.PROD_ENV_SSH_HOST}}:/var/lib/bie
scp ./.env ${{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"
- name: Cleanup
Expand Down
Loading

0 comments on commit f263eb3

Please sign in to comment.