β¨ upscale tomcat max threads #17
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
name: Backend CD Develop | |
on: | |
push: | |
branches: | |
- be/dev | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: test | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: temurin | |
cache: gradle | |
- name: Cache Gradle | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/build.gradle') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Add execute permissions | |
working-directory: ./backend | |
run: chmod +x ./gradlew | |
- name: Build | |
working-directory: ./backend | |
run: ./gradlew build -x test -x bootJar | |
- name: Test and Create OAS | |
env: | |
JASYPT_PASSWORD: ${{ secrets.JASYPT_PASSWORD }} | |
working-directory: ./backend | |
run: ./gradlew copyOasToSwagger | |
- name: Create bootJar | |
working-directory: ./backend | |
run: ./gradlew bootJar | |
- name: Build Docker image | |
working-directory: ./backend | |
run: | | |
docker build \ | |
-f Dockerfile-dev \ | |
-t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:dev \ | |
. | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Push Docker image | |
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:dev | |
- name: Upload docker compose | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docker-compose | |
path: ./backend/src/main/resources/docker-compose-dev.yaml | |
if-no-files-found: error | |
deploy: | |
needs: build | |
runs-on: [self-hosted, dev] | |
environment: dev | |
steps: | |
- name: Set up environment variables | |
run: | | |
cd ~/${{ secrets.DOCKERHUB_IMAGE_NAME }} | |
echo "MYSQL_DATABASE=${{ secrets.MYSQL_DATABASE }}" > .env | |
echo "MYSQL_ROOT_PASSWORD=${{ secrets.MYSQL_ROOT_PASSWORD }}" >> .env | |
echo "JASYPT_PASSWORD=${{ secrets.JASYPT_PASSWORD }}" >> .env | |
- name: Download docker compose | |
uses: actions/download-artifact@v4 | |
with: | |
name: docker-compose | |
path: ~/${{ secrets.DOCKERHUB_IMAGE_NAME }} | |
- name: Rename downloaded file | |
run: | | |
cd ~/${{ secrets.DOCKERHUB_IMAGE_NAME }} | |
mv docker-compose-dev.yaml docker-compose.yaml | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Pull latest Docker images | |
run: docker compose -f ~/${{ secrets.DOCKERHUB_IMAGE_NAME }}/docker-compose.yaml pull | |
- name: Restart docker compose | |
run: | | |
cd ~/${{ secrets.DOCKERHUB_IMAGE_NAME }} | |
docker compose up -d | |
- name: Clean up unused Docker images | |
run: docker image prune -af |