Skip to content

Commit 36d3d29

Browse files
committed
updated dockerfile for frontend, and lazy loading to more routes
1 parent 6c7ee45 commit 36d3d29

4 files changed

Lines changed: 48 additions & 24 deletions

File tree

Frontend/Dockerfile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
FROM node:20-alpine AS build
1+
FROM node:24-alpine AS build
22

33
WORKDIR /app
44

55
RUN npm i -g pnpm
66

77
COPY package*.json pnpm-lock.yaml* ./
8-
98
RUN pnpm install
109

1110
COPY . .
11+
RUN pnpm run build
12+
13+
14+
FROM nginx:1.27-alpine AS deploy
15+
16+
COPY nginx.conf /etc/nginx/conf.d/default.conf
17+
18+
COPY --from=build /app/dist /usr/share/nginx/html
1219

13-
EXPOSE 5173
20+
EXPOSE 80
1421

15-
CMD ["npm", "run", "host"]
22+
CMD ["nginx", "-g", "daemon off;"]

Frontend/nginx.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
server {
2+
listen 80;
3+
server_name _;
4+
5+
root /usr/share/nginx/html;
6+
index index.html;
7+
8+
location / {
9+
try_files $uri /index.html;
10+
}
11+
12+
gzip on;
13+
gzip_types text/plain text/css application/javascript application/json image/svg+xml;
14+
gzip_min_length 256;
15+
}

Frontend/src/components/jobs/JobCard.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export default function JobCard({ _id, jobName, method, url, nextRunAt, lastRunA
88
const [confirmDelete, setConfirmDelete] = useState(false);
99
const [open, setOpen] = useState(false);
1010
const menuRef = useRef<HTMLDivElement>(null);
11-
console.log(timeFormat24)
1211

1312
const formattedTime_NextRunAt = new Date(nextRunAt).toLocaleTimeString('en-US', {
1413
hour12: !timeFormat24,

Frontend/src/routes.tsx

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,58 @@
11
import { lazy, Suspense } from "react";
2-
import { createBrowserRouter } from "react-router-dom";
3-
import { Home, Login, Signup, Dashboard, CreateJob, Jobs, EditJob, Logs, JobLogs, Settings, NotFoundPage, ForgotPassword } from "./pages";
2+
import { createBrowserRouter, Outlet } from "react-router-dom";
3+
import { Dashboard, CreateJob, Jobs, EditJob, Logs, JobLogs, Settings } from "./pages";
44
import { Layout, ProtectedRoute, PublicRoute, Loader } from "./components";
55

6+
const Home = lazy(() => import("./pages/Home"));
67
const PrivacyPolicy = lazy(() => import("./pages/PrivacyPolicy"));
78
const Terms = lazy(() => import("./pages/Terms"));
89
const VerifyEmail = lazy(() => import("./pages/VerifyUserEmail"));
910
const ResetPassword = lazy(() => import("./pages/ResetPassword"));
11+
const NotFoundPage = lazy(() => import("./pages/NotFoundPage"));
12+
const Login = lazy(() => import("./pages/Login"));
13+
const Signup = lazy(() => import("./pages/Signup"));
14+
const ForgotPassword = lazy(() => import("./pages/ForgotPassword"));
1015

1116
export const router = createBrowserRouter([
12-
{ path: "/", element: <Home /> },
13-
1417
{
15-
path: "/privacy-policy",
1618
element: (
1719
<Suspense fallback={<Loader />}>
18-
<PrivacyPolicy />
20+
<Outlet />
1921
</Suspense>
2022
),
23+
children: [
24+
{ path: "/", element: <Home /> },
25+
{ path: "/privacy-policy", element: <PrivacyPolicy /> },
26+
{ path: "/terms", element: <Terms /> },
27+
{ path: "/verify-email/:userId", element: <VerifyEmail /> },
28+
{ path: "/reset-password/:token", element: <ResetPassword /> },
29+
{ path: "*", element: <NotFoundPage /> },
30+
],
2131
},
2232
{
23-
path: "/terms",
33+
path: "/login",
2434
element: (
2535
<Suspense fallback={<Loader />}>
26-
<Terms />
36+
<PublicRoute><Login /></PublicRoute>
2737
</Suspense>
2838
),
2939
},
30-
{ path: "/login", element: <PublicRoute><Login /></PublicRoute> },
31-
{ path: "/signup", element: <PublicRoute><Signup /></PublicRoute> },
32-
{ path: "/forgot-password", element: <PublicRoute><ForgotPassword /></PublicRoute> },
33-
3440
{
35-
path: "/verify-email/:userId",
41+
path: "/signup",
3642
element: (
3743
<Suspense fallback={<Loader />}>
38-
<VerifyEmail />
44+
<PublicRoute><Signup /></PublicRoute>
3945
</Suspense>
4046
),
4147
},
4248
{
43-
path: "/reset-password/:token",
49+
path: "/forgot-password",
4450
element: (
4551
<Suspense fallback={<Loader />}>
46-
<ResetPassword />
52+
<PublicRoute><ForgotPassword /></PublicRoute>
4753
</Suspense>
4854
),
4955
},
50-
5156
{
5257
element: <ProtectedRoute />,
5358
children: [
@@ -65,6 +70,4 @@ export const router = createBrowserRouter([
6570
},
6671
],
6772
},
68-
69-
{ path: "*", element: <NotFoundPage /> },
7073
]);

0 commit comments

Comments
 (0)