diff --git a/.github/workflows/ci-production.yml b/.github/workflows/ci-production.yml new file mode 100644 index 000000000..0d0a0a152 --- /dev/null +++ b/.github/workflows/ci-production.yml @@ -0,0 +1,53 @@ +name: Jan CI Production + +on: + push: + tags: ['v*.*.*'] + +env: + REGISTRY: ghcr.io + HASURA_WORKER_IMAGE_NAME: ${{ github.repository }}/worker + WEB_CLIENT_IMAGE_NAME: ${{ github.repository }}/web-client + +jobs: + build-docker-image: + runs-on: ubuntu-latest + environment: production + permissions: + contents: read + packages: write + steps: + - name: Getting the repo + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get tag + id: tag + uses: dawidd6/action-get-tag@v1 + + # Build and docker image for app-backend worker + - name: Build docker image for app-backend worker + run: | + cd ./app-backend/worker + docker build -t ${{ env.REGISTRY }}/${{ env.HASURA_WORKER_IMAGE_NAME }}:${{ steps.tag.outputs.tag }} . + docker push ${{ env.REGISTRY }}/${{ env.HASURA_WORKER_IMAGE_NAME }}:${{ steps.tag.outputs.tag }} + + # Get .env for FE + - name: Get .env file for build time + run: cd ./web-client && base64 -d <<< "$ENV_FILE_BASE64" > .env + shell: bash + env: + ENV_FILE_BASE64: ${{ secrets.ENV_FILE_BASE64 }} + + # Build and push docker for web client + - name: Build docker image for web-client + run: | + cd ./web-client + docker build -t ${{ env.REGISTRY }}/${{ env.WEB_CLIENT_IMAGE_NAME }}:${{ steps.tag.outputs.tag }} . + docker push ${{ env.REGISTRY }}/${{ env.WEB_CLIENT_IMAGE_NAME }}:${{ steps.tag.outputs.tag }} diff --git a/.github/workflows/ci-staging.yml b/.github/workflows/ci-staging.yml new file mode 100644 index 000000000..5f42cef4b --- /dev/null +++ b/.github/workflows/ci-staging.yml @@ -0,0 +1,58 @@ +name: Jan CI Staging +on: + push: + branches: + - stag + paths: + - 'app-backend/worker/**' # hasura worker source code + - 'web-client/**' # web client source code + +env: + REGISTRY: ghcr.io + HASURA_WORKER_IMAGE_NAME: ${{ github.repository }}/worker + WEB_CLIENT_IMAGE_NAME: ${{ github.repository }}/web-client + +jobs: + build-docker-image: + runs-on: ubuntu-latest + environment: staging + permissions: + contents: read + packages: write + steps: + - name: Getting the repo + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Get current date + id: date + run: echo "::set-output name=date::$(date +'%Y.%m.%d')" + + # Build docker image for app-backend worker + - name: Build docker image for app-backend worker + if: ${{ contains(github.event.head_commit.added, 'app-backend/worker/') }} + run: | + cd ./app-backend/worker + docker build -t ${{ env.REGISTRY }}/${{ env.HASURA_WORKER_IMAGE_NAME }}:staging-${{ steps.date.outputs.date }}.${{github.run_number}} . + docker push ${{ env.REGISTRY }}/${{ env.HASURA_WORKER_IMAGE_NAME }}:staging-${{ steps.date.outputs.date }}.${{github.run_number}} + + # Get .env for FE + - name: Get .env file for build time + run: cd ./web-client && base64 -d <<< "$ENV_FILE_BASE64" > .env + shell: bash + env: + ENV_FILE_BASE64: ${{ secrets.ENV_FILE_BASE64 }} + + # Build and push docker for web client + - name: Build docker image for web-client + if: ${{ contains(github.event.head_commit.added, 'web-client/') }} + run: | + cd ./web-client + docker build -t ${{ env.REGISTRY }}/${{ env.WEB_CLIENT_IMAGE_NAME }}:staging-${{ steps.date.outputs.date }}.${{github.run_number}} . + docker push ${{ env.REGISTRY }}/${{ env.WEB_CLIENT_IMAGE_NAME }}:staging-${{ steps.date.outputs.date }}.${{github.run_number}} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy-jan-docs.yml similarity index 97% rename from .github/workflows/deploy.yml rename to .github/workflows/deploy-jan-docs.yml index 88de994f4..68a10b4bc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy-jan-docs.yml @@ -4,7 +4,8 @@ on: push: branches: - main - - fix/github-page-customdomain + paths: + - 'docs/**' # Review gh actions docs if you want to further define triggers, paths, etc # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on diff --git a/.github/workflows/quality-gate.yml b/.github/workflows/quality-gate.yml index 9351ba6af..f49f19abe 100644 --- a/.github/workflows/quality-gate.yml +++ b/.github/workflows/quality-gate.yml @@ -2,11 +2,9 @@ name: Linter & Sonarqube scanner on: push: branches: - - dev - main pull_request: branches: - - dev - main jobs: diff --git a/web-client/Dockerfile b/web-client/Dockerfile index eede493fd..8b1843602 100644 --- a/web-client/Dockerfile +++ b/web-client/Dockerfile @@ -9,7 +9,7 @@ WORKDIR /app # Install dependencies based on the preferred package manager COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ -RUN npm install && npm i -g @nestjs/cli typescript ts-node +RUN yarn add graphql && yarn install # 2. Rebuild the source code only when needed FROM base AS builder @@ -18,7 +18,7 @@ COPY --from=deps /app/node_modules ./node_modules COPY . . # This will do the trick, use the corresponding env file for each environment. -RUN npm run build +RUN yarn build # 3. Production image, copy all the files and run next FROM base AS runner @@ -34,7 +34,7 @@ COPY --from=builder /app/public ./public # Automatically leverage output traces to reduce image size # https://nextjs.org/docs/advanced-features/output-file-tracing -COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next +# COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/package.json ./package.json