From 3714c2c91a63eae20998e6a962b00c62c5a79684 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Thu, 28 Sep 2023 11:16:50 +0000 Subject: [PATCH] add test container --- .github/workflows/release.yml | 60 ++++++++++++++++++ .github/workflows/test-release.yaml | 63 +++++++++++++++++++ Tests/Dockefile.tpl | 19 ++++++ .../scripts => Tests/Scripts}/status-check.sh | 0 Tests/start.sh | 1 + 5 files changed, 143 insertions(+) create mode 100644 Tests/Dockefile.tpl rename {HelmChart/public/oneuptime/scripts => Tests/Scripts}/status-check.sh (100%) create mode 100644 Tests/start.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4bff1ad9d0..3fe7c2aea9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -399,6 +399,66 @@ jobs: GIT_SHA=${{ github.sha }} APP_VERSION=7.0.${{needs.generate-build-number.outputs.build_number}} + test-docker-image-deploy: + needs: generate-build-number + runs-on: ubuntu-latest + steps: + - name: Docker Meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + oneuptime/test + ghcr.io/oneuptime/test + tags: | + type=raw,value=release,enable=true + type=semver,value=7.0.${{needs.generate-build-number.outputs.build_number}},pattern={{version}},enable=true + + - uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + + - uses: actions/setup-node@v2 + with: + node-version: 18.3.0 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Generate Dockerfile from Dockerfile.tpl + run: npm run prerun + + # Build and deploy test. + + - name: Login to Docker Hub + uses: docker/login-action@v2.2.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2.2.0 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + file: ./Test/Dockerfile + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + GIT_SHA=${{ github.sha }} + APP_VERSION=7.0.${{needs.generate-build-number.outputs.build_number}} + realtime-docker-image-deploy: needs: generate-build-number runs-on: ubuntu-latest diff --git a/.github/workflows/test-release.yaml b/.github/workflows/test-release.yaml index 13ccbfc669..a64765b090 100644 --- a/.github/workflows/test-release.yaml +++ b/.github/workflows/test-release.yaml @@ -385,6 +385,69 @@ jobs: GIT_SHA=${{ github.sha }} APP_VERSION=7.0.${{needs.generate-build-number.outputs.build_number}} + + + test-docker-image-deploy: + needs: generate-build-number + runs-on: ubuntu-latest + steps: + - name: Docker Meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + oneuptime/test + ghcr.io/oneuptime/test + tags: | + type=raw,value=test,enable=true + type=semver,value=7.0.${{needs.generate-build-number.outputs.build_number}}-test,pattern={{version}},enable=true + + + - uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + + - uses: actions/setup-node@v2 + with: + node-version: 18.3.0 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Generate Dockerfile from Dockerfile.tpl + run: npm run prerun + + # Build and deploy test. + + - name: Login to Docker Hub + uses: docker/login-action@v2.2.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2.2.0 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + file: ./Test/Dockerfile + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + GIT_SHA=${{ github.sha }} + APP_VERSION=7.0.${{needs.generate-build-number.outputs.build_number}} + realtime-docker-image-deploy: needs: generate-build-number runs-on: ubuntu-latest diff --git a/Tests/Dockefile.tpl b/Tests/Dockefile.tpl new file mode 100644 index 0000000000..7619fa199e --- /dev/null +++ b/Tests/Dockefile.tpl @@ -0,0 +1,19 @@ +FROM node:18.13.0-alpine +USER root +RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm config set cache /tmp/npm --global + +RUN npm config set fetch-retry-maxtimeout 6000000 +RUN npm config set fetch-retry-mintimeout 1000000 + +ARG GIT_SHA +ARG APP_VERSION + +ENV GIT_SHA=${GIT_SHA} +ENV APP_VERSION=${APP_VERSION} + +RUN npm -g config set user root +RUN apk add bash + +COPY ./Tests . + +CMD ["/start.sh"] \ No newline at end of file diff --git a/HelmChart/public/oneuptime/scripts/status-check.sh b/Tests/Scripts/status-check.sh similarity index 100% rename from HelmChart/public/oneuptime/scripts/status-check.sh rename to Tests/Scripts/status-check.sh diff --git a/Tests/start.sh b/Tests/start.sh new file mode 100644 index 0000000000..3251c6590b --- /dev/null +++ b/Tests/start.sh @@ -0,0 +1 @@ +echo "This is a test container. Please specify a script to test" \ No newline at end of file