feature: docker container

This commit is contained in:
Andy Burke 2025-07-14 19:56:38 -07:00
parent 80032ad926
commit 524f9ff2e3
4 changed files with 84 additions and 41 deletions

23
Dockerfile Normal file
View file

@ -0,0 +1,23 @@
FROM denoland/deno:latest
EXPOSE 8000
WORKDIR /app
# Cache the dependencies as a layer (the following two steps are re-run only when deps.ts is modified).
# Ideally cache deps.ts will download and compile _all_ external files used in main.ts.
ADD handlers /app/handlers
COPY server.ts /app
COPY serverus.ts /app
COPY deno.json /app
COPY deno.lock /app
COPY README.md /app
RUN deno install --frozen
USER deno
ENV ROOT=/www
ENV TRACE_ERROR_RESPONSES=true
ENV SERVERUS_TYPESCRIPT_IMPORT_LOGGING=true
CMD ["sh", "-c", "deno --allow-env --allow-read --allow-write --allow-net /app/serverus.ts --hostname 0.0.0.0 --root ${ROOT}"]

View file

@ -15,8 +15,7 @@ Compiled:
Container: Container:
``` ```
<insert instructions for using a container> podman run -d --name web -v /var/public:/www andyburke/serverus:latest
<our container can and should be very simple: mount a /www into the container and we run serverus on it>
``` ```
Deno: Deno:

View file

@ -1,7 +1,7 @@
{ {
"name": "@andyburke/serverus", "name": "@andyburke/serverus",
"description": "A flexible HTTP server for mixed content. Throw static files, markdown, Typescript and (hopefully, eventually) more into a directory and serverus can serve it up a bit more like old-school CGI.", "description": "A flexible HTTP server for mixed content. Throw static files, markdown, Typescript and (hopefully, eventually) more into a directory and serverus can serve it up a bit more like old-school CGI.",
"version": "0.8.0", "version": "0.9.0",
"license": "MIT", "license": "MIT",
"exports": { "exports": {
".": "./serverus.ts", ".": "./serverus.ts",
@ -16,6 +16,8 @@
"fmt": "deno fmt", "fmt": "deno fmt",
"test": "DENO_ENV=test DATA_STORAGE_ROOT=./tests/data/$(date --iso-8601=seconds) SERVERUS_TYPESCRIPT_IMPORT_LOGGING=1 deno test --allow-env --allow-read --allow-write --allow-net --trace-leaks --fail-fast ./tests/", "test": "DENO_ENV=test DATA_STORAGE_ROOT=./tests/data/$(date --iso-8601=seconds) SERVERUS_TYPESCRIPT_IMPORT_LOGGING=1 deno test --allow-env --allow-read --allow-write --allow-net --trace-leaks --fail-fast ./tests/",
"build": "deno compile --allow-env --allow-read --allow-write --allow-net --include handlers ./serverus.ts -o serverus", "build": "deno compile --allow-env --allow-read --allow-write --allow-net --include handlers ./serverus.ts -o serverus",
"build_docker": "podman build -t andyburke/serverus .",
"publish_docker": "podman push --format v2s2 serverus docker://docker.io/andyburke/serverus:latest",
"serverus": "deno --allow-env --allow-read --allow-write --allow-net ./serverus.ts" "serverus": "deno --allow-env --allow-read --allow-write --allow-net ./serverus.ts"
}, },
"test": { "test": {
@ -42,12 +44,12 @@
"imports": { "imports": {
"@std/assert": "jsr:@std/assert@^1.0.11", "@std/assert": "jsr:@std/assert@^1.0.11",
"@std/async": "jsr:@std/async@^1.0.13", "@std/async": "jsr:@std/async@^1.0.13",
"@std/cli": "jsr:@std/cli@^1.0.19", "@std/cli": "jsr:@std/cli@^1.0.20",
"@std/fmt": "jsr:@std/fmt@^1.0.6", "@std/fmt": "jsr:@std/fmt@^1.0.6",
"@std/fs": "jsr:@std/fs@^1.0.14", "@std/fs": "jsr:@std/fs@^1.0.19",
"@std/http": "jsr:@std/http@^1.0.13", "@std/http": "jsr:@std/http@^1.0.19",
"@std/media-types": "jsr:@std/media-types@^1.1.0", "@std/media-types": "jsr:@std/media-types@^1.1.0",
"@std/path": "jsr:@std/path@^1.0.8", "@std/path": "jsr:@std/path@^1.1.1",
"@std/testing": "jsr:@std/testing@^1.0.9" "@std/testing": "jsr:@std/testing@^1.0.14"
} }
} }

85
deno.lock generated
View file

@ -5,27 +5,26 @@
"jsr:@std/assert@^1.0.13": "1.0.13", "jsr:@std/assert@^1.0.13": "1.0.13",
"jsr:@std/async@*": "1.0.11", "jsr:@std/async@*": "1.0.11",
"jsr:@std/async@^1.0.13": "1.0.13", "jsr:@std/async@^1.0.13": "1.0.13",
"jsr:@std/cli@^1.0.18": "1.0.19", "jsr:@std/cli@^1.0.20": "1.0.20",
"jsr:@std/cli@^1.0.19": "1.0.19",
"jsr:@std/data-structures@^1.0.8": "1.0.8", "jsr:@std/data-structures@^1.0.8": "1.0.8",
"jsr:@std/encoding@1": "1.0.10",
"jsr:@std/encoding@^1.0.10": "1.0.10", "jsr:@std/encoding@^1.0.10": "1.0.10",
"jsr:@std/encoding@^1.0.7": "1.0.10",
"jsr:@std/fmt@^1.0.6": "1.0.8", "jsr:@std/fmt@^1.0.6": "1.0.8",
"jsr:@std/fmt@^1.0.8": "1.0.8", "jsr:@std/fmt@^1.0.8": "1.0.8",
"jsr:@std/fs@^1.0.14": "1.0.18", "jsr:@std/fs@^1.0.18": "1.0.19",
"jsr:@std/fs@^1.0.17": "1.0.18", "jsr:@std/fs@^1.0.19": "1.0.19",
"jsr:@std/html@^1.0.4": "1.0.4", "jsr:@std/html@^1.0.4": "1.0.4",
"jsr:@std/http@^1.0.13": "1.0.17", "jsr:@std/http@^1.0.19": "1.0.19",
"jsr:@std/internal@*": "1.0.8", "jsr:@std/internal@*": "1.0.8",
"jsr:@std/internal@^1.0.6": "1.0.8", "jsr:@std/internal@^1.0.6": "1.0.8",
"jsr:@std/internal@^1.0.8": "1.0.8", "jsr:@std/internal@^1.0.8": "1.0.8",
"jsr:@std/internal@^1.0.9": "1.0.9",
"jsr:@std/media-types@^1.1.0": "1.1.0", "jsr:@std/media-types@^1.1.0": "1.1.0",
"jsr:@std/net@^1.0.4": "1.0.4", "jsr:@std/net@^1.0.4": "1.0.4",
"jsr:@std/path@^1.0.8": "1.1.0", "jsr:@std/path@^1.1.0": "1.1.1",
"jsr:@std/path@^1.1.0": "1.1.0", "jsr:@std/path@^1.1.1": "1.1.1",
"jsr:@std/streams@^1.0.9": "1.0.9", "jsr:@std/streams@^1.0.10": "1.0.10",
"jsr:@std/testing@^1.0.9": "1.0.13" "jsr:@std/testing@^1.0.14": "1.0.14",
"npm:@types/node@*": "22.15.15"
}, },
"jsr": { "jsr": {
"@std/assert@1.0.13": { "@std/assert@1.0.13": {
@ -40,8 +39,8 @@
"@std/async@1.0.13": { "@std/async@1.0.13": {
"integrity": "1d76ca5d324aef249908f7f7fe0d39aaf53198e5420604a59ab5c035adc97c96" "integrity": "1d76ca5d324aef249908f7f7fe0d39aaf53198e5420604a59ab5c035adc97c96"
}, },
"@std/cli@1.0.19": { "@std/cli@1.0.20": {
"integrity": "b3601a54891f89f3f738023af11960c4e6f7a45dc76cde39a6861124cba79e88" "integrity": "a8c384a2c98cec6ec6a2055c273a916e2772485eb784af0db004c5ab8ba52333"
}, },
"@std/data-structures@1.0.8": { "@std/data-structures@1.0.8": {
"integrity": "2fb7219247e044c8fcd51341788547575653c82ae2c759ff209e0263ba7d9b66" "integrity": "2fb7219247e044c8fcd51341788547575653c82ae2c759ff209e0263ba7d9b66"
@ -52,54 +51,74 @@
"@std/fmt@1.0.8": { "@std/fmt@1.0.8": {
"integrity": "71e1fc498787e4434d213647a6e43e794af4fd393ef8f52062246e06f7e372b7" "integrity": "71e1fc498787e4434d213647a6e43e794af4fd393ef8f52062246e06f7e372b7"
}, },
"@std/fs@1.0.18": { "@std/fs@1.0.19": {
"integrity": "24bcad99eab1af4fde75e05da6e9ed0e0dce5edb71b7e34baacf86ffe3969f3a", "integrity": "051968c2b1eae4d2ea9f79a08a3845740ef6af10356aff43d3e2ef11ed09fb06",
"dependencies": [ "dependencies": [
"jsr:@std/path@^1.1.0" "jsr:@std/internal@^1.0.9",
"jsr:@std/path@^1.1.1"
] ]
}, },
"@std/html@1.0.4": { "@std/html@1.0.4": {
"integrity": "eff3497c08164e6ada49b7f81a28b5108087033823153d065e3f89467dd3d50e" "integrity": "eff3497c08164e6ada49b7f81a28b5108087033823153d065e3f89467dd3d50e"
}, },
"@std/http@1.0.17": { "@std/http@1.0.19": {
"integrity": "98aec8ab4080d95c21f731e3008f69c29c5012d12f1b4e553f85935db601569f", "integrity": "52128c8d00a1f0b20019f8b72376e7ef5f3133375b6f805b5bc89b9de2ad4686",
"dependencies": [ "dependencies": [
"jsr:@std/cli@^1.0.18", "jsr:@std/cli",
"jsr:@std/encoding@^1.0.10", "jsr:@std/encoding",
"jsr:@std/fmt@^1.0.8", "jsr:@std/fmt@^1.0.8",
"jsr:@std/fs@^1.0.19",
"jsr:@std/html", "jsr:@std/html",
"jsr:@std/media-types", "jsr:@std/media-types",
"jsr:@std/net", "jsr:@std/net",
"jsr:@std/path@^1.1.0", "jsr:@std/path@^1.1.1",
"jsr:@std/streams" "jsr:@std/streams"
] ]
}, },
"@std/internal@1.0.8": { "@std/internal@1.0.8": {
"integrity": "fc66e846d8d38a47cffd274d80d2ca3f0de71040f855783724bb6b87f60891f5" "integrity": "fc66e846d8d38a47cffd274d80d2ca3f0de71040f855783724bb6b87f60891f5"
}, },
"@std/internal@1.0.9": {
"integrity": "bdfb97f83e4db7a13e8faab26fb1958d1b80cc64366501af78a0aee151696eb8"
},
"@std/media-types@1.1.0": { "@std/media-types@1.1.0": {
"integrity": "c9d093f0c05c3512932b330e3cc1fe1d627b301db33a4c2c2185c02471d6eaa4" "integrity": "c9d093f0c05c3512932b330e3cc1fe1d627b301db33a4c2c2185c02471d6eaa4"
}, },
"@std/net@1.0.4": { "@std/net@1.0.4": {
"integrity": "2f403b455ebbccf83d8a027d29c5a9e3a2452fea39bb2da7f2c04af09c8bc852" "integrity": "2f403b455ebbccf83d8a027d29c5a9e3a2452fea39bb2da7f2c04af09c8bc852"
}, },
"@std/path@1.1.0": { "@std/path@1.1.1": {
"integrity": "ddc94f8e3c275627281cbc23341df6b8bcc874d70374f75fec2533521e3d6886" "integrity": "fe00026bd3a7e6a27f73709b83c607798be40e20c81dde655ce34052fd82ec76",
"dependencies": [
"jsr:@std/internal@^1.0.9"
]
}, },
"@std/streams@1.0.9": { "@std/streams@1.0.10": {
"integrity": "a9d26b1988cdd7aa7b1f4b51e1c36c1557f3f252880fa6cc5b9f37078b1a5035" "integrity": "75c0b1431873cd0d8b3d679015220204d36d3c7420d93b60acfc379eb0dc30af"
}, },
"@std/testing@1.0.13": { "@std/testing@1.0.14": {
"integrity": "74418be16f627dfe996937ab0ffbdbda9c1f35534b78724658d981492f121e71", "integrity": "144b3737105b9071cb50c957681f58a1b8ec0f3e5b19ad830f401c5fa931e8f0",
"dependencies": [ "dependencies": [
"jsr:@std/assert@^1.0.13", "jsr:@std/assert@^1.0.13",
"jsr:@std/async@^1.0.13",
"jsr:@std/data-structures", "jsr:@std/data-structures",
"jsr:@std/fs@^1.0.17", "jsr:@std/fs@^1.0.18",
"jsr:@std/internal@^1.0.8", "jsr:@std/internal@^1.0.8",
"jsr:@std/path@^1.1.0" "jsr:@std/path@^1.1.0"
] ]
} }
}, },
"npm": {
"@types/node@22.15.15": {
"integrity": "sha512-R5muMcZob3/Jjchn5LcO8jdKwSCbzqmPB6ruBxMcf9kbxtniZHP327s6C37iOfuw8mbKK3cAQa7sEl7afLrQ8A==",
"dependencies": [
"undici-types"
]
},
"undici-types@6.21.0": {
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="
}
},
"remote": { "remote": {
"https://deno.land/std@0.184.0/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462", "https://deno.land/std@0.184.0/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462",
"https://deno.land/std@0.184.0/_util/os.ts": "d932f56d41e4f6a6093d56044e29ce637f8dcc43c5a90af43504a889cf1775e3", "https://deno.land/std@0.184.0/_util/os.ts": "d932f56d41e4f6a6093d56044e29ce637f8dcc43c5a90af43504a889cf1775e3",
@ -117,13 +136,13 @@
"dependencies": [ "dependencies": [
"jsr:@std/assert@^1.0.11", "jsr:@std/assert@^1.0.11",
"jsr:@std/async@^1.0.13", "jsr:@std/async@^1.0.13",
"jsr:@std/cli@^1.0.19", "jsr:@std/cli@^1.0.20",
"jsr:@std/fmt@^1.0.6", "jsr:@std/fmt@^1.0.6",
"jsr:@std/fs@^1.0.14", "jsr:@std/fs@^1.0.19",
"jsr:@std/http@^1.0.13", "jsr:@std/http@^1.0.19",
"jsr:@std/media-types@^1.1.0", "jsr:@std/media-types@^1.1.0",
"jsr:@std/path@^1.0.8", "jsr:@std/path@^1.1.1",
"jsr:@std/testing@^1.0.9" "jsr:@std/testing@^1.0.14"
] ]
} }
} }