mirror of
https://github.com/Dokploy/examples
synced 2025-06-26 18:15:52 +00:00
commit
731fd5a41c
15
deno/Dockerfile
Normal file
15
deno/Dockerfile
Normal file
@ -0,0 +1,15 @@
|
||||
FROM denoland/deno:2.0.1
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY deno.json .
|
||||
|
||||
RUN deno install
|
||||
|
||||
COPY . .
|
||||
RUN deno cache main.ts
|
||||
|
||||
ARG PORT=8000
|
||||
EXPOSE $PORT
|
||||
|
||||
CMD ["task", "start"]
|
23
deno/README.md
Normal file
23
deno/README.md
Normal file
@ -0,0 +1,23 @@
|
||||
# Deno Example
|
||||
|
||||
This repository contains an example of Deno application that is deployed on Dokploy.
|
||||
|
||||
|
||||
1. **Use Git Provider in Your Application**:
|
||||
- Repository: `https://github.com/Dokploy/examples.git`
|
||||
- Branch: `main`
|
||||
- Build path: `/deno`
|
||||
- Select `Dockerfile` as Build Type
|
||||
- Type `Dockerfile` in the Dockerfile path field
|
||||
|
||||
2. **Click on Deploy**:
|
||||
- Deploy your application by clicking the deploy button.
|
||||
|
||||
3. **Generate a Domain**:
|
||||
- Click on generate domain button.
|
||||
- A new domain will be generated for you.
|
||||
- Set Port `8080`
|
||||
- You can use this domain to access your application.
|
||||
|
||||
|
||||
If you need further assistance, join our [Discord server](https://discord.com/invite/2tBnJ3jDJc).
|
11
deno/deno.json
Normal file
11
deno/deno.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"tasks": {
|
||||
"dev": "deno run --watch main.ts",
|
||||
"start": "deno run --allow-read --allow-env --allow-net main.ts"
|
||||
},
|
||||
"imports": {
|
||||
"@std/assert": "jsr:@std/assert@1",
|
||||
"@std/dotenv": "jsr:@std/dotenv@^0.225.2",
|
||||
"@std/http": "jsr:@std/http@^1.0.8"
|
||||
}
|
||||
}
|
59
deno/deno.lock
Normal file
59
deno/deno.lock
Normal file
@ -0,0 +1,59 @@
|
||||
{
|
||||
"version": "4",
|
||||
"specifiers": {
|
||||
"jsr:@std/cli@^1.0.6": "1.0.6",
|
||||
"jsr:@std/dotenv@*": "0.225.2",
|
||||
"jsr:@std/encoding@^1.0.5": "1.0.5",
|
||||
"jsr:@std/fmt@^1.0.2": "1.0.2",
|
||||
"jsr:@std/http@*": "1.0.8",
|
||||
"jsr:@std/media-types@^1.0.3": "1.0.3",
|
||||
"jsr:@std/net@^1.0.4": "1.0.4",
|
||||
"jsr:@std/path@^1.0.6": "1.0.6",
|
||||
"jsr:@std/streams@^1.0.7": "1.0.7"
|
||||
},
|
||||
"jsr": {
|
||||
"@std/cli@1.0.6": {
|
||||
"integrity": "d22d8b38c66c666d7ad1f2a66c5b122da1704f985d3c47f01129f05abb6c5d3d"
|
||||
},
|
||||
"@std/dotenv@0.225.2": {
|
||||
"integrity": "e2025dce4de6c7bca21dece8baddd4262b09d5187217e231b033e088e0c4dd23"
|
||||
},
|
||||
"@std/encoding@1.0.5": {
|
||||
"integrity": "ecf363d4fc25bd85bd915ff6733a7e79b67e0e7806334af15f4645c569fefc04"
|
||||
},
|
||||
"@std/fmt@1.0.2": {
|
||||
"integrity": "87e9dfcdd3ca7c066e0c3c657c1f987c82888eb8103a3a3baa62684ffeb0f7a7"
|
||||
},
|
||||
"@std/http@1.0.8": {
|
||||
"integrity": "6ea1b2e8d33929967754a3b6d6c6f399ad6647d7bbb5a466c1eaf9b294a6ebcd",
|
||||
"dependencies": [
|
||||
"jsr:@std/cli",
|
||||
"jsr:@std/encoding",
|
||||
"jsr:@std/fmt",
|
||||
"jsr:@std/media-types",
|
||||
"jsr:@std/net",
|
||||
"jsr:@std/path",
|
||||
"jsr:@std/streams"
|
||||
]
|
||||
},
|
||||
"@std/media-types@1.0.3": {
|
||||
"integrity": "b12d30a7852f7578f4d210622df713bbfd1cbdd9b4ec2eaf5c1845ab70bab159"
|
||||
},
|
||||
"@std/net@1.0.4": {
|
||||
"integrity": "2f403b455ebbccf83d8a027d29c5a9e3a2452fea39bb2da7f2c04af09c8bc852"
|
||||
},
|
||||
"@std/path@1.0.6": {
|
||||
"integrity": "ab2c55f902b380cf28e0eec501b4906e4c1960d13f00e11cfbcd21de15f18fed"
|
||||
},
|
||||
"@std/streams@1.0.7": {
|
||||
"integrity": "1a93917ca0c58c01b2bfb93647189229b1702677f169b6fb61ad6241cd2e499b"
|
||||
}
|
||||
},
|
||||
"workspace": {
|
||||
"dependencies": [
|
||||
"jsr:@std/assert@1",
|
||||
"jsr:@std/dotenv@~0.225.2",
|
||||
"jsr:@std/http@^1.0.8"
|
||||
]
|
||||
}
|
||||
}
|
24
deno/main.ts
Normal file
24
deno/main.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import "jsr:@std/dotenv/load";
|
||||
import { serveFile } from "jsr:@std/http/file-server";
|
||||
|
||||
const PORT = Deno.env.get("PORT") || 8000;
|
||||
|
||||
const handler = async (req: Request): Promise<Response> => {
|
||||
const url = new URL(req.url);
|
||||
|
||||
if (url.pathname === "/") {
|
||||
return await serveFile(req, "./public/index.html");
|
||||
} else if (url.pathname === "/greet") {
|
||||
const greeting = Deno.env.get("GREETING") || "Hello from Deno 2!";
|
||||
return new Response(greeting);
|
||||
} else {
|
||||
return new Response("Not Found", { status: 404 });
|
||||
}
|
||||
};
|
||||
|
||||
// Error handling
|
||||
try {
|
||||
Deno.serve({ port: Number(PORT) }, handler);
|
||||
} catch (err) {
|
||||
console.error("Error starting the server:", err);
|
||||
}
|
40
deno/public/index.html
Normal file
40
deno/public/index.html
Normal file
@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title>Deno 2 Web Server</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f4f4f4;
|
||||
color: #333;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
.container {
|
||||
text-align: center;
|
||||
}
|
||||
h1 {
|
||||
color: #4caf50;
|
||||
}
|
||||
p {
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Welcome to Deno 2</h1>
|
||||
<p>Your Deno 2 web server is up and running!</p>
|
||||
<p>
|
||||
Visit the <a href="/greet">/greet</a> endpoint to see a greeting
|
||||
message.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user