Multi-Language Hello World Suite

This commit is contained in:
adelyaou 2025-08-11 16:36:59 +07:00
parent 4717e117fb
commit f6e206889f
12 changed files with 141 additions and 0 deletions

9
go/Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM golang:1.20-alpine AS builder
WORKDIR /app
COPY . .
RUN go mod init goapp && go mod tidy
RUN go build -o main .
CMD ["./main"]

13
go/main.go Normal file
View File

@ -0,0 +1,13 @@
package main
import (
"fmt"
"time"
)
func main() {
for i := 1; i <= 10; i++ {
fmt.Printf("Angka ke-%d\n", i)
time.Sleep(1 * time.Minute) // jeda 1 menit
}
}

15
java/Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM openjdk:17-jdk-slim AS builder
WORKDIR /app
COPY . .
RUN javac Main.java
FROM eclipse-temurin:17-jre
WORKDIR /app
COPY --from=builder /app/Main.class .
ENTRYPOINT ["java", "Main"]

14
java/Main.java Normal file
View File

@ -0,0 +1,14 @@
import java.util.concurrent.TimeUnit;
public class Main {
public static void main(String[] args) {
for (int i = 1; i <= 10; i++) {
System.out.println("Angka ke-" + i);
try {
TimeUnit.MINUTES.sleep(5); // jeda 1 menit
} catch (InterruptedException e) {
System.out.println("Terjadi kesalahan saat menunggu.");
}
}
}
}

19
nodejs/Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM node:18-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --only=production
COPY . .
RUN npm run
FROM node:18-alpine
WORKDIR /app
COPY --from=builder /app ./
CMD ["node", "app.js"]

12
nodejs/app.js Normal file
View File

@ -0,0 +1,12 @@
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function loopWithDelay() {
for (let i = 1; i <= 10; i++) {
console.log(`Angka ke-${i}`);
await delay(60000); // delay 1 menit (60.000 ms)
}
}
loopWithDelay();

13
nodejs/package-lock.json generated Normal file
View File

@ -0,0 +1,13 @@
{
"name": "nodejs",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "nodejs",
"version": "1.0.0",
"license": "ISC"
}
}
}

12
nodejs/package.json Normal file
View File

@ -0,0 +1,12 @@
{
"name": "nodejs",
"version": "1.0.0",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": ""
}

22
python/Dockerfile Normal file
View File

@ -0,0 +1,22 @@
FROM python:3.9-alpine AS builder
WORKDIR /app
# Install build dependencies (needed for some Python packages)
RUN apk add --no-cache gcc musl-dev linux-headers
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
FROM python:3.9-alpine
WORKDIR /app
# Install runtime dependencies if needed (uncomment if your app needs them)
# RUN apk add --no-cache libstdc++
COPY --from=builder /app /app
CMD ["python", "app.py"]

8
python/app.py Normal file
View File

@ -0,0 +1,8 @@
# app.py
import time
print("Starting loop...")
while True:
print("App is running...")
time.sleep(5)

0
python/requirements.txt Normal file
View File

4
test/Dockerfile Normal file
View File

@ -0,0 +1,4 @@
FROM ubuntu
RUN apt-get update
CMD ["sleep", "1d"]