Added a bin folder and changed the maven clean command #5
This file contains hidden or 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
| # This workflow will build docker image and push it to DockerHub, | ||
| # After that, This wrkflow build and push a new container image to Amazon ECR, | ||
| # and then will deploy a new task definition to Amazon ECS, when there is a push to the "main" branch. | ||
| name: CI/CD Pipeline # Name of the CI/CD Pipeline | ||
| on: | ||
| push: | ||
| branches: [ "main" ] # Trigger on push events to the main branch | ||
| pull_request: | ||
| branches: [ "main" ] # Trigger on pull requests to the main branch | ||
| jobs: | ||
| build-and-deploy: | ||
| runs-on: ubuntu-latest # Runs on the latest version of Ubuntu | Default operating system environment for workflows unless explicitly specified. | ||
| steps: | ||
| - name: Checkout code # Step to checkout the code from the repository | Fetch the source code repository into the runner machine where our workflow is executing. | ||
| uses: actions/checkout@v4 | ||
| - name: Set up JDK 17 # Step to set up JDK 17 | ||
| uses: actions/setup-java@v3 | ||
| with: | ||
| java-version: '17' | ||
| distribution: 'oracle' | ||
| # Build the Spring Boot app using Maven | ||
| - name: Build Spring Boot App with Maven | ||
| run: mvn -f demo/pom.xml clean install | ||
| - name: build and push the docker image to dockerhub | ||
| run: | | ||
| # 1. Login to DockerHub | ||
| # 2. Build the Docker image | ||
| # 3. Push the Docker image to DockerHub | ||
| # 4. Run the Docker image | ||
| # 5. Fetch logs from the running container | ||
| # 6. Stop the container after the test | ||
| # 7. Remove the container after the test | ||
| # 8. Cleanup dangling images (optional) | ||
| docker login -u gowthamdineshrajkumar -p gowthamdineshrajkumar | ||
| docker build -f demo/Dockerfile -t gowthamdineshrajkumar/demospringboot . | ||
| docker push gowthamdineshrajkumar/demospringboot:latest | ||
| docker run -d --name demospringboot-container -p 8080:8080 gowthamdineshrajkumar/demospringboot:latest | ||
| docker logs --tail 50 demospringboot-container | ||
| docker stop demospringboot-container | ||
| docker rm demospringboot-container | ||
| docker image prune -f | ||