diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml new file mode 100644 index 0000000..fc3b760 --- /dev/null +++ b/.github/workflows/cicd.yml @@ -0,0 +1,43 @@ +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] +jobs: + build: + runs-on: [ubuntu-latest] + steps: + - name: Checkout source + uses: actions/checkout@v3 + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + - name: Unit Tests + run: mvn -B test --file pom.xml + - name: Build the application + run: | + mvn clean + mvn -B package --file pom.xml + + - name: Build Docker Image + uses: docker/build-push-action@v3 + with: + context: . + dockerfile: Dockerfile + push: false + tags: ${{ secrets.DOCKER_USERNAME }}/elearning-be + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + + - name: Push to Docker Hub + uses: docker/build-push-action@v3 + with: + context: . + dockerfile: Dockerfile + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/elearning-be \ No newline at end of file diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..5584824 --- /dev/null +++ b/compose.yml @@ -0,0 +1,57 @@ +services: + postgres: + container_name: elearning-db + image: postgres + environment: + POSTGRES_USER: root + POSTGRES_PASSWORD: password + PGDATA: /data/postgres + POSTGRES_DB: elearning + volumes: + - db_data:/data/postgres + ports: + - "5432:5432" + networks: + - postgres + restart: unless-stopped + + pgadmin: + container_name: elearning-pgui + image: dpage/pgadmin4 + environment: + PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org} + PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin} + PGADMIN_CONFIG_SERVER_MODE: 'False' + volumes: + - pgadmin:/var/lib/pgadmin + ports: + - "5050:80" + networks: + - postgres + restart: unless-stopped + api: + image: thuanvn2002/elearning-be:latest + ports: + - "8082:8082" + environment: + - SPRING_PROFILES_ACTIVE=prod + networks: + - postgres + depends_on: + - postgres + ui: + image: thuanvn2002/elearning-fe:latest + ports: + - "80:80" + networks: + - postgres + restart: unless-stopped +networks: + postgres: + driver: bridge + +volumes: + db_data: + pgadmin: + +