Add pelajaran 1 (Nginx) and pelajaran 2 (Node) lab starters.

This commit is contained in:
sayudhalw
2026-07-16 12:53:06 +07:00
commit 5e1c4f797d
6 changed files with 123 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
# learn — lab fullstack + homelab
Repo Gitea: https://git.sayudha.uk/sayudhalw/learn
Edit di Cursor di Mac, commit, lalu `git push`. Deploy ke `ubuntu-vm` terpisah (Docker).
## Isi (`main`)
| Folder | Pelajaran | Port di VM |
|--------|-----------|------------|
| `pelajaran-1/` | Nginx + HTML statis | `8088` |
| `pelajaran-2/` | Node.js di Docker | `8091` |
## Git remote
```bash
git remote -v
# gitea git@gitea:sayudhalw/learn.git
```
Butuh entry SSH (sudah disarankan di mesin ini):
```text
Host gitea
HostName 192.168.0.104
Port 2222
User git
ProxyJump proxmox
```
## Sync kode ke ubuntu-vm (jalankan container)
```bash
rsync -av pelajaran-1/ ubuntu-vm:~/learn/pelajaran-1/
rsync -av pelajaran-2/ ubuntu-vm:~/learn/pelajaran-2/
```
```bash
ssh ubuntu-vm 'cd ~/learn/pelajaran-1 && docker compose up -d'
ssh ubuntu-vm 'cd ~/learn/pelajaran-2 && docker compose up -d --build'
```
## Tunnel browser (dari Mac)
```bash
ssh -N -L 8088:127.0.0.1:8088 ubuntu-vm # pelajaran 1
ssh -N -L 8091:127.0.0.1:8091 ubuntu-vm # pelajaran 2
```
+8
View File
@@ -0,0 +1,8 @@
services:
web:
image: nginx:alpine
ports:
- "8088:80"
volumes:
- ./index.html:/usr/share/nginx/html/index.html:ro
restart: unless-stopped
+26
View File
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hello Homelab</title>
<style>
body {
font-family: system-ui, sans-serif;
max-width: 40rem;
margin: 4rem auto;
padding: 0 1rem;
line-height: 1.5;
}
code {
background: #eee;
padding: 0.1rem 0.3rem;
}
</style>
</head>
<body>
<h1>Hello dari homelab</h1>
<p>Ini halaman statis di Docker di VM Ubuntu (Proxmox).</p>
<p>Host: <code>ubuntu-vm</code> · Hypervisor: <code>sayudha</code> (PVE 9.2)</p>
</body>
</html>
+5
View File
@@ -0,0 +1,5 @@
FROM node:22-alpine
WORKDIR /app
COPY server.js .
EXPOSE 3000
CMD ["node", "server.js"]
+6
View File
@@ -0,0 +1,6 @@
services:
web:
build: .
ports:
- "8091:3000"
restart: unless-stopped
+30
View File
@@ -0,0 +1,30 @@
const http = require("http");
const server = http.createServer((request, response) => {
// request = apa yang browser minta
// response = apa yang kita kirim balik
const waktu = new Date().toLocaleString("id-ID");
response.writeHead(200, {
"Content-Type": "text/html; charset=utf-8",
});
response.end(`<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8" />
<title>Hello Node</title>
</head>
<body>
<h1>Hello dari Node di homelab</h1>
<p>Ini bukan file HTML diam. Teks di bawah dibuat oleh JavaScript saat request datang.</p>
<p>Waktu server sekarang: <strong>${waktu}</strong></p>
<p>Path yang diminta: <code>${request.url}</code></p>
</body>
</html>`);
});
server.listen(3000, () => {
console.log("Server siap di port 3000");
});