Merge branch 'develop' #39
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
| name: DevOps App CI | |
| on: | |
| push: | |
| jobs: | |
| build-and-run: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| # Checkout code | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # Set up JDK 17 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v2 | |
| with: | |
| java-version: '17' | |
| distribution: 'adopt' | |
| # Build fat JAR with dependencies | |
| - name: Build JAR with dependencies | |
| run: mvn clean package | |
| # Create a Docker network for container communication | |
| - name: Create Docker network | |
| run: docker network create se-methods || echo "Network already exists" | |
| # Start MongoDB container on the network | |
| - name: Start MongoDB | |
| run: docker run -d --name mongo-dbserver --network se-methods -p 27000:27017 mongo:latest | |
| # Build your application Docker image | |
| - name: Build Docker image | |
| run: docker build -t devopsimage . | |
| # Run your application container on the same network | |
| - name: Run app container | |
| run: docker run --name devopscontainer --network se-methods -d devopsimage | |
| # View logs to confirm it worked | |
| - name: View container logs | |
| run: docker logs devopscontainer |