Skip to content

Commit 546296d

Browse files
committed
2 parents 4bdf70b + 26ded85 commit 546296d

16 files changed

+883
-102
lines changed

Dockerfile

Lines changed: 0 additions & 41 deletions
This file was deleted.

Dockerfile.airflow

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM apache/airflow:2.10.4
2+
3+
# Switch to root to install system dependencies
4+
USER root
5+
6+
# Install system dependencies with GPG signature verification workaround
7+
USER root
8+
RUN apt-get update -o Acquire::AllowInsecureRepositories=true \
9+
&& apt-get install -y --no-install-recommends --allow-unauthenticated \
10+
curl \
11+
unzip \
12+
gnupg \
13+
&& apt-get clean \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
# Install Terraform 1.5.7
17+
RUN curl -fsSL https://releases.hashicorp.com/terraform/1.5.7/terraform_1.5.7_linux_amd64.zip -o terraform.zip && \
18+
unzip terraform.zip -d /usr/local/bin && \
19+
rm terraform.zip && \
20+
terraform --version # Verify installation
21+
22+
# Switch back to the airflow user
23+
USER airflow
24+
WORKDIR /opt/airflow
25+
26+
# Copy and install Python dependencies
27+
COPY requirements.txt ./
28+
RUN pip install --no-cache-dir -r requirements.txt
29+
30+
# Copy the rest of your application code
31+
COPY . .
32+
33+
# Expose the port for the Airflow webserver
34+
EXPOSE 8081
35+
36+
# Set the default command to start the webserver
37+
CMD ["airflow", "webserver", "--port", "8081"]

Dockerfile.dummy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM alpine

Dockerfile.socket-server

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:20-slim
2+
3+
WORKDIR /app
4+
5+
COPY package*.json ./
6+
7+
RUN npm install
8+
9+
COPY ./server/server.js ./
10+
11+
EXPOSE 4000
12+
13+
CMD ["node", "server.js"]

Dockerfile.website

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM node:20
2+
3+
WORKDIR /app
4+
5+
COPY package.json package-lock.json ./
6+
7+
RUN npm install
8+
9+
COPY . .
10+
11+
RUN npm run build
12+
13+
EXPOSE 3000
14+
15+
CMD ["npm", "run", "start"]

debug.log

Lines changed: 636 additions & 0 deletions
Large diffs are not rendered by default.

docker-compose-minimal.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: "3"
2+
services:
3+
website:
4+
image: orchestronic.azurecr.io/orchestronic-app:website-latest
5+
ports:
6+
- "8080:3000"
7+
environment:
8+
- NODE_ENV=production
9+
command: ["npm", "run", "start"]
10+
socket-server:
11+
image: orchestronic.azurecr.io/orchestronic-app:socket-server-latest
12+
ports:
13+
- "4000:4000"
14+
environment:
15+
- NODE_ENV=production
16+
command: ["node", "server.js"]
17+
postgres:
18+
image: postgres:13
19+
environment:
20+
POSTGRES_USER: airflow
21+
POSTGRES_PASSWORD: airflow
22+
POSTGRES_DB: airflow
23+
redis:
24+
image: redis:7.2-bookworm
25+
expose:
26+
- 6379
27+
airflow-webserver:
28+
image: orchestronic.azurecr.io/orchestronic-app:airflow-webserver-latest
29+
command: webserver -p 8081
30+
ports:
31+
- "8081:8081"
32+
environment:
33+
AIRFLOW__CORE__EXECUTOR: CeleryExecutor
34+
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres/airflow
35+
AIRFLOW__CELERY__RESULT_BACKEND: db+postgresql://airflow:airflow@postgres/airflow
36+
AIRFLOW__CELERY__BROKER_URL: redis://:@redis:6379/0
37+
AIRFLOW__WEBSERVER__WEB_SERVER_PORT: "8081"

docker-compose.yaml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ x-airflow-common: &airflow-common
4949
# Comment the image line, place your Dockerfile in the directory where you placed the docker-compose.yaml
5050
# and uncomment the "build" line below, Then run `docker-compose build` to build the images.
5151
# image: ${AIRFLOW_IMAGE_NAME:-apache/airflow:2.10.4}
52-
build: .
52+
build:
53+
context: .
54+
dockerfile: Dockerfile.airflow
55+
image: ${AIRFLOW_IMAGE:-orchestronic.azurecr.io/orchestronic-app:airflow-webserver-latest}
5356
environment: &airflow-common-env
57+
PYTHONWARNINGS: "ignore"
5458
AIRFLOW__CORE__EXECUTOR: CeleryExecutor
5559
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres/airflow
5660
AIRFLOW__CELERY__RESULT_BACKEND: db+postgresql://airflow:airflow@postgres/airflow
@@ -83,6 +87,33 @@ x-airflow-common: &airflow-common
8387
condition: service_healthy
8488

8589
services:
90+
website:
91+
build:
92+
context: .
93+
dockerfile: Dockerfile.website
94+
image: ${WEBSITE_IMAGE:-orchestronic.azurecr.io/orchestronic-app:website-latest}
95+
ports:
96+
- "8080:3000"
97+
environment:
98+
- NODE_ENV=production
99+
command: ["npm", "run", start]
100+
depends_on:
101+
- socket-server
102+
restart: always
103+
104+
socket-server:
105+
build:
106+
context: .
107+
dockerfile: Dockerfile.socket-server
108+
image: ${WEBSITE_IMAGE:-orchestronic.azurecr.io/orchestronic-app:socket-server-latest}
109+
ports:
110+
- "4000:4000"
111+
environment:
112+
- NODE_ENV=production
113+
working_dir: /server
114+
command: ["node", "server.js"]
115+
restart: always
116+
86117
rabbitmq:
87118
image: rabbitmq:management-alpine
88119
tty: true
@@ -128,9 +159,12 @@ services:
128159
<<: *airflow-common
129160
command: webserver
130161
ports:
131-
- "8080:8080"
162+
- "8081:8081"
163+
environment:
164+
<<: *airflow-common-env
165+
AIRFLOW__WEBSERVER__WEB_SERVER_PORT: "8081"
132166
healthcheck:
133-
test: ["CMD", "curl", "--fail", "http://localhost:8080/health"]
167+
test: ["CMD", "curl", "--fail", "http://localhost:8081/health"]
134168
interval: 30s
135169
timeout: 10s
136170
retries: 5
@@ -260,7 +294,7 @@ services:
260294
_PIP_ADDITIONAL_REQUIREMENTS: ""
261295
user: "0:0"
262296
volumes:
263-
- ${AIRFLOW_PROJ_DIR:-.}:/sources
297+
- ${AIRFLOW_PROJ_DIR:-.}:/opt/airflow
264298

265299
airflow-cli:
266300
<<: *airflow-common

models/notification.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const notificationSchema = new Schema({
44
projectName: { type: String },
55
detail: { type: String },
66
userId: { type: String },
7-
date: { type: Date },
7+
date: { type: Date, default: Date.now },
88
});
99

1010
const Notification =

models/requesttype.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import mongoose, { Schema } from "mongoose";
22

33
const requesttypeSchema = new Schema({
4-
projectid: {
5-
type: String,
6-
ref: "Project"
7-
},
8-
status: { type: String },
4+
projectid: { type: String, required: true },
5+
status: { type: String, required: true },
96
});
107

118
const Requesttype =
12-
mongoose.models.Requesttype || mongoose.model("Requesttype", requesttypeSchema);
9+
mongoose.models.Requesttype ||
10+
mongoose.model("Requesttype", requesttypeSchema);
1311
export default Requesttype;

scaling.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
properties:
2+
configuration:
3+
minReplicas: 1
4+
maxReplicas: 10
5+
template:
6+
scale:
7+
rules:
8+
- name: cpu-scale
9+
custom:
10+
type: cpu
11+
metadata:
12+
value: "80" # CPU usage percentage (80%)
File renamed without changes.

src/app/api/request/route.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { connectMongoDB } from "../../../../lib/mongodb";
2-
import Request from "../../../../models/requesttype";
2+
import Request from "../../../../models/request";
33
import { NextResponse } from "next/server";
44

55
export async function GET(req) {

src/app/api/requesttype/route.js

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,33 @@ export async function GET(req) {
1717
}
1818

1919
export async function POST(req) {
20-
// Connect to MongoDB
21-
await connectMongoDB();
20+
try {
21+
await connectMongoDB();
2222

23-
const url = new URL(req.url);
24-
const projectid = url.searchParams.get("projectid");
25-
26-
const requesttype = await Requesttype({
27-
projectid,
28-
status: "created",
29-
}).save();
23+
// Parse the JSON body from the request
24+
const body = await req.json();
3025

31-
return NextResponse.json(
32-
{ message: "Successfully added requests", requests: requesttype },
33-
{ status: 201 }
34-
);
26+
// Validate required fields
27+
if (!body.projectid) throw new Error("Missing projectid");
28+
29+
// Set default status if not provided
30+
const requestData = {
31+
projectid: body.projectid,
32+
status: body.status,
33+
};
34+
35+
// Save to database
36+
const requesttype = new Requesttype(requestData);
37+
const saveRequestType = await requesttype.save();
38+
39+
return NextResponse.json({ saveRequestType }, { status: 200 });
40+
} catch (error) {
41+
console.error("Error creating request:", error);
42+
return NextResponse.json(
43+
{ message: "Error creating request", error: error.message },
44+
{ status: 500 }
45+
);
46+
}
3547
}
3648

3749
export async function PUT(req) {
@@ -43,25 +55,26 @@ export async function PUT(req) {
4355

4456
// Update requesttype or create if it doesn't exist
4557
const updatedRequestType = await Requesttype.findOneAndUpdate(
46-
{ projectid },
47-
{ status },
48-
{ new: true, upsert: true }
49-
);
50-
51-
return NextResponse.json(
52-
{ message: "Successfully updated request type", requesttype: updatedRequestType },
53-
{ status: 200 }
54-
);
55-
} catch (error) {
56-
console.error("Error updating request type:", error);
57-
return NextResponse.json(
58-
{ message: "Internal Server Error", error: error.message },
59-
{ status: 500 }
60-
);
61-
}
62-
}
58+
{ projectid },
59+
{ status },
60+
{ new: true, upsert: true }
61+
);
6362

64-
63+
return NextResponse.json(
64+
{
65+
message: "Successfully updated request type",
66+
requesttype: updatedRequestType,
67+
},
68+
{ status: 200 }
69+
);
70+
} catch (error) {
71+
console.error("Error updating request type:", error);
72+
return NextResponse.json(
73+
{ message: "Internal Server Error", error: error.message },
74+
{ status: 500 }
75+
);
76+
}
77+
}
6578

6679
export async function DELETE(req) {
6780
await connectMongoDB();
@@ -81,4 +94,4 @@ export async function DELETE(req) {
8194
{ message: "Request type deleted successfully" },
8295
{ status: 200 }
8396
);
84-
}
97+
}

src/app/page.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function HomePage() {
2727

2828
const data = await res.json();
2929
setNotificationList(data);
30-
// console.log("Notifications:", data);
30+
console.log("Notifications:", data);
3131
return data;
3232
} catch (error) {
3333
console.error("Error fetching notifications:", error);
@@ -128,7 +128,12 @@ export default function HomePage() {
128128

129129
{/* Footer Section */}
130130
<div className="flex justify-between items-center mt-2 text-xs text-gray-500">
131-
<p>Date: {new Date().toLocaleDateString()}</p>
131+
<p>
132+
Date:{" "}
133+
{new Date(notification.date).toLocaleDateString(
134+
"en-US"
135+
)}
136+
</p>
132137
<div className="flex items-center gap-2">
133138
<Image
134139
src={bell}

0 commit comments

Comments
 (0)