diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 7693d73..0000000 --- a/Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -# use the official Bun image -# see all versions at https://hub.docker.com/r/oven/bun/tags -FROM docker.io/oven/bun:1 as base -WORKDIR /usr/src/app - -# install dependencies into temp directory -# this will cache them and speed up future builds -FROM base AS install -RUN mkdir -p /temp/dev -COPY package.json bun.lockb /temp/dev/ -RUN cd /temp/dev && bun install --frozen-lockfile - -# install with --production (exclude devDependencies) -RUN mkdir -p /temp/prod -COPY package.json bun.lockb /temp/prod/ -RUN cd /temp/prod && bun install --frozen-lockfile --production - -# copy node_modules from temp directory -# then copy all (non-ignored) project files into the image -FROM install AS prerelease -COPY --from=install /temp/dev/node_modules node_modules -COPY . . - -# [optional] tests & build -ENV NODE_ENV=production -RUN bun test -RUN bun run build - -# copy production dependencies and source code into final image -FROM base AS release -COPY --from=install /temp/prod/node_modules node_modules -COPY --from=prerelease /usr/src/app/index.ts . -COPY --from=prerelease /usr/src/app/package.json . - -# run the app -USER bun -EXPOSE 8000/tcp -EXPOSE 8080/tcp -ENTRYPOINT [ "bun", "run", "index.ts" ] - diff --git a/bun.lockb b/bun.lockb deleted file mode 100755 index 0b96ba4..0000000 Binary files a/bun.lockb and /dev/null differ diff --git a/flake.nix b/flake.nix index 9eda624..2a4d9b8 100644 --- a/flake.nix +++ b/flake.nix @@ -10,7 +10,7 @@ in { devShells.default = pkgs.mkShell { packages = with pkgs; [ - bun + go mpd mpc-cli ]; diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..32b28c0 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/cccb/sanic + +go 1.20 diff --git a/package.json b/package.json deleted file mode 100644 index e42eb85..0000000 --- a/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "sanic", - "module": "server.ts", - "type": "module", - "scripts": { - "start": "bun run server.ts", - "init": "mkdir -p /tmp/sanic/{music,playlists}; touch /tmp/sanic/mpd_db", - "mpd": "mpd --no-daemon ./mpd.conf", - "docker-build": "docker build --pull -t sanic .", - "docker-run": "docker run -it --rm -p 8000:8000 -p 8080:8080 sanic" - }, - "devDependencies": { - "bun-types": "latest" - }, - "peerDependencies": { - "typescript": "^5.0.0" - }, - "dependencies": { - "react": "^18.2.0" - } -} diff --git a/server.ts b/server.ts deleted file mode 100644 index 7ca927b..0000000 --- a/server.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Run websocket server -const wsServer = Bun.serve({ - port: 8080, - fetch(req, server) { - // upgrade the request to a WebSocket - if (server.upgrade(req)) { - return; // do not return a Response - } - return new Response("Upgrade failed :(", { status: 500 }); - }, - websocket: { - message(ws, message) { // a message is received - ws.send(message); // echo back the message - }, - open(ws) {}, // a socket is opened - close(ws, code, message) {}, // a socket is closed - drain(ws) {}, // the socket is ready to receive more data - }, -}); - -// Run web server -const webServer = Bun.serve({ - port: 8000, - //unix: "/run/sanic.sock", - fetch(req) { - return new Response("Put frontend here!"); - }, -}); - -console.log(`Listening on http://localhost:${webServer.port} ...`); -console.log(`Listening on ws://localhost:${wsServer.port} ...`); - diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 7556e1d..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "lib": ["ESNext"], - "module": "esnext", - "target": "esnext", - "moduleResolution": "bundler", - "moduleDetection": "force", - "allowImportingTsExtensions": true, - "noEmit": true, - "composite": true, - "strict": true, - "downlevelIteration": true, - "skipLibCheck": true, - "jsx": "react-jsx", - "allowSyntheticDefaultImports": true, - "forceConsistentCasingInFileNames": true, - "allowJs": true, - "types": [ - "bun-types" // add Bun global - ] - } -}