diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..35f24f3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,72 @@ +name: Build Docker image + +on: + push: + paths-ignore: + - '**.md' + branches: + - main + - 'release/*' + tags: + - 'v*' + pull_request: + branches: + - main + - 'release/*' + +defaults: + run: + shell: bash + +jobs: + docker: + runs-on: ubuntu-20.04 + env: + DOCKER_REGISTRY_URL: tip-tip-wlan-cloud-ucentral.jfrog.io + DOCKER_REGISTRY_USERNAME: ucentral + steps: + - name: Checkout actions repo + uses: actions/checkout@v2 + with: + repository: Telecominfraproject/.github + path: github + + - name: Build and push Docker image + uses: ./github/composite-actions/docker-image-build + with: + image_name: owrrm + registry: tip-tip-wlan-cloud-ucentral.jfrog.io + registry_user: ucentral + registry_password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} + + - name: Notify on failure via Slack + if: failure() && github.ref == 'refs/heads/main' + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_USERNAME: GitHub Actions failure notifier + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_COLOR: "${{ job.status }}" + SLACK_ICON: https://raw.githubusercontent.com/quintessence/slack-icons/master/images/github-logo-slack-icon.png + SLACK_TITLE: Docker build failed for OpenWiFi RRM Service + + trigger-deploy-to-dev: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + needs: + - docker + steps: + - name: Checkout actions repo + uses: actions/checkout@v2 + with: + repository: Telecominfraproject/.github + path: github + + - name: Trigger deployment of the latest version to dev instance and wait for result + uses: ./github/composite-actions/trigger-workflow-and-wait + with: + owner: Telecominfraproject + repo: wlan-testing + workflow: ucentralgw-dev-deployment.yaml + token: ${{ secrets.WLAN_TESTING_PAT }} + ref: master + inputs: '{"force_latest": "true"}' diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml new file mode 100644 index 0000000..bfcdf82 --- /dev/null +++ b/.github/workflows/cleanup.yml @@ -0,0 +1,19 @@ +name: Clean up PR Docker images + +on: + pull_request: + branches: + - main + types: [ closed ] + +defaults: + run: + shell: bash + +jobs: + cleanup: + runs-on: ubuntu-latest + steps: + - run: | + export PR_BRANCH_TAG=$(echo ${GITHUB_HEAD_REF#refs/heads/} | tr '/' '-') + curl -uucentral:${{ secrets.DOCKER_REGISTRY_PASSWORD }} -X DELETE "https://tip.jfrog.io/artifactory/tip-wlan-cloud-ucentral/owrrm/$PR_BRANCH_TAG" diff --git a/.github/workflows/enforce-jira-issue-key.yml b/.github/workflows/enforce-jira-issue-key.yml new file mode 100644 index 0000000..0908476 --- /dev/null +++ b/.github/workflows/enforce-jira-issue-key.yml @@ -0,0 +1,24 @@ +name: Ensure Jira issue is linked + +on: + pull_request: + types: [opened, edited, reopened, synchronize] + branches: + - 'release/*' + +jobs: + check_for_issue_key: + runs-on: ubuntu-latest + steps: + - name: Checkout actions repo + uses: actions/checkout@v2 + with: + repository: Telecominfraproject/.github + path: github + + - name: Run JIRA check + uses: ./github/composite-actions/enforce-jira-issue-key + with: + jira_base_url: ${{ secrets.TIP_JIRA_URL }} + jira_user_email: ${{ secrets.TIP_JIRA_USER_EMAIL }} + jira_api_token: ${{ secrets.TIP_JIRA_API_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..89fd54a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +name: Release chart package + +on: + push: + tags: + - 'v*' + +defaults: + run: + shell: bash + +jobs: + helm-package: + runs-on: ubuntu-20.04 + env: + HELM_REPO_URL: https://tip.jfrog.io/artifactory/tip-wlan-cloud-ucentral-helm/ + HELM_REPO_USERNAME: ucentral + steps: + - name: Checkout uCentral assembly chart repo + uses: actions/checkout@v2 + with: + path: wlan-cloud-rrm + + - name: Build package + working-directory: wlan-cloud-rrm/helm + run: | + helm plugin install https://github.com/aslafy-z/helm-git --version 0.10.0 + helm repo add bitnami https://charts.bitnami.com/bitnami + helm repo update + helm dependency update + mkdir dist + helm package . -d dist + + - name: Generate GitHub release body + working-directory: wlan-cloud-rrm/helm + run: | + pip3 install yq -q + echo "Docker image - tip-tip-wlan-cloud-ucentral.jfrog.io/owrrm:$GITHUB_REF_NAME" > release.txt + echo "Helm charted may be attached to this release" >> release.txt + echo "Deployment artifacts may be found in https://github.com/Telecominfraproject/wlan-cloud-ucentral-deploy/tree/$GITHUB_REF_NAME" >> release.txt + + - name: Create GitHub release + uses: softprops/action-gh-release@v1 + with: + body_path: wlan-cloud-rrm/helm/release.txt + files: wlan-cloud-rrm/helm/dist/* diff --git a/Dockerfile b/Dockerfile index ca28ec3..9325495 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,12 @@ COPY . . RUN mvn clean package FROM openjdk:11 +RUN apt-get update && apt-get install -y gettext-base +RUN wget https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentral-deploy/main/docker-compose/certs/restapi-ca.pem \ + -O /usr/local/share/ca-certificates/restapi-ca-selfsigned.pem WORKDIR /usr/src/java +COPY docker-entrypoint.sh / COPY --from=build /usr/src/java/target/openwifi-rrm.jar /usr/local/bin/ -ENTRYPOINT ["java", "-jar", "/usr/local/bin/openwifi-rrm.jar", "run"] +EXPOSE 16789 +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["java", "-jar", "/usr/local/bin/openwifi-rrm.jar", "run", "--config-env"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..98bc652 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -e + +if [ "$SELFSIGNED_CERTS" = 'true' ]; then + update-ca-certificates +fi + +exec "$@"