diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..fb1a4e6 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,82 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: Java CI with Maven + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + name: build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + - name: Build with Maven + run: mvn -B package --file pom.xml + + notification: + needs: build + runs-on: ubuntu-latest + steps: + - name: Send a message to Microsoft Teams + uses: aliencube/microsoft-teams-actions@v0.8.0 + if: always() + with: + webhook_uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + title: CI pipeline + text: Build is successfull waiting for the approval to run test + theme_color: 28a745 + QA: + name: test + needs: build + runs-on: ubuntu-latest + environment: + name: QA + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + - name: Test with Maven + run: mvn -B test --file pom.xml + notify: + needs: QA + runs-on: ubuntu-latest + steps: + - name: Send a message to Microsoft Teams + uses: aliencube/microsoft-teams-actions@v0.8.0 + if: always() + with: + webhook_uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }} + title: CI pipeline + text: Test is successful waiting for the approval to deploy + theme_color: 28a745 + DeployStaging: + name: Deploy to Staging + needs: QA + runs-on: ubuntu-latest + environment: + name: staging + steps: + - uses: actions/checkout@v2 + - name: Login to Docker Hub + run: docker login docker.io --username "${{ secrets.Docker_Username }}" --password "${{ secrets.Docker_Password }}" + - name: Build the Docker Image + run: docker build . --file Dockerfile --tag hasinireddy24/samplenodejs + - name: Push the Docker Image + run: docker push hasinireddy24/samplenodejs:latest + + + diff --git a/Dockerfile b/Dockerfile index 32977bc..9f1cadb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,20 @@ # Multi-stage build setup (https://docs.docker.com/develop/develop-images/multistage-build/) # Stage 1 (to create a "build" image, ~140MB) -FROM openjdk:8-jdk-alpine3.7 AS builder -RUN java -version +FROM adoptopenjdk/openjdk11:latest +ARG MAVEN_VERSION="3.8.1" +ARG USER_HOME_DIR="/root" +ARG SHA="b98a1905eb554d07427b2e5509ff09bd53e2f1dd7a0afa38384968b113abef02" +ARG BASE_URL="https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries" -COPY . /usr/src/myapp/ -WORKDIR /usr/src/myapp/ -RUN apk --no-cache add maven && mvn --version -RUN mvn package +RUN mkdir -p /usr/share/maven \ + && curl -Lso /tmp/maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ + && echo "${SHA} /tmp/maven.tar.gz" | sha256sum -c - \ + && tar -xzC /usr/share/maven --strip-components=1 -f /tmp/maven.tar.gz \ + && rm -v /tmp/maven.tar.gz \ + && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn -# Stage 2 (to create a downsized "container executable", ~87MB) -FROM openjdk:8-jre-alpine3.7 -WORKDIR /root/ -COPY --from=builder /usr/src/myapp/target/app.jar . +ENV MAVEN_HOME /usr/share/maven +ENV MAVEN_CONFIG "${USER_HOME_DIR}/.m2" -EXPOSE 8123 -ENTRYPOINT ["java", "-jar", "./app.jar"] +CMD ["/usr/bin/mvn"] diff --git a/results.sarif b/results.sarif new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/results.sarif @@ -0,0 +1 @@ +