Skip to content

Commit 8407086

Browse files
committed
updaet:added docker and Ci/CD pipeline
1 parent 2a597ac commit 8407086

6 files changed

Lines changed: 86 additions & 11 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Docker CI/CD to Render
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Docker
17+
uses: docker/setup-buildx-action@v2
18+
19+
- name: Docker Hub Login
20+
uses: docker/login-action@v2
21+
with:
22+
username: ${{ secrets.DOCKER_USERNAME }}
23+
password: ${{ secrets.DOCKER_PASSWORD }}
24+
25+
- name: Build Docker image
26+
run: |
27+
docker build -t nob0t/my-bytebox-backend:latest ./backend
28+
29+
- name: Push Docker image
30+
run: |
31+
docker push nob0t/my-bytebox-backend:latest
32+
33+
- name: Trigger Render Deploy
34+
uses: fjogeleit/http-request-action@v1
35+
with:
36+
url: https://api.render.com/deploy/srv-${{ secrets.RENDER_SERVICE_ID }}
37+
method: POST
38+
headers: |
39+
Authorization: Bearer ${{ secrets.RENDER_API_KEY }}
40+
Content-Type: application/json
41+
body: '{"clearCache":true}'

backend/.dockerignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Env files
2+
.env
3+
.env.*
4+
5+
# Node modules (we install inside container)
6+
node_modules
7+
8+
# Git
9+
.git
10+
.gitignore
11+
12+
# Docker files (optional but clean)
13+
Dockerfile
14+
docker-compose.yml
15+
16+
# Build cache (if any)
17+
dist
18+
build

backend/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM node:20-alpine
2+
3+
# Install redis
4+
RUN apk add --no-cache redis
5+
6+
WORKDIR /app
7+
8+
COPY package*.json ./
9+
RUN npm ci
10+
11+
COPY . .
12+
13+
RUN npm run build
14+
15+
EXPOSE 3000
16+
17+
# Start Redis + Node
18+
CMD redis-server --daemonize yes && node ./dist/server.js

backend/src/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ const port= Number(process.env.PORT);
66

77
server.listen(port,()=>{
88
console.log(`server is running on port: ${port}`)
9+
console.log(`🙋🏻‍♂️🙋🏻‍♂️t: ${port}`)
910
})

frontend/components/GoogleForm.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ const GoogleForm = () => {
2424
Authorization: `Bearer ${res.access_token}`,
2525
}
2626
})
27-
if(responses.status === 200){
28-
Cookies.set("token", res.access_token, {
29-
expires: 1, // days
30-
sameSite: "strict",
31-
secure: true
32-
});
33-
34-
}
3527
const form = new FormData();
3628
form.append('name', responses.data.name || '');
3729
form.append('email', responses.data.email || '');
@@ -52,6 +44,14 @@ const GoogleForm = () => {
5244
email: raw.email,
5345
picture: raw.picture
5446
}
47+
if(responses.status === 200){
48+
Cookies.set("token", res.access_token, {
49+
expires: 1, // days
50+
sameSite: "strict",
51+
secure: true
52+
});
53+
54+
}
5555
localStorage.setItem('user', JSON.stringify(user));
5656
Cookies.set('user', user._id, { expires: 1 });
5757
router.push('/')

frontend/next.config.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ const nextConfig: NextConfig = {
1616
typescript: {
1717
ignoreBuildErrors: true,
1818
},
19-
eslint: {
20-
ignoreDuringBuilds: true,
21-
},
2219
experimental: {
2320
serverActions: {
2421
bodySizeLimit: "100MB",

0 commit comments

Comments
 (0)