Docker should now work

This commit is contained in:
Chad Freeman 2024-10-13 17:16:06 -04:00
parent 9918001d29
commit 7671af5cbe
11 changed files with 1551 additions and 40 deletions

3
container/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
app
run
.vscode

15
container/Dockerfile Normal file
View file

@ -0,0 +1,15 @@
FROM denoland/deno:ubuntu-2.0.0
# This is the app that runs on port (env PORT)
COPY app/ /home/app
# This is the proxy that
# runs the app in the background
# AND lisens to (env SOCK) and forwards to localhost:(env PORT)
COPY proxy.ts /home/proxy.ts
RUN mkdir -p /var/run/proxy
ENV PORT=80
ENV SOCK="/var/run/proxy/app.sock"
ENTRYPOINT [ "deno", "run", "-A", "--unstable-worker-options", "./home/proxy.ts" ]

View file

@ -0,0 +1,9 @@
version: '3'
name: "bluffit"
services:
app:
container_name: "app"
build: .
volumes:
- ./run/:/var/run/proxy/

22
container/proxy.ts Normal file
View file

@ -0,0 +1,22 @@
const SOCKET = Deno.env.get("SOCK");
const PORT = Deno.env.get("PORT");
if(!SOCKET || !PORT) {
throw new Error("Missing port and socket env vars")
}
const worker = new Worker(new URL("./app/index.js", import.meta.url), {
deno: {
permissions: 'inherit'
},
name: 'server',
type: 'module'
})
worker.onerror = (e: ErrorEvent) => {
throw new Error(e.message)
}
Deno.serve({ path: SOCKET }, async (req) => {
return await fetch(`http://localhost:${PORT}`, req)
})

6
container/run.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
docker-compose down
rm -rf ./run
docker image remove bluffit-app
docker-compose up

12
container/update.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/bash
DIR="$(cd "$(dirname "$0")" && pwd)"
docker-compose down
docker image remove bluffit-app
cd ..
rm -rf "$DIR" &
curl -0 "https://github.com/mavdotjs/bluffit/releases/latest/download/container.zip"
unzip ./container.zip
cd container