mirror of
https://github.com/khairul169/home-lab.git
synced 2025-04-28 08:39:34 +07:00
feat: web build 1.0
This commit is contained in:
parent
9402b650b6
commit
e10279bd0e
12
backend/Dockerfile
Normal file
12
backend/Dockerfile
Normal file
@ -0,0 +1,12 @@
|
||||
FROM oven/bun
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./package.json .
|
||||
COPY ./bun.lockb .
|
||||
|
||||
RUN bun install
|
||||
|
||||
COPY . .
|
||||
|
||||
CMD ["bun", "run", "index.ts"]
|
11
backend/docker-compose.yml
Normal file
11
backend/docker-compose.yml
Normal file
@ -0,0 +1,11 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
backend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: homelab-backend
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "5050:3000"
|
@ -1,5 +1,6 @@
|
||||
import { Hono } from "hono";
|
||||
import { cors } from "hono/cors";
|
||||
import { serveStatic } from "hono/bun";
|
||||
import { zValidator } from "@hono/zod-validator";
|
||||
import z from "zod";
|
||||
import si from "systeminformation";
|
||||
@ -16,15 +17,13 @@ const secondsToTime = (seconds: number) => {
|
||||
const d = Math.floor(seconds / (3600 * 24));
|
||||
const h = Math.floor((seconds % (3600 * 24)) / 3600);
|
||||
const m = Math.floor((seconds % 3600) / 60);
|
||||
const s = Math.floor(seconds % 60);
|
||||
// const s = Math.floor(seconds % 60);
|
||||
return `${d}d ${h}h ${m}m`;
|
||||
};
|
||||
|
||||
const app = new Hono()
|
||||
.use(cors())
|
||||
|
||||
.get("/", (c) => c.text("It works!"))
|
||||
|
||||
.get("/system", async (c) => {
|
||||
const date = new Date().toISOString();
|
||||
const uptime = secondsToTime(si.time().uptime || 0);
|
||||
@ -51,7 +50,11 @@ const app = new Hono()
|
||||
|
||||
const fsMounts = await si.fsSize();
|
||||
const storage = fsMounts
|
||||
.filter((i) => i.size > 32 * 1024 * 1024 * 1024)
|
||||
.filter(
|
||||
(i) =>
|
||||
i.size > 32 * 1024 * 1024 * 1024 &&
|
||||
!i.mount.startsWith("/var/lib/docker")
|
||||
)
|
||||
.map((i) => ({
|
||||
type: i.type,
|
||||
mount: i.mount,
|
||||
@ -106,7 +109,9 @@ const app = new Hono()
|
||||
|
||||
return c.json({ list });
|
||||
}
|
||||
);
|
||||
)
|
||||
|
||||
.use("*", serveStatic({ root: "./public" }));
|
||||
|
||||
export type AppType = typeof app;
|
||||
|
||||
|
@ -3,7 +3,8 @@
|
||||
"module": "index.ts",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "bun run --watch index.ts"
|
||||
"dev": "bun run --watch index.ts",
|
||||
"start": "bun run index.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest"
|
||||
|
File diff suppressed because one or more lines are too long
BIN
backend/public/favicon.ico
Normal file
BIN
backend/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
37
backend/public/index.html
Normal file
37
backend/public/index.html
Normal file
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
||||
<title>Home Lab</title>
|
||||
<!-- The `react-native-web` recommended style reset: https://necolas.github.io/react-native-web/docs/setup/#root-element -->
|
||||
<style id="expo-reset">
|
||||
/* These styles make the body full-height */
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
}
|
||||
/* These styles disable body scrolling if you are using <ScrollView> */
|
||||
body {
|
||||
overflow: hidden;
|
||||
}
|
||||
/* These styles make the root element full-height */
|
||||
#root {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
flex: 1;
|
||||
}
|
||||
</style>
|
||||
<link rel="shortcut icon" href="/favicon.ico" /></head>
|
||||
|
||||
<body>
|
||||
<!-- Use static rendering with Expo Router to support running without JavaScript. -->
|
||||
<noscript>
|
||||
You need to enable JavaScript to run this app.
|
||||
</noscript>
|
||||
<!-- The root element for your Expo app. -->
|
||||
<div id="root"></div>
|
||||
<script src="/_expo/static/js/web/entry-e06d28382380fb434ee081d40f28c03c.js" defer></script>
|
||||
</body>
|
||||
</html>
|
1
backend/public/metadata.json
Normal file
1
backend/public/metadata.json
Normal file
@ -0,0 +1 @@
|
||||
{"version":0,"bundler":"metro","fileMetadata":{}}
|
@ -48,7 +48,7 @@ const Performance = ({ data: system }: Props) => {
|
||||
{system ? (
|
||||
<Text className="text-xs">
|
||||
{`${system.perf.cpu.speed.toFixed(1)} GHz / ${
|
||||
system.perf.cpu.temp
|
||||
system.perf.cpu.temp || 0
|
||||
}°C`}
|
||||
</Text>
|
||||
) : null}
|
||||
|
@ -1 +1,2 @@
|
||||
export const API_BASEURL = "http://localhost:3000";
|
||||
// export const API_BASEURL = "http://localhost:3000";
|
||||
export const API_BASEURL = "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user