File tree Expand file tree Collapse file tree 4 files changed +72
-52
lines changed
Expand file tree Collapse file tree 4 files changed +72
-52
lines changed Original file line number Diff line number Diff line change 1+ name : CD Pipeline
2+
3+ on :
4+ workflow_run :
5+ workflows : ["CI Pipeline"]
6+ types :
7+ - completed
8+
9+ jobs :
10+ build :
11+ runs-on : aws-ec2
12+
13+ steps :
14+ - name : Pull Docker image
15+ run : sudo docker pull pratik50/receiptsnap-backend:latest
16+
17+ - name : Delete Old docker container
18+ run : sudo docker rm -f receiptsnap-backend || true
19+
20+ - name : Run Docker Container
21+ run : |
22+ sudo docker run -d -p 8080:8080 --name receiptsnap-backend \
23+ -e DATABASE_URL='${{ secrets.DATABASE_URL }}' \
24+ -e JWT_SECRET='${{ secrets.JWT_SECRET }}' \
25+ -e AWS_ACCESS_KEY_ID='${{ secrets.AWS_ACCESS_KEY_ID }}' \
26+ -e AWS_SECRET_ACCESS_KEY='${{ secrets.AWS_SECRET_ACCESS_KEY }}' \
27+ -e AWS_REGION='${{ secrets.AWS_REGION }}' \
28+ -e AWS_BUCKET_NAME='${{ secrets.AWS_BUCKET_NAME }}' \
29+ -e PORT='${{ secrets.PORT }}' \
30+ pratik50/receiptsnap-backend:latest
Original file line number Diff line number Diff line change 1+ name : CI Pipeline
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+ build :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ # 1️⃣ Checkout repo code
14+ - name : Checkout code
15+ uses : actions/checkout@v3
16+
17+ # 2️⃣ Set up Docker Buildx (multi-platform + cache support)
18+ - name : Set up Docker Buildx
19+ uses : docker/setup-buildx-action@v2
20+
21+ # 3️⃣ Docker login using GitHub Secrets
22+ - name : Log in to Docker Hub
23+ uses : docker/login-action@v2
24+ with :
25+ username : ${{ secrets.DOCKER_USERNAME }}
26+ password : ${{ secrets.DOCKER_PASSWORD }}
27+
28+ # 4️⃣ Build and push Docker image (commit SHA + latest)
29+ - name : Build and push Docker image
30+ uses : docker/build-push-action@v5
31+ with :
32+ context : .
33+ file : Dockerfile
34+ push : true
35+ tags : |
36+ pratik50/receiptsnap-backend:latest
37+ pratik50/receiptsnap-backend:${{ github.sha }}
38+ build-args : |
39+ DATABASE_URL=${{ secrets.DATABASE_URL }}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ WORKDIR /app
55# Copying dependencies & env & schema
66COPY package*.json ./
77COPY prisma ./prisma
8- COPY .env .env
98
109# Install dependencies
1110RUN npm install
@@ -17,6 +16,9 @@ COPY . .
1716RUN rm -rf node_modules/.prisma dist
1817
1918# Generate Prisma Client
19+ # Build-time ARG (only needed for prisma generate)
20+ ARG DATABASE_URL
21+ ENV DATABASE_URL=$DATABASE_URL
2022RUN npx prisma generate
2123
2224# Build TS files after client is ready
You can’t perform that action at this time.
0 commit comments