From a8fd217e670bdc6146c51717f67a2ef09fdb593d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vedansh=20=E2=9C=A8?= Date: Fri, 10 May 2024 11:02:10 +0530 Subject: [PATCH] Revert to backwards --- .github/workflows/docker-publish.yml | 77 ++++++++++++++++++---------- Dockerfile | 7 +-- 2 files changed, 55 insertions(+), 29 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 26f387d..7ff5d69 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -1,43 +1,68 @@ name: CI / Docker Publish Image on: - workflow_dispatch: + schedule: + - cron: '10 0 * * *' push: - branches: - - master + branches: [ "master"] + workflow_dispatch: + env: - IMAGE_NAME: untileverything - DOCKER_USER: ntsystems - GHCR_REGISTRY: ghcr.io - DOCKERHUB_REGISTRY: docker.io + REGISTRY: docker.io + IMAGE_NAME: ntsystems/untileverything jobs: - docker: + push: runs-on: ubuntu-latest + permissions: + contents: read + packages: write + id-token: write + steps: - - name: Checkout - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install cosign + if: github.event_name != 'pull_request' + uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1 + with: + cosign-release: 'v2.1.1' - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 + + + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 with: - registry: ${{ env.DOCKERHUB_REGISTRY }} + registry: ${{ env.REGISTRY }} username: ntsystems password: ${{ secrets.DOCKER_TOKEN }} - - name: Build and push Docker images - uses: docker/build-push-action@v2 + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and Push Docker image + id: build-and-push + uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 with: context: . - file: ./Dockerfile - push: true - platforms: linux/amd64,linux/arm64/v8,windows/amd64,windows/arm64,macos/amd64,macos/arm64 - tags: | - latest - latest + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Sign the published Docker image + if: ${{ github.event_name != 'pull_request' }} + env: + TAGS: ${{ steps.meta.outputs.tags }} + DIGEST: ${{ steps.build-and-push.outputs.digest }} + # This step uses the identity token to provision an ephemeral certificate + # against the sigstore community Fulcio instance. + run: echo "Image with ${TAGS} tag has been sucessfully Signed." \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2e48de0..990d907 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ # syntax=docker/dockerfile:1 + ARG NODE_VERSION=20 -FROM node:20 +FROM node:${NODE_VERSION}-alpine LABEL maintainer "Vedansh Khandelwal " -LABEL org.opencontainers.image.source "https://github.com/offensive-vk/UntilEverything" +LABEL org.opencontainers.image.source https://github.com/offensive-vk/UntilEverything ENV NODE_ENV production WORKDIR /usr/src/app RUN --mount=type=bind,source=package.json,target=package.json \ @@ -13,4 +14,4 @@ USER node COPY . . EXPOSE 9999 CMD ["npm", "start"] -# syntax=docker/dockerfile:END +# syntax=docker/dockerfile:END \ No newline at end of file