From 6608938024954c20eeeefb27a1d092d47763f6bc Mon Sep 17 00:00:00 2001 From: yash-1104github Date: Thu, 4 Dec 2025 03:23:18 +0530 Subject: [PATCH] Chore: implement ci/cd pipelines --- .github/workflows/backend-ci.yml | 87 +++++++++++++++++++++++++++++++ .github/workflows/frontend-ci.yml | 78 +++++++++++++++++++++++++++ README.md | 9 ++-- backend/Dockerfile | 3 -- docker-compose.yml | 16 ++---- frontend/Dockerfile | 2 - 6 files changed, 175 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/backend-ci.yml create mode 100644 .github/workflows/frontend-ci.yml diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml new file mode 100644 index 0000000..8c358e7 --- /dev/null +++ b/.github/workflows/backend-ci.yml @@ -0,0 +1,87 @@ +name: Backend CI/CD Pipeline + +on: + push: + branches: + - main + paths: + - "backend/**" + + pull_request: + branches: + - main + paths: + - "backend/**" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Set up node.js + uses: actions/setup-node@v4 + + - name: Install Dependencies + working-directory: ./backend + run: npm install + + - name: Code linting + working-directory: ./frontend + run: npm run lint + + - name: Build Code + working-directory: ./frontend + run: npm run build + + - name: Upload built backend (artifact) + uses: actions/upload-artifact@v4 + with: + name: backend-dist + path: backend/dist + + deploy: + runs-on: ubuntu-latest + needs: build + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Download backend build artifact + uses: actions/download-artifact@v4 + with: + name: backend-dist + path: backend/dist + + - 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 Docker Image + run: | + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --file backend/Dockerfile \ + -t ${{ secrets.DOCKERHUB_USERNAME }}/transyobe-backend:latest \ + --push \ + backend + + - name: Deployment confirmation + run: echo "Backend image pushed to Docker Hub successfully." + + + + + + + + + diff --git a/.github/workflows/frontend-ci.yml b/.github/workflows/frontend-ci.yml new file mode 100644 index 0000000..5076c23 --- /dev/null +++ b/.github/workflows/frontend-ci.yml @@ -0,0 +1,78 @@ +name: Frontend CI/CD + +on: + push: + branches: + - main + paths: + - "frontend/**" + pull_request: + branches: + - main + paths: + - "frontend/**" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Set Up Node.js + uses: actions/stepup-node@v4 + with: + node-version: '20' + + - name: Install dependencies + working-directory: ./frontend + run: npm install + + - name: Code linting + working-directory: ./frontend + run: npm run lint + + - name: Build Code + env: + VITE_API_URL: ${{secrets.VITE_API_URL}} + working-directory: ./frontend + run: npm run build + + - name: Upload built frontend (artifact) + uses: actions/upload-artifact@v4 + with: + name: frontend-dist + path: frontend/dist + + deploy: + runs-on: ubuntu-latest + needs: build + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - 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 Docker Image + run: | + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --file frontend/Dockerfile \ + -t ${{ secrets.DOCKERHUB_USERNAME }}/transyobe_frontend:latest \ + --push \ + --build-arg VITE_API_URL="${{ secrets.VITE_API_URL }}" \ + frontend + + - name: Successfully Deployed + run: echo "Frontend image pushed to Docker Hub successfully." + + diff --git a/README.md b/README.md index ff35748..e392950 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,13 @@ AI assistant that comprehends the video’s content — all within an elegant da - RAPIDAPI_KEY="your_rapidapi_key" ``` -- Run the application: +**Run the application:** + ```bash -- npm run dev -- Access the app at http://localhost:3000 +- docker compose pull +- docker compose up -d +- http://localhost:5173 +- http://localhost:8000 ``` ⭐ Star this repository if TransYobe helped you explore YouTube videos smarter with AI! \ No newline at end of file diff --git a/backend/Dockerfile b/backend/Dockerfile index cd23a66..0690e06 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -3,11 +3,9 @@ FROM node:20-alpine AS build WORKDIR /app COPY package*.json ./ - RUN npm install COPY . . - RUN npm run build @@ -16,7 +14,6 @@ FROM node:20-alpine WORKDIR /app COPY package*.json ./ - RUN npm install COPY --from=build /app/dist ./dist diff --git a/docker-compose.yml b/docker-compose.yml index 617666f..3835d86 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,25 +2,20 @@ version: "3.9" services: frontend: - build: - context: ./frontend - dockerfile: Dockerfile - args: - VITE_API_URL: "http://localhost:8000/api/v1" + image: yash4256/transyobe_frontend:latest container_name: frontend-transyobe restart: unless-stopped ports: - "5173:80" networks: - app-network - + environment: + - VITE_API_URL=http://backend:8000/api/v1 depends_on: - backend backend: - build: - context: ./backend - dockerfile: Dockerfile + image: yash4256/transyobe-backend:latest container_name: backend-transyobe restart: unless-stopped ports: @@ -31,9 +26,6 @@ services: - app-network depends_on: - mongo - volumes: - - ./backend:/app - - /app/node_modules mongo: image: mongo:7.0 diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 3aebbdd..2301f79 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -11,8 +11,6 @@ COPY . . ARG VITE_API_URL ENV VITE_API_URL=${VITE_API_URL} -RUN echo "Building frontend with API_URL=${VITE_API_URL}" - RUN npm run build