Skip to content

Commit 1d47d9b

Browse files
created local dev and basic CI/CD
1 parent 79ce397 commit 1d47d9b

File tree

11 files changed

+81
-35
lines changed

11 files changed

+81
-35
lines changed

.github/workflows/deploy.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build and Push Services
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Log in to Docker Hub
16+
uses: docker/login-action@v3
17+
with:
18+
username: ${{ secrets.DOCKER_USERNAME }}
19+
password: ${{ secrets.DOCKER_PASSWORD }}
20+
21+
- name: Build & Push API Gateway
22+
uses: docker/build-push-action@v5
23+
with:
24+
context: ./API_Gateway
25+
push: true
26+
tags: anujakalahara99/api-gateway:latest
27+
28+
- name: Build & Push Codespace Service
29+
uses: docker/build-push-action@v5
30+
with:
31+
context: ./Codespace_Service
32+
push: true
33+
tags: anujakalahara99/codespace-service:latest
34+
35+
- name: Build & Push WS Server
36+
uses: docker/build-push-action@v5
37+
with:
38+
context: ./WS_Server
39+
push: true
40+
tags: anujakalahara99/ws-server:latest
41+
42+
deploy:
43+
runs-on: ubuntu-latest
44+
needs: build
45+
46+
steps:
47+
- name: Deploy on server
48+
uses: appleboy/ssh-action@v1.0.0
49+
with:
50+
host: ${{ secrets.SERVER_HOST }}
51+
username: ${{ secrets.SERVER_USER }}
52+
key: ${{ secrets.SERVER_SSH_KEY }}
53+
script: |
54+
cd /home/${{ secrets.SERVER_USER }}/app
55+
sudo docker compose pull
56+
sudo docker compose up -d --remove-orphans

API_Gateway/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ ENV HOST=0.0.0.0
1414

1515
ENV SUPABASE_JWT_SECRET="5zUyIiUCwuVglYQiXu847i+uIoaphtR4dih5mnVCP+7cHgt8gOdbpslgKwkGhzoS+9+h8sL/iDlLg9WRheSqpQ=="
1616

17+
ENV NODE_ENV="production"
18+
1719
EXPOSE 4000
1820

1921
CMD [ "npm", "start" ]

API_Gateway/src/routes.js

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ const ROUTES = [
88
limit: 100,
99
},
1010
proxy: {
11-
// target: "http://localhost:5000/codespaces",
12-
target: "http://codespace-service:5000/codespaces",
11+
target:
12+
process.env.NODE_ENV === "production"
13+
? "http://codespace-service:5000/codespaces"
14+
: "http://localhost:5000/codespaces",
1315
changeOrigin: true,
1416
pathRewrite: {
1517
[`^/codespaces`]: "",
@@ -25,8 +27,10 @@ const ROUTES = [
2527
limit: 100,
2628
},
2729
proxy: {
28-
// target: "http://localhost:5000/codespaces",
29-
target: "http://codespace-service:5000/api",
30+
target:
31+
process.env.NODE_ENV === "production"
32+
? "http://codespace-service:5000/api"
33+
: "http://localhost:5000/api",
3034
changeOrigin: true,
3135
pathRewrite: {
3236
[`^/api`]: "",
@@ -49,18 +53,6 @@ const ROUTES = [
4953
},
5054
},
5155
},
52-
{
53-
url: "/premium",
54-
auth: true,
55-
creditCheck: true,
56-
proxy: {
57-
target: "https://www.google.com",
58-
changeOrigin: true,
59-
pathRewrite: {
60-
[`^/premium`]: "",
61-
},
62-
},
63-
},
6456
{
6557
url: "/ws",
6658
auth: false,
@@ -70,9 +62,10 @@ const ROUTES = [
7062
limit: 1000,
7163
},
7264
proxy: {
73-
target: "ws://ws-server:4455",
74-
// target: "ws://144.24.128.44:4455",
75-
// target: "ws://localhost:4455",
65+
target:
66+
process.env.NODE_ENV === "production"
67+
? "ws://ws-server:4455"
68+
: "ws://localhost:4455",
7669
changeOrigin: true,
7770
ws: true,
7871
pathRewrite: {

API_Gateway/src/server.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import express from "express";
22
import cors from "cors";
33
import { config } from "dotenv";
4-
import { createServer } from "http";
54
config();
5+
import { createServer } from "http";
66
import setupProxies from "./middleware/proxy.js";
77
import ROUTES from "./routes.js";
88
import setupAuth from "./middleware/auth.js";
@@ -18,7 +18,6 @@ const corsConfig = {
1818
};
1919

2020
app.use(cors(corsConfig));
21-
// app.use(express.json());
2221
setupLogging(app);
2322
setupRateLimit(app, ROUTES);
2423
setupAuth(app, ROUTES);

Codespace_Service/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ ENV Email_user='codespace.mora@gmail.com'
2424

2525
ENV GOOGLE_GENERATIVE_AI_API_KEY='AIzaSyAhLe2PB2sTVfAhzUTMIEmSPjhFDKr_kDs'
2626

27+
ENV NODE_ENV="production"
28+
2729
EXPOSE 5000
2830

2931
CMD [ "npm", "start" ]

Codespace_Service/src/controllers/codespaceController.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { CodespaceService } from "../services/codespaceService.js";
22

33
export class CodespaceController {
44
static async getCodespaces(req, res, next) {
5+
// console.log("Fetching codespaces for user:", req.user.id);
6+
57
try {
68
const codespaces = await CodespaceService.getUserCodespaces(req.user.id);
79
res.json({

Frontend/src/App/CodeEditor/AIPanel.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ interface Message {
1111
}
1212

1313
export default function AskAIPanel() {
14-
// const CODESPACE_API_URL = "http://localhost:4000/codespaces";
15-
const CODESPACE_API_URL = "https://www.rtc-app.linkpc.net/api";
14+
const CODESPACE_API_URL = `${import.meta.env.VITE_BACKEND_URL}/api`;
1615

1716
const { theme } = useTheme();
1817
const [messages, setMessages] = useState<Message[]>([]);

Frontend/src/App/Dashboard/AcceptInvite.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ const getToken = () => {
1414
};
1515

1616
const CollaboratePage: React.FC = () => {
17-
// const CODESPACE_API_URL = "http://localhost:4000/codespaces";
18-
const CODESPACE_API_URL = "https://www.rtc-app.linkpc.net/codespaces";
17+
const CODESPACE_API_URL = `${import.meta.env.VITE_BACKEND_URL}/codespaces`;
1918

2019
const navigate = useNavigate();
2120
const { invitationId } = useParams<{ invitationId: string }>();
@@ -24,10 +23,6 @@ const CollaboratePage: React.FC = () => {
2423
const [isLoading, setIsLoading] = useState(false);
2524
const [showContent, setShowContent] = useState(false);
2625

27-
// Debugging: Log the invitationId
28-
console.log("Invitation ID:", invitationId);
29-
30-
// Animation effect
3126
useEffect(() => {
3227
const timer = setTimeout(() => setShowContent(true), 100);
3328
return () => clearTimeout(timer);
@@ -36,7 +31,6 @@ const CollaboratePage: React.FC = () => {
3631
const handleProceed = async () => {
3732
if (!invitationId) {
3833
setError("No invitation ID found in URL");
39-
console.error("No invitationId provided in URL");
4034
return;
4135
}
4236

@@ -61,7 +55,6 @@ const CollaboratePage: React.FC = () => {
6155
}
6256

6357
const data = await response.json();
64-
console.log("API response:", data);
6558
console.log("API response22:", data.invitation.workspace_id);
6659

6760
navigate(

Frontend/src/App/Dashboard/useCodespaces.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { type Session } from "@supabase/supabase-js";
33
import { type Codespace } from "./codespace.types";
44

55
export const useCodespaces = (session: Session) => {
6-
// const CODESPACE_API_URL = "http://localhost:4000/codespaces";
7-
const CODESPACE_API_URL = "https://www.rtc-app.linkpc.net/codespaces";
6+
const CODESPACE_API_URL = `${import.meta.env.VITE_BACKEND_URL}/codespaces`;
87

98
const [codespaces, setCodespaces] = useState<Codespace[]>([]);
109
const user = session.user;

Frontend/src/components/login.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ function Login() {
4848
const { error } = await supabase.auth.signInWithOAuth({
4949
provider: "google",
5050
options: {
51-
redirectTo:
52-
"https://68aee7a468a50f41d684ab8b--rtc-editor.netlify.app/dashboard",
51+
redirectTo: `${import.meta.env.VITE_AUTH_CALLBACK_URL}`,
5352
},
5453
});
5554

0 commit comments

Comments
 (0)