Skip to content

Commit

Permalink
Merge branch 'main' into feature/faq-section
Browse files Browse the repository at this point in the history
  • Loading branch information
VineeTagarwaL-code authored Sep 16, 2024
2 parents 606fabc + 8f382d6 commit 9c27b36
Show file tree
Hide file tree
Showing 32 changed files with 652 additions and 185 deletions.
31 changes: 28 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
DATABASE_URL="postgres://postgres:postgres@db:5432/job-board-db"
NEXTAUTH_SECRET="koXrQGB5TFDhiX47swxHW+4KALDX4kAvnQ5RHHvAOIzB"
#
# Database
#
DATABASE_URL="postgres://postgres:password@localhost:5432/postgres"

#
# AUTH
#
NEXTAUTH_SECRET="koXrQGB5TFD4KALDX4kAvnQ5RHHvAOIzB"
NEXTAUTH_URL="http://localhost:3000"

# PRISMA STUDIO DOCKER
POSTGRES_URL=postgres://postgres:postgres@db:5432/job-board-db
POSTGRES_HOST=db
POSTGRES_USERNAME=postgres
POSTGRES_PASSWORD=postgres

AWS_S3_REGION=your-aws-region
AWS_S3_ACCESS_KEY_ID=your-access-ID
AWS_S3_SECRET_ACCESS_KEY=your-access-key
AWS_S3_BUCKET_NAME=your-bucket
AWS_S3_BUCKET_NAME=your-bucket
#
# Bunny CDN
#
CDN_API_KEY=api-key
CDN_BASE_UPLOAD_URL=https://sg.storage.bunnycdn.com/job-board/assets
CDN_BASE_ACCESS_URL=https://job-board.b-cdn.net/assets


NEXT_PUBLIC_GOOGLE_MAPS_API_KEY=


41 changes: 41 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Continuous Deployment
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.prod
push: true
tags: 100xdevs/job-board-staging:${{ github.sha }}

- name: Clone staging-ops repo, update, and push
env:
PAT: ${{ secrets.PAT }}
run: |
git clone https://github.com/code100x/staging-ops.git
cd staging-ops
sed -i 's|image: 100xdevs/job-board-staging:.*|image: 100xdevs/job-board-staging:${{ github.sha }}|' staging/job-board/deployment.yml
git config user.name "GitHub Actions Bot"
git config user.email "[email protected]"
git add staging/job-board/deployment.yml
git commit -m "Update job-board-staging image to ${{ github.sha }}"
git push https://${PAT}@github.com/code100x/staging-ops.git main
41 changes: 41 additions & 0 deletions .github/workflows/cd_prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Continuous Deployment (Prod)
on:
push:
branches: [ production ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.prod
push: true
tags: 100xdevs/job-board:${{ github.sha }}

- name: Clone staging-ops repo, update, and push
env:
PAT: ${{ secrets.PAT }}
run: |
git clone https://github.com/code100x/staging-ops.git
cd staging-ops
sed -i 's|image: 100xdevs/job-board:.*|image: 100xdevs/job-board:${{ github.sha }}|' prod/job-board/deployment.yml
git config user.name "GitHub Actions Bot"
git config user.email "[email protected]"
git add prod/job-board/deployment.yml
git commit -m "Update job-board image to ${{ github.sha }}"
git push https://${PAT}@github.com/code100x/staging-ops.git main
6 changes: 5 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:

- name: Run format check
run: npm run check

- name: Run format fix if check fails
if: ${{ failure() }}
run: npm run format

- name: Run build
run: npm run build
run: npm run build
19 changes: 19 additions & 0 deletions Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

FROM node:20-alpine AS build
ARG DATABASE_URL
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
RUN DATABASE_URL=$DATABASE_URL npx prisma generate
RUN DATABASE_URL=$DATABASE_URL npm run build

FROM node:20-alpine AS production
WORKDIR /usr/src/app
COPY --from=build /usr/src/app/.next ./.next
COPY --from=build /usr/src/app/node_modules ./node_modules
COPY --from=build /usr/src/app/public ./public
COPY --from=build /usr/src/app/package.json ./package.json
CMD ["npm", "run", "start"]

EXPOSE 3000
67 changes: 58 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Project Name: Job Board

[All about job board](https://marmalade-height-05f.notion.site/100xDevs-Job-board-ab8ca399180d49e4bc0c2ff5c81dfb08?pvs=25) <br/>
[Job board bugs](https://marmalade-height-05f.notion.site/100xDevs-JOB-BOARD-Bugs-10115651c69c80478fc8f673a139bc60)
## Table of Contents

- [Description](#description)
Expand All @@ -11,14 +12,6 @@

Job Board is a platform designed to connect employers with potential employees. Employers can post job listings, and job seekers can apply for these positions. The application ensures a seamless and efficient job search and hiring process.

## Features

- **User Registration and Authentication**: Secure and easy registration and login for both employers and job seekers.
- **Job Listings Management**: Employers can create, update, and manage job listings.
- **Job Applications**: Job seekers can browse listings and apply directly through the platform.
- **Profile Management**: Users can create and update their profiles with relevant information.
- **Search and Filter**: Advanced search and filtering options to find the perfect job or candidate.

## Technologies

- **Web-app**: Next.Js, TypeScript
Expand All @@ -44,9 +37,23 @@ Follow these steps to set up the repository locally and run it.
1. Create a `.env` file in the root folder of your project. Update it following the convention of the `.env.example` file. Here's an example:

```bash
#
# Database
#
DATABASE_URL="postgres://postgres:password@localhost:5432/postgres"

#
# AUTH
#
NEXTAUTH_SECRET="koXrQGB5TFD4KALDX4kAvnQ5RHHvAOIzB"
NEXTAUTH_URL="http://localhost:3000"

#
# Bunny CDN
#
CDN_SZ_NAME=
CDN_BASE_PATH=
CDN_API_KEY=
```

2. To generate AUTH_SECRET,
Expand All @@ -61,6 +68,7 @@ Follow these steps to set up the repository locally and run it.

[Run in browser](https://www.cryptool.org/en/cto/openssl/)


### Running the Project with Docker

```bash
Expand Down Expand Up @@ -95,3 +103,44 @@ Now, you can run the project and make changes as needed.
Emails: '[email protected], [email protected]';
Password: '123456';
```


## Steps to create a BunnyCDN storage for this repo:

1. **Create a storage zone:**

<img src="https://utfs.io/f/CUistsOk9f0Iocrllmq4RQuXkCx9NthDrTEw6dFy1Z3KfIPc" alt="Create a storage zone" width="150" />

2. **Connect the storage zone to a pull zone:**

<img src="https://utfs.io/f/CUistsOk9f0ImevkKUyo3QdPNXDuFbcZEagW0AUej1tzvmMw" alt="Connect the storage zone to a pull zone" width="250" />

4. **Set environment variables:**

Go to the FTP & API Access section in the storage zone and add the following environment variables:

```bash
CDN_API_KEY=<your-api-key>
```

Which you can find in the storage -> [storage name] -> FTP & API Access section

<img src="https://utfs.io/f/CUistsOk9f0Imf5c1ZUyo3QdPNXDuFbcZEagW0AUej1tzvmM" alt="CDN_API_KEY" width="500" />

---

```bash
CDN_BASE_UPLOAD_URL=<your-cdn-base-upload-url>
```
Which is https://[your-hostname]/[storage-name]/[any folder name you might have added otherwise empty]

<img src="https://utfs.io/f/CUistsOk9f0Imf5c1ZUyo3QdPNXDuFbcZEagW0AUej1tzvmM" alt="CDN_BASE_UPLOAD_URL" width="500" />

---

```bash
CDN_BASE_ACCESS_URL=<your-cdn-base-access-url>
```
Which is https://[your-pull-zone-hostname]/[any folder name you might have added otherwise empty] or get link from the dashboard as mentioned below

<img src="https://utfs.io/f/CUistsOk9f0IyM9047Pa7YvK8qbtnUAPO9jwxdskhzc2JNoR" alt=" CDN_BASE_ACCESS_URL" width="600" />
11 changes: 11 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,16 @@ services:
timeout: 5s
retries: 5

prisma-studio:
container_name: prisma-studio
image: timothyjmiller/prisma-studio:latest
restart: unless-stopped
env_file:
- .env
depends_on:
- app
ports:
- 5555:5555

volumes:
postgres-data:
4 changes: 2 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const nextConfig = {
remotePatterns: [
{
protocol: 'https',
//Add aws s3 bucket hostname
hostname: '<bucket_url/hostname>', //example - youraws.s3.ap-south-2.amazonaws.com
//Change it with your cdn access domain here
hostname: 'job-board.b-cdn.net',
},
],
},
Expand Down
16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,28 @@
"lint": "next lint",
"dev:docker": "npm run db:seed & next dev",
"db:seed": "npx prisma db push & npx prisma db seed",
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,md,mdx,css}\"",
"db:studio": "npx prisma studio",
"check": "prettier --check \"**/*.{ts,tsx,js,jsx,md,mdx,css}\"",
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,md,mdx,css}\"",
"prepare": "husky"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"**/*.{ts,tsx,js,jsx,md,mdx,css}": [
"prettier --write"
]
},
"prisma": {
"seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.645.0",
"@aws-sdk/s3-request-presigner": "^3.645.0",
"@faker-js/faker": "^9.0.0",
"@hookform/resolvers": "^3.9.0",
"@prisma/client": "5.18.0",
"@radix-ui/react-accordion": "^1.2.0",
Expand All @@ -36,6 +48,7 @@
"@radix-ui/react-switch": "^1.1.0",
"@radix-ui/react-toast": "^1.2.1",
"@types/lodash": "^4.17.7",
"@types/uuid": "^10.0.0",
"@uidotdev/usehooks": "^2.4.1",
"bcryptjs": "^2.4.3",
"class-variance-authority": "^0.7.0",
Expand All @@ -55,6 +68,7 @@
"react-quill": "^2.0.0",
"tailwind-merge": "^2.4.0",
"tailwindcss-animate": "^1.0.7",
"uuid": "^10.0.0",
"vaul": "^0.9.1",
"zod": "^3.23.8",
"zod-error": "^1.5.0"
Expand Down
15 changes: 15 additions & 0 deletions prisma/migrations/20240915194739_init/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
Warnings:
- You are about to drop the column `location` on the `Job` table. All the data in the column will be lost.
- Added the required column `address` to the `Job` table without a default value. This is not possible if the table is not empty.
- Added the required column `city` to the `Job` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Job" DROP COLUMN "location",
ADD COLUMN "address" TEXT NOT NULL,
ADD COLUMN "city" TEXT NOT NULL;

-- DropEnum
DROP TYPE "JobLocations";
15 changes: 2 additions & 13 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ model Job {
type String
workMode WorkMode @map("work_mode")
currency Currency @default(INR)
location JobLocations
city String
address String
application String
companyLogo String
hasSalaryRange Boolean @default(false) @map("has_salary_range")
Expand Down Expand Up @@ -58,15 +59,3 @@ enum Role {
ADMIN
}

enum JobLocations {
BANGLORE
DELHI
MUMBAI
CHENNAI
PUNE
HYDERABAD
KOLKATA
AHMEDABAD
JAIPUR
SURAT
}
Loading

0 comments on commit 9c27b36

Please sign in to comment.