diff --git a/.env.sample b/.env.sample new file mode 100644 index 000000000..b26c06d8c --- /dev/null +++ b/.env.sample @@ -0,0 +1 @@ +API_URL=https://your-teams-backend-probe-url.com diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml new file mode 100644 index 000000000..9df933681 --- /dev/null +++ b/.github/workflows/build-and-push.yml @@ -0,0 +1,32 @@ +name: Build and Push + +on: + push: + branches: + - dev + +jobs: + build_and_push: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + file: docker/development/Dockerfile + push: true + tags: hngdevops/nextjs-boilerplate:dev diff --git a/.github/workflows/clean-cicd.yml b/.github/workflows/build-lint-test.yml similarity index 61% rename from .github/workflows/clean-cicd.yml rename to .github/workflows/build-lint-test.yml index 3a5d749b8..a9d42b6f4 100644 --- a/.github/workflows/clean-cicd.yml +++ b/.github/workflows/build-lint-test.yml @@ -1,19 +1,10 @@ - -name: Clean CI/CD Pipeline +name: Build, Lint and Test on: - push: - branches: - - clean - paths-ignore: - - .github/workflows/** - -concurrency: - group: ${{ github.ref }} - cancel-in-progress: true + pull_request jobs: - build: + build_lint_test: runs-on: ubuntu-latest steps: @@ -24,7 +15,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: "20" - + - name: Cache pnpm modules uses: actions/cache@v3 with: @@ -52,17 +43,3 @@ jobs: - name: Run tests run: pnpm run test:ci - - deploy: - runs-on: ubuntu-latest - needs: build - - steps: - - name: Deploy to dev environment - uses: appleboy/ssh-action@v1.0.3 - with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - password: ${{ secrets.PASSWORD }} - script: | - ./deploy_dev.sh next \ No newline at end of file diff --git a/.github/workflows/checks.PR.yml b/.github/workflows/checks.PR.yml deleted file mode 100644 index 5c5978f18..000000000 --- a/.github/workflows/checks.PR.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: PR Checks - -on: - pull_request: - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: pnpm/action-setup@v4 - with: - version: 9 - - run: pnpm install - - name: "Test" - run: pnpm run test:ci -- --max-warnings 0 - - name: "Upload Coverage" - uses: actions/upload-artifact@v4 - with: - name: coverage - path: coverage - eslint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: pnpm/action-setup@v4 - with: - version: 9 - - run: pnpm install - - uses: reviewdog/action-eslint@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - fail_on_error: true - eslint_flags: ". --ext js,jsx,ts,tsx --ignore-path=.gitignore --max-warnings 0" diff --git a/.github/workflows/coverage.PR.yml b/.github/workflows/coverage-report.yml similarity index 79% rename from .github/workflows/coverage.PR.yml rename to .github/workflows/coverage-report.yml index 2cfb02af8..116ebc1a4 100644 --- a/.github/workflows/coverage.PR.yml +++ b/.github/workflows/coverage-report.yml @@ -1,13 +1,13 @@ -name: PR Checks - Report Coverage +name: Coverage Report on: workflow_run: - workflows: ["PR Checks"] + workflows: ["build-lint-test"] types: - completed jobs: - report-test: + coverage_report: runs-on: ubuntu-latest permissions: @@ -19,6 +19,6 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} run-id: ${{ github.event.workflow_run.id }} - - name: "Report Coverage" + - name: "Coverage Report" if: always() uses: davelosert/vitest-coverage-report-action@v2 diff --git a/.github/workflows/dev-cicd.yml b/.github/workflows/dev-cicd.yml deleted file mode 100644 index 0f265d782..000000000 --- a/.github/workflows/dev-cicd.yml +++ /dev/null @@ -1,68 +0,0 @@ - -name: Development CI/CD Pipeline - -on: - push: - branches: - - dev - paths-ignore: - - .github/workflows/** - -concurrency: - group: ${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: "20" - - - name: Cache pnpm modules - uses: actions/cache@v3 - with: - path: ~/.pnpm-store - key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm- - - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9 - - - name: Install dependencies - run: pnpm install - - - name: Lint code - run: pnpm lint - - - name: Build email - run: pnpm email:build - - - name: Build project - run: pnpm build - - - name: Run tests - run: pnpm run test:ci - - deploy: - runs-on: ubuntu-latest - needs: build - - steps: - - name: Deploy to dev environment - uses: appleboy/ssh-action@v1.0.3 - with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - password: ${{ secrets.PASSWORD }} - script: | - ./deploy_dev.sh next diff --git a/.github/workflows/dev-deployment.yml b/.github/workflows/dev-deployment.yml new file mode 100644 index 000000000..a5fc7e53b --- /dev/null +++ b/.github/workflows/dev-deployment.yml @@ -0,0 +1,27 @@ +name: Dev Deployment + +on: + workflow_run: + workflows: ["Build and Push"] + types: + - completed + +jobs: + deploy_to_dev: + if: github.event.repository.fork == false + runs-on: ubuntu-latest + + environment: + name: "dev" + url: ${{ vars.URL }} + + steps: + - name: Deploy to dev environment + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + script: | + cd hng_boilerplate_nextjs + ./scripts/dev_deploy.sh diff --git a/.github/workflows/prod-cicd.yml b/.github/workflows/prod-cicd.yml deleted file mode 100644 index d9123984a..000000000 --- a/.github/workflows/prod-cicd.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Production CI/CD Pipeline - -on: - push: - branches: - - main - paths-ignore: - - .github/workflows/** - -concurrency: - group: ${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: "20" - - - name: Cache pnpm modules - uses: actions/cache@v3 - with: - path: ~/.pnpm-store - key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm- - - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9 - - - name: Install dependencies - run: pnpm install - - - name: Lint code - run: pnpm lint - - - name: Build email - run: pnpm email:build - - - name: Build project - run: pnpm build - - - name: Run tests - run: pnpm run test:ci - - deploy: - runs-on: ubuntu-latest - needs: build - - steps: - - name: Deploy to prod environment - uses: appleboy/ssh-action@v1.0.3 - with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - password: ${{ secrets.PASSWORD }} - script: | - ./deploy_prod.sh next \ No newline at end of file diff --git a/.github/workflows/production-deployment.yml b/.github/workflows/production-deployment.yml new file mode 100644 index 000000000..8531be876 --- /dev/null +++ b/.github/workflows/production-deployment.yml @@ -0,0 +1,55 @@ +name: Production Deployment + +on: + workflow_dispatch: + push: + branches: + - main + paths-ignore: + - .github/workflows/** + +jobs: + build_and_push: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + file: docker/prod/Dockerfile + push: true + tags: hngdevops/nextjs-boilerplate:prod + + deploy_to_production: + needs: build_and_push + if: github.event.repository.fork == false + runs-on: ubuntu-latest + + environment: + name: "production" + url: ${{ vars.URL }} + + steps: + - name: Deploy to production environment + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + script: | + cd hng_boilerplate_nextjs + ./scripts/prod_deploy.sh diff --git a/.github/workflows/staging-cicd.yml b/.github/workflows/staging-cicd.yml deleted file mode 100644 index 1dbd788e8..000000000 --- a/.github/workflows/staging-cicd.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Staging CI/CD Pipeline - -on: - push: - branches: - - staging - paths-ignore: - - .github/workflows/** - -concurrency: - group: ${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: "20" - - - name: Cache pnpm modules - uses: actions/cache@v3 - with: - path: ~/.pnpm-store - key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm- - - - name: Install pnpm - uses: pnpm/action-setup@v4 - with: - version: 9 - - - name: Install dependencies - run: pnpm install - - - name: Lint code - run: pnpm lint - - - name: Build email - run: pnpm email:build - - - name: Build project - run: pnpm build - - - name: Run tests - run: pnpm run test:ci - - deploy: - runs-on: ubuntu-latest - needs: build - - steps: - - name: Deploy to staging environment - uses: appleboy/ssh-action@v1.0.3 - with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - password: ${{ secrets.PASSWORD }} - script: | - ./deploy_staging.sh next \ No newline at end of file diff --git a/.github/workflows/staging-deployment.yml b/.github/workflows/staging-deployment.yml new file mode 100644 index 000000000..481e00222 --- /dev/null +++ b/.github/workflows/staging-deployment.yml @@ -0,0 +1,55 @@ +name: Staging Deployment + +on: + workflow_dispatch: + push: + branches: + - staging + paths-ignore: + - .github/workflows/** + +jobs: + build_and_push: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + file: docker/staging/Dockerfile + push: true + tags: hngdevops/nextjs-boilerplate:staging + + deploy_to_staging: + needs: build_and_push + if: github.event.repository.fork == false + runs-on: ubuntu-latest + + environment: + name: "staging" + url: ${{ vars.URL }} + + steps: + - name: Deploy to staging environment + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + script: | + cd hng_boilerplate_nextjs + ./scripts/staging_deploy.sh diff --git a/.github/workflows/team-deployment.yml b/.github/workflows/team-deployment.yml new file mode 100644 index 000000000..0227383d5 --- /dev/null +++ b/.github/workflows/team-deployment.yml @@ -0,0 +1,141 @@ +name: Team Deployment + +on: + workflow_run: + workflows: ["Build and Push"] + types: + - completed + +jobs: + kimiko-golang: + if: github.event.repository.fork == false + runs-on: ubuntu-latest + + environment: + name: "kimiko-golang" + url: ${{ vars.URL }} + + steps: + - name: Deploy to kimiko-golang environment + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + script: | + cd hng_boilerplate_nextjs + ./scripts/team_deploy.sh kimiko-golang ${{ vars.PORT }} + + kimiko-csharp: + if: github.event.repository.fork == false + runs-on: ubuntu-latest + + environment: + name: "kimiko-csharp" + url: ${{ vars.URL }} + + steps: + - name: Deploy to kimiko-csharp environment + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + script: | + cd hng_boilerplate_nextjs + ./scripts/team_deploy.sh kimiko-csharp ${{ vars.PORT }} + + cyborgs-java: + if: github.event.repository.fork == false + runs-on: ubuntu-latest + + environment: + name: "cyborgs-java" + url: ${{ vars.URL }} + + steps: + - name: Deploy to cyborgs-java environment + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + script: | + cd hng_boilerplate_nextjs + ./scripts/team_deploy.sh cyborgs-java ${{ vars.PORT }} + + cyborgs-python: + if: github.event.repository.fork == false + runs-on: ubuntu-latest + + environment: + name: "cyborgs-python" + url: ${{ vars.URL }} + + steps: + - name: Deploy to cyborgs-python environment + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + script: | + cd hng_boilerplate_nextjs + ./scripts/team_deploy.sh cyborgs-python ${{ vars.PORT }} + + bulldozer-php: + if: github.event.repository.fork == false + runs-on: ubuntu-latest + + environment: + name: "bulldozer-php" + url: ${{ vars.URL }} + + steps: + - name: Deploy to bulldozer-php environment + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + script: | + cd hng_boilerplate_nextjs + ./scripts/team_deploy.sh bulldozer-php ${{ vars.PORT }} + + starlight-nestjs: + if: github.event.repository.fork == false + runs-on: ubuntu-latest + + environment: + name: "starlight-nestjs" + url: ${{ vars.URL }} + + steps: + - name: Deploy to starlight-nestjs environment + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + script: | + cd hng_boilerplate_nextjs + ./scripts/team_deploy.sh starlight-nestjs ${{ vars.PORT }} + + panther-expressjs: + if: github.event.repository.fork == false + runs-on: ubuntu-latest + + environment: + name: "panther-expressjs" + url: ${{ vars.URL }} + + steps: + - name: Deploy to panther-expressjs environment + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + script: | + cd hng_boilerplate_nextjs + ./scripts/team_deploy.sh panther-expressjs ${{ vars.PORT }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 256efa5bd..000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Checks - -on: - push: - branches: - - main - - dev - - staging - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: pnpm/action-setup@v4 - with: - version: 9 - - run: pnpm install - - name: "Test" - run: pnpm run test:ci - - eslint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 18 - - uses: pnpm/action-setup@v4 - with: - version: 9 - - run: pnpm install - - uses: reviewdog/action-eslint@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - fail_on_error: true - reporter: github-pr-check - eslint_flags: ". --ext js,jsx,ts,tsx --ignore-path=.gitignore --max-warnings 0" diff --git a/.gitignore b/.gitignore index a855a991a..8b0b1362f 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ yarn-error.log* # local env files .env*.local +.env # vercel .vercel @@ -37,4 +38,4 @@ yarn-error.log* next-env.d.ts # react email -/.react-email \ No newline at end of file +/.react-email diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..4682d02a6 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +Security is very important for this project and its community. 🔒 + +Learn more about it below. 👇 + +## Versions + +The latest version or release is supported. + +You are encouraged to write tests for your application and update your versions frequently after ensuring that your tests are passing. This way you will benefit from the latest features, bug fixes, and **security fixes**. + +## Reporting a Vulnerability + +If you think you found a vulnerability, and even if you are not sure about it, please report it right away by sending an email to: security@hng.tech. Please try to be as explicit as possible, describing all the steps and example code to reproduce the security issue. + +The maintainers will review it thoroughly and get back to you. + +## Public Discussions + +Please refrain from publicly discussing a potential security vulnerability. 🙊 + +It's better to discuss privately and try to find a solution first, to limit the potential impact as much as possible. diff --git a/docker/development/Dockerfile b/docker/development/Dockerfile index da94d3399..eaa083c9e 100644 --- a/docker/development/Dockerfile +++ b/docker/development/Dockerfile @@ -53,4 +53,4 @@ ENV PORT 3000 # server.js is created by next build from the standalone output # https://nextjs.org/docs/pages/api-reference/next-config-js/output -CMD HOSTNAME="0.0.0.0" node server.js \ No newline at end of file +CMD HOSTNAME="0.0.0.0" node server.js diff --git a/docker/development/docker-compose.yml b/docker/development/docker-compose.yml index f9cbfb510..869ed04f3 100644 --- a/docker/development/docker-compose.yml +++ b/docker/development/docker-compose.yml @@ -1,17 +1,16 @@ services: - next-dev-frontend-1: - build: - context: ../../ - dockerfile: docker/development/Dockerfile + frontend: + image: hngdevops/nextjs-boilerplate:dev ports: - 3100:3000 - restart: always + volumes: + - ../../.env:/app/.env - next-dev-frontend-2: - build: - context: ../../ - dockerfile: docker/development/Dockerfile - ports: - - 3130:3000 - restart: always + # next-dev-frontend-2: + # build: + # context: ../../ + # dockerfile: docker/development/Dockerfile + # ports: + # - 3130:3000 + # restart: always diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile index 1804005e9..74067e5bb 100644 --- a/docker/prod/Dockerfile +++ b/docker/prod/Dockerfile @@ -1,4 +1,4 @@ -Use the official Node.js image based on Alpine Linux for a smaller image size +# Use the official Node.js image based on Alpine Linux for a smaller image size FROM node:20-alpine AS base FROM base AS deps @@ -24,6 +24,7 @@ COPY . . # Build the application RUN corepack enable pnpm && pnpm run build + # Production image, copy all the files and run next FROM base AS runner WORKDIR /app @@ -52,4 +53,4 @@ ENV PORT 3000 # server.js is created by next build from the standalone output # https://nextjs.org/docs/pages/api-reference/next-config-js/output -CMD HOSTNAME="0.0.0.0" node server.js \ No newline at end of file +CMD HOSTNAME="0.0.0.0" node server.js diff --git a/docker/prod/docker-compose.yml b/docker/prod/docker-compose.yml index b3bd96b55..38660d65b 100644 --- a/docker/prod/docker-compose.yml +++ b/docker/prod/docker-compose.yml @@ -1,17 +1,16 @@ services: - next-prod-frontend-1: - build: - context: ../../ - dockerfile: docker/prod/Dockerfile + frontend: + image: hngdevops/nextjs-boilerplate:prod ports: - 3000:3000 - restart: always + volumes: + - ../../.env:/app/.env - next-prod-frontend-2: - build: - context: ../../ - dockerfile: docker/prod/Dockerfile - ports: - - 3030:3000 - restart: always + # next-prod-frontend-2: + # build: + # context: ../../ + # dockerfile: docker/prod/Dockerfile + # ports: + # - 3030:3000 + # restart: always diff --git a/docker/staging/Dockerfile b/docker/staging/Dockerfile index 1804005e9..74067e5bb 100644 --- a/docker/staging/Dockerfile +++ b/docker/staging/Dockerfile @@ -1,4 +1,4 @@ -Use the official Node.js image based on Alpine Linux for a smaller image size +# Use the official Node.js image based on Alpine Linux for a smaller image size FROM node:20-alpine AS base FROM base AS deps @@ -24,6 +24,7 @@ COPY . . # Build the application RUN corepack enable pnpm && pnpm run build + # Production image, copy all the files and run next FROM base AS runner WORKDIR /app @@ -52,4 +53,4 @@ ENV PORT 3000 # server.js is created by next build from the standalone output # https://nextjs.org/docs/pages/api-reference/next-config-js/output -CMD HOSTNAME="0.0.0.0" node server.js \ No newline at end of file +CMD HOSTNAME="0.0.0.0" node server.js diff --git a/docker/staging/docker-compose.yml b/docker/staging/docker-compose.yml index 96ed1f242..d279c3648 100644 --- a/docker/staging/docker-compose.yml +++ b/docker/staging/docker-compose.yml @@ -1,12 +1,11 @@ services: - next-staging-frontend-1: - build: - context: ../../ - dockerfile: docker/staging/Dockerfile + frontend: + image: hngdevops/nextjs-boilerplate:staging ports: - 3200:3000 - restart: always + volumes: + - ../../.env:/app/.env # next-staging-frontend-2: # build: diff --git a/docker/team-deploy/docker-compose.yml b/docker/team-deploy/docker-compose.yml new file mode 100644 index 000000000..276c26557 --- /dev/null +++ b/docker/team-deploy/docker-compose.yml @@ -0,0 +1,7 @@ +services: + frontend: + image: hngdevops/nextjs-boilerplate:dev + ports: + - "${PORT}:3000" + volumes: + - ../../.env:/app/.env diff --git a/scripts/dev_deploy.sh b/scripts/dev_deploy.sh new file mode 100755 index 000000000..2e7f92f3c --- /dev/null +++ b/scripts/dev_deploy.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +cd "$(git rev-parse --show-toplevel)" +git pull origin dev +docker pull hngdevops/nextjs-boilerplate:dev +docker compose --project-name dev-nextjs -f docker/development/docker-compose.yml up -d diff --git a/scripts/prod_deploy.sh b/scripts/prod_deploy.sh new file mode 100755 index 000000000..38ab8d1a1 --- /dev/null +++ b/scripts/prod_deploy.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +cd "$(git rev-parse --show-toplevel)" +git pull origin main +docker pull hngdevops/nextjs-boilerplate:prod +docker compose --project-name prod-nextjs -f docker/prod/docker-compose.yml up -d diff --git a/scripts/staging_deploy.sh b/scripts/staging_deploy.sh new file mode 100755 index 000000000..9a5f36ef3 --- /dev/null +++ b/scripts/staging_deploy.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +cd "$(git rev-parse --show-toplevel)" +git pull origin staging +docker pull hngdevops/nextjs-boilerplate:staging +docker compose --project-name staging-nextjs -f docker/staging/docker-compose.yml up -d diff --git a/scripts/team_deploy.sh b/scripts/team_deploy.sh new file mode 100755 index 000000000..c558e020a --- /dev/null +++ b/scripts/team_deploy.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +# Check if the team name is provided +if [ -z "$1" ] || [ -z "$2" ]; then + echo "Error: Port number is required." + echo "Usage: $0 [team name] [port]" + exit 1 +fi + +TEAM_NAME=$1 +export PORT=$2 + +cd "$(git rev-parse --show-toplevel)" +git pull origin dev +docker pull hngdevops/nextjs-boilerplate:dev +docker compose --project-name $TEAM_NAME -f docker/team-deploy/docker-compose.yml up -d diff --git a/src/app/(landing-routes)/hng-test/page.tsx b/src/app/(landing-routes)/hng-test/page.tsx new file mode 100644 index 000000000..e75751fd9 --- /dev/null +++ b/src/app/(landing-routes)/hng-test/page.tsx @@ -0,0 +1,23 @@ +import { unstable_noStore as noStore } from "next/cache"; + +export default async function HNGTEST() { + noStore(); + const API_URL = process.env.API_URL || "No API URL provided"; + let result = {} as { message?: string }; + try { + const response = await fetch(API_URL); + result = response.ok ? await response.json() : {}; + } catch { + result = {}; + } + return ( +
Version 0.12
+{API_URL}
+{result?.message}
+@@ -94,23 +95,25 @@ const ProjectLogo = ({ form, name }: Properties) => { className="grid h-full w-full place-items-center" >
Add a Product