Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment #28

Merged
merged 4 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ build/
Thumbs.db

# Directories not needed in Docker context
stone-prover/
deployment/
dashboard/
k8s/
docs/
registry/
utils/
docs/
.git/
.github/

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ zetina-executor = { path = "crates/executor" }
zetina-peer = { path = "crates/peer" }
zetina-prover = { path = "crates/prover" }
zetina-runner = { path = "crates/runner" }
zetina-tests = { path = "crates/tests" }
zetina-tests = { path = "crates/tests" }
2 changes: 0 additions & 2 deletions dashboard/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,3 @@ coverage
*.spec.js
*.test.ts
*.spec.ts

k8s/
2 changes: 1 addition & 1 deletion dashboard/.env.production
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NEXT_PUBLIC_API_URL=http://localhost:4000
NEXT_PUBLIC_API_URL=https://api.delegator.zetina.iosis.tech
19 changes: 1 addition & 18 deletions dashboard/dashboard.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,5 @@ COPY . .
# Build the Next.js app
RUN npm run build

# Use a smaller base image for the final stage
FROM node:18-alpine AS runner

# Set the working directory
WORKDIR /app

# Copy the built files from the builder stage
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/public ./public
COPY --from=builder /app/package*.json ./

# Install only production dependencies
RUN npm install --omit=dev

# Expose the port that the app runs on
EXPOSE 3000

# Start the application using Next.js built-in server
CMD ["npm", "start"]
CMD ["npm", "run", "start"]
Binary file removed dashboard/public/background.jpg
Binary file not shown.
Binary file removed dashboard/public/zetina-logo.png
Binary file not shown.
20 changes: 13 additions & 7 deletions dashboard/src/app/api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { z } from "zod";

const hexStringSchema = z.string().regex(/^[0-9a-fA-F]+$/, 'Invalid hex string');
const base58Pattern = /^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+$/;
const base58Schema = z.string().regex(base58Pattern, 'Invalid Base58 string');
const hexStringSchema = z
.string()
.regex(/^[0-9a-fA-F]+$/, "Invalid hex string");
const base58Pattern =
/^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+$/;
const base58Schema = z.string().regex(base58Pattern, "Invalid Base58 string");
const bytesSchema = z.array(z.number());

// Zod for DelegateRequest
Expand All @@ -13,18 +16,21 @@ export type DelegateRequest = z.infer<typeof DelegateRequest>;

// Zod for DelegateResponse
export const DelegateResponse = z.object({
job_key: hexStringSchema
job_key: hexStringSchema,
});
export type DelegateResponse = z.infer<typeof DelegateResponse>;

// Zod for JobEventsRequest
export const JobEventsRequest = z.object({
job_key: hexStringSchema
job_key: hexStringSchema,
});
export type JobEventsRequest = z.infer<typeof JobEventsRequest>;

export const JobEventsResponse = z.object({
type: z.literal("Finished").or(z.literal("Delegated")).or(z.literal("BidReceived")),
type: z
.literal("Finished")
.or(z.literal("Delegated"))
.or(z.literal("BidReceived")),
data: z.any(),
});
export type JobEventsResponse = z.infer<typeof JobEventsResponse>;
Expand All @@ -33,4 +39,4 @@ export const Proof = bytesSchema;
export type Proof = z.infer<typeof Proof>;

export const PeerId = base58Schema;
export type PeerId = z.infer<typeof PeerId>;
export type PeerId = z.infer<typeof PeerId>;
34 changes: 3 additions & 31 deletions dashboard/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@
@tailwind utilities;

:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}

@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
}

body {
Expand All @@ -32,26 +24,6 @@ body {
}
}

.background {
position: relative;
}

.background::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url("../../public/background.jpg");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
opacity: 0.2; /* Adjust the opacity as needed */
filter: blur(5px);
z-index: -1; /* Ensure the image is behind any content in .background */
}

/* Hide scrollbar for WebKit browsers (Chrome, Safari) */
.scroll-container::-webkit-scrollbar {
display: none; /* Hide scrollbar */
Expand Down
9 changes: 8 additions & 1 deletion dashboard/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ export default function RootLayout({
return (
<html lang="en">
<head>
<link rel="icon" href="zetina-logo.png" />
<meta name="theme-color" content="#000" />
<meta
name="apple-mobile-web-app-status-bar-style"
content="black-translucent"
/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="#000" />
<meta name="msapplication-navbutton-color" content="#000" />
</head>
<body className={inter.className}>{children}</body>
</html>
Expand Down
29 changes: 18 additions & 11 deletions dashboard/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ function QontoStepIcon(props: StepIconProps) {
);
}


export default function Home() {
const workerRef = useRef<Worker>();
const darkTheme = createTheme({
Expand Down Expand Up @@ -183,7 +182,7 @@ export default function Home() {
const data: DelegateResponse = DelegateResponse.parse(
await response.json(),
);
addLog(`Job ${data.job_key} sent to the p2p network`)
addLog(`Job ${data.job_key} sent to the p2p network`);
setActiveStep(1);
setIsProcessing(data.job_key);

Expand All @@ -194,25 +193,29 @@ export default function Home() {
let job_event = JobEventsResponse.parse(event);
if (job_event.type == "BidReceived") {
let peer_id = PeerId.parse(job_event.data);
addLog(`Recived bid for job ${data.job_key} from peer ${peer_id}`)
addLog(
`Recived bid for job ${data.job_key} from peer ${peer_id}`,
);
setActiveStep(2);
}
if (job_event.type == "Delegated") {
let peer_id = PeerId.parse(job_event.data);
addLog(`Job ${data.job_key} delegated to peer ${peer_id}`)
addLog(`Job ${data.job_key} delegated to peer ${peer_id}`);
setActiveStep(3);
}
if (job_event.type == "Finished") {
let proof = Proof.parse(job_event.data);
addLog(`Job ${data.job_key} proof received`)
addLog(`Job ${data.job_key} proof received`);
setActiveStep(4);
setDownloadBlob([
new Blob([new Uint8Array(proof)]),
`${data.job_key}_proof.json`,
]);
setIsProcessing(null);
subscriber?.close();
await verifyProof(new TextDecoder().decode(new Uint8Array(job_event.data)))
await verifyProof(
new TextDecoder().decode(new Uint8Array(job_event.data)),
);
}
},
);
Expand Down Expand Up @@ -249,15 +252,16 @@ export default function Home() {

useEffect(() => {
if (scrollContainerRef.current) {
scrollContainerRef.current.scrollTop = scrollContainerRef.current.scrollHeight;
scrollContainerRef.current.scrollTop =
scrollContainerRef.current.scrollHeight;
}
}, [logs]);

return (
<ThemeProvider theme={darkTheme}>
<div className="h-screen flex flex-col background">
<main className="flex-1 grid justify-center items-center">
<div className="p-10 border-2 border-gray-800 rounded-2xl backdrop-blur-md grid grid-flow-row gap-8 w-[800px]">
<div className="h-screen flex flex-col">
<main className="flex-1 grid items-center">
<div className="p-10 border-2 border-gray-800 rounded-2xl backdrop-blur-md grid grid-flow-row gap-8 max-w-[1000px] w-full mx-auto">
<div className="text-center font-medium grid grid-flow-row gap-1">
<div className="text-xl font-bold">Zetina network</div>
<div className="text-md">Prove program Pie</div>
Expand Down Expand Up @@ -298,7 +302,10 @@ export default function Home() {
</Step>
))}
</Stepper>
<div ref={scrollContainerRef} className="scroll-container p-1 px-4 border-2 border-gray-800 rounded-2xl backdrop-blur-md h-20 overflow-y-scroll text-sm text-wrap break-words text-gray-500">
<div
ref={scrollContainerRef}
className="scroll-container p-1 px-4 border-2 border-gray-800 rounded-2xl backdrop-blur-md h-32 overflow-y-scroll text-xs text-wrap break-words text-gray-500"
>
{logs.map((log, index) => (
<div key={index}>{log}</div>
))}
Expand Down
3 changes: 0 additions & 3 deletions delegator.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@ WORKDIR /zetina-delegator
# Copy the rest of the application source code
COPY . .

# Expose necessary ports
EXPOSE 5678/udp 5679/tcp 3000/tcp

# Build the application in release mode
RUN cargo build --release --bin zetina-delegator
1 change: 1 addition & 0 deletions deployment/delegator/certificates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ spec:
secretName: zetina-tls

dnsNames:
- api.delegator.zetina.iosis.tech
- dashboard.delegator.zetina.iosis.tech
issuerRef:
name: letsencrypt-http01
Expand Down
2 changes: 1 addition & 1 deletion deployment/delegator/delegator-dashboard-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
image: registry.internal.iosis.tech/zetina-delegator-dashboard
resources:
limits:
cpu: "1000m"
cpu: "1"
memory: "1Gi"
ports:
- containerPort: 3000
Expand Down
67 changes: 0 additions & 67 deletions deployment/delegator/delegator-deployment.yaml

This file was deleted.

Loading
Loading