-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
2,581 additions
and
435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Database Configuration | ||
MYSQL_ROOT_PASSWORD=change_this_root_password | ||
MYSQL_DATABASE=consultant_tracking | ||
MYSQL_USER=change_this_user | ||
MYSQL_PASSWORD=change_this_password | ||
|
||
# Spring Configuration | ||
SPRING_DATASOURCE_URL=jdbc:mariadb://mariadb:3306/consultant_tracking | ||
SPRING_DATASOURCE_USERNAME=${MYSQL_USER} | ||
SPRING_DATASOURCE_PASSWORD=${MYSQL_PASSWORD} | ||
SPRING_JPA_HIBERNATE_DDL_AUTO=validate | ||
SPRING_JPA_SHOW_SQL=true | ||
SPRING_JPA_FORMAT_SQL=true | ||
|
||
# Liquibase Configuration | ||
LIQUIBASE_COMMAND_USERNAME=${MYSQL_USER} | ||
LIQUIBASE_COMMAND_PASSWORD=${MYSQL_PASSWORD} | ||
LIQUIBASE_COMMAND_URL=${SPRING_DATASOURCE_URL} | ||
LIQUIBASE_SEARCH_PATH=/liquibase/changelog | ||
LIQUIBASE_COMMAND_CHANGELOG_FILE=./db.changelog.xml | ||
|
||
# Domains Configuration | ||
DOMAIN_FRONTEND=app.localhost | ||
DOMAIN_BACKEND=api.localhost | ||
DOMAIN_ADMINER=adminer.localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
name: CI/CD Pipeline | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
BACKEND_IMAGE_NAME: ${{ github.repository }}/backend | ||
FRONTEND_IMAGE_NAME: ${{ github.repository }}/frontend | ||
MYSQL_DATABASE: consultant_tracking | ||
DOMAIN_FRONTEND: app.example.com | ||
DOMAIN_BACKEND: api.example.com | ||
DOMAIN_ADMINER: adminer.example.com | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create .env file | ||
run: | | ||
cat << EOF > .env | ||
MYSQL_ROOT_PASSWORD=${{ secrets.MYSQL_ROOT_PASSWORD }} | ||
MYSQL_DATABASE=${{ env.MYSQL_DATABASE }} | ||
MYSQL_USER=${{ secrets.MYSQL_USER }} | ||
MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }} | ||
SPRING_DATASOURCE_URL=jdbc:mariadb://mariadb:3306/${{ env.MYSQL_DATABASE }} | ||
SPRING_DATASOURCE_USERNAME=${{ secrets.MYSQL_USER }} | ||
SPRING_DATASOURCE_PASSWORD=${{ secrets.MYSQL_PASSWORD }} | ||
SPRING_JPA_HIBERNATE_DDL_AUTO=validate | ||
SPRING_JPA_SHOW_SQL=false | ||
SPRING_JPA_FORMAT_SQL=false | ||
DOMAIN_FRONTEND=${{ env.DOMAIN_FRONTEND }} | ||
DOMAIN_BACKEND=${{ env.DOMAIN_BACKEND }} | ||
DOMAIN_ADMINER=${{ env.DOMAIN_ADMINER }} | ||
EOF | ||
- name: Build and push Backend Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./backend | ||
push: true | ||
tags: ${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}:latest | ||
build-args: | | ||
SPRING_DATASOURCE_URL=jdbc:mariadb://mariadb:3306/${{ env.MYSQL_DATABASE }} | ||
SPRING_DATASOURCE_USERNAME=${{ secrets.MYSQL_USER }} | ||
SPRING_DATASOURCE_PASSWORD=${{ secrets.MYSQL_PASSWORD }} | ||
- name: Build and push Frontend Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./frontend | ||
push: true | ||
tags: ${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}:latest | ||
build-args: | | ||
API_URL=https://${{ env.DOMAIN_BACKEND }} | ||
deploy: | ||
needs: build-and-push | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Create .env file on server | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SERVER_HOST }} | ||
username: ${{ secrets.SERVER_USERNAME }} | ||
key: ${{ secrets.SERVER_SSH_KEY }} | ||
script: | | ||
cat << EOF > ~/consultant-tracking/.env | ||
MYSQL_ROOT_PASSWORD=${{ secrets.MYSQL_ROOT_PASSWORD }} | ||
MYSQL_DATABASE=${{ env.MYSQL_DATABASE }} | ||
MYSQL_USER=${{ secrets.MYSQL_USER }} | ||
MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }} | ||
SPRING_DATASOURCE_URL=jdbc:mariadb://mariadb:3306/${{ env.MYSQL_DATABASE }} | ||
SPRING_DATASOURCE_USERNAME=${{ secrets.MYSQL_USER }} | ||
SPRING_DATASOURCE_PASSWORD=${{ secrets.MYSQL_PASSWORD }} | ||
SPRING_JPA_HIBERNATE_DDL_AUTO=validate | ||
SPRING_JPA_SHOW_SQL=false | ||
SPRING_JPA_FORMAT_SQL=false | ||
DOMAIN_FRONTEND=${{ env.DOMAIN_FRONTEND }} | ||
DOMAIN_BACKEND=${{ env.DOMAIN_BACKEND }} | ||
DOMAIN_ADMINER=${{ env.DOMAIN_ADMINER }} | ||
EOF | ||
- name: Deploy to server | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SERVER_HOST }} | ||
username: ${{ secrets.SERVER_USERNAME }} | ||
key: ${{ secrets.SERVER_SSH_KEY }} | ||
script: | | ||
cd ~/consultant-tracking | ||
docker pull ${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}:latest | ||
docker pull ${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}:latest | ||
docker-compose down | ||
docker-compose up -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Environment variables | ||
.env | ||
.env.* | ||
!.env.example | ||
|
||
# IDE files | ||
.idea/ | ||
.vscode/ | ||
*.iml | ||
|
||
# Dependencies | ||
node_modules/ | ||
/dist/ | ||
/target/ | ||
|
||
# Logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# System Files | ||
.DS_Store | ||
Thumbs.db |
Oops, something went wrong.