Multi-Language Hello World Suite
This commit is contained in:
parent
4717e117fb
commit
f6e206889f
|
@ -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"]
|
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
|
@ -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"]
|
|
@ -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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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"]
|
||||||
|
|
|
@ -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();
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"name": "nodejs",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "nodejs",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "ISC"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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": ""
|
||||||
|
}
|
|
@ -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"]
|
|
@ -0,0 +1,8 @@
|
||||||
|
# app.py
|
||||||
|
import time
|
||||||
|
|
||||||
|
print("Starting loop...")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
print("App is running...")
|
||||||
|
time.sleep(5)
|
|
@ -0,0 +1,4 @@
|
||||||
|
FROM ubuntu
|
||||||
|
|
||||||
|
RUN apt-get update
|
||||||
|
CMD ["sleep", "1d"]
|
Loading…
Reference in New Issue