Skip to content

Commit

Permalink
Checking deployment pipeline for frontend and backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Puneet-NJ committed Jan 17, 2025
1 parent a330148 commit d00ab35
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 67 deletions.
46 changes: 19 additions & 27 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ jobs:
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 # Added for better build performance
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3 # Updated to v3
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Backend Docker image
uses: docker/build-push-action@v5 # Updated to v5
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.backend
Expand All @@ -38,28 +38,14 @@ jobs:
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}
CDN_LINK=${{ secrets.CDN_LINK }}
- name: Build and Push Frontend Docker image
uses: docker/build-push-action@v5 # Updated to v5
with:
context: .
file: ./Dockerfile.frontend
push: true
tags: puneetnj/course-app-fe:latest
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=puneetnj/course-app-fe:latest
cache-to: type=inline
CF_PUBLIC_KEY=${{ secrets.CF_PUBLIC_KEY }}
CF_PRIVATE_KEY=${{ secrets.CF_PRIVATE_KEY }}
- name: Verify Backend Image
run: |
docker pull puneetnj/course-app-be:latest
docker image inspect puneetnj/course-app-be:latest
- name: Verify Frontend Image
run: |
docker pull puneetnj/course-app-fe:latest
docker image inspect puneetnj/course-app-fe:latest
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
Expand All @@ -72,21 +58,27 @@ jobs:
sudo docker rm course-app-be || true
sudo docker run -d --name course-app-be -p 4000:4000 puneetnj/course-app-be:latest
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"

- name: Install Frontend Dependencies
working-directory: ./frontend # Adjust this path based on your project structure
run: npm install

- name: Build Frontend
working-directory: ./frontend # Adjust this path based on your project structure
run: npm run build

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Pull and Extract Frontend Assets
run: |
docker pull puneetnj/course-app-fe:latest
docker create --name temp_container puneetnj/course-app-fe:latest
docker cp temp_container:/usr/share/nginx/html/. ./dist
docker rm temp_container
- name: Deploy to S3
run: |
aws s3 sync dist s3://${{ secrets.S3_BUCKET }} --delete
aws s3 sync frontend/dist s3://${{ secrets.S3_BUCKET }} --delete
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"
22 changes: 0 additions & 22 deletions Dockerfile.frontend

This file was deleted.

2 changes: 1 addition & 1 deletion backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ app.use(cookieParser());
app.use(express.json());
app.use(
cors({
origin: "http://localhost:5174",
origin: "https://course-app.puneetnj.fun",
credentials: true,
methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
allowedHeaders: ["Content-Type", "Authorization"],
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const BLOCKCHAIN_COHORT_URL =
export const COHORT2_URL =
"https://appxcontent.kaxa.in/subject/2024-07-05-0.3715048534115637.jpeg";

export const BACKEND_URL = "http://localhost:4000/api/v1";
export const BACKEND_URL = "https://course-app-be.puneetnj.fun/api/v1";

export const ABOUT_CONTENT1 = "Welcome to 100xdevs.";

Expand Down
16 changes: 0 additions & 16 deletions nginx.conf

This file was deleted.

0 comments on commit d00ab35

Please sign in to comment.