Skip to content

Commit

Permalink
Be gone mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueBurger committed Dec 27, 2024
1 parent 1e82a2a commit fcea282
Show file tree
Hide file tree
Showing 78 changed files with 1,487 additions and 1,803 deletions.
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules
dist
*.zip
_build
packets.mjs
*.log
test-context/
servers/
burgerpanel.sqlite3*
.git
burgerpanel-db-backup*
connector.burgerpanelsock
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ Web/dist
Share/BuildInfo.ts
Server/data.json
testing/
/db/
/servers/
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:23-alpine
RUN corepack enable
COPY . /panelbuild/
RUN rm -rf /panelbuild/Server/node_modules /panelbuild/Web/node_modules
WORKDIR /panelbuild/Server
ENV BURGERPANEL_DOCKER=1
RUN pnpm i
RUN pnpm buildRelease
FROM node:23-alpine
RUN apk update
RUN apk add openjdk21
WORKDIR /panel
COPY --from=0 /panelbuild/Server/node_modules/better-sqlite3/build/Release/better_sqlite3.node /panel/better_sqlite3.node
COPY --from=0 /panelbuild/Server/_build/ /panel
CMD [ "node", "burgerpanel.mjs" ]
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.github.theblueburger.burgerpanelintegrator;

import io.github.theblueburger.burgerpanelintegrator.packets.*;

import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
Expand Down Expand Up @@ -120,6 +122,12 @@ public void run() {
@Override
public void onDisable() {
try {
if(Bukkit.getServer().isStopping()) {
JSONObject stoppingJsonObject = new JSONObject();
stoppingJsonObject.put("dataType", "request");
stoppingJsonObject.put("type", "serverStopping");
write(stoppingJsonObject);
}
client.close();
} catch (IOException ignored) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected void execute(JSONObject data, String id) throws IOException {
locationObj.put("z", location.getZ());
locationObj.put("world", location.getWorld().getName());
playerObject.put("location", locationObj);
playerObject.put("gamemode", player.getGameMode().getValue());
playerArray.add(playerObject);
}
responseObj.put("players", playerArray);
Expand Down
2 changes: 2 additions & 0 deletions Server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ packets.mjs
*.log
test-context/
servers/
burgerpanel.sqlite3*
burgerpanel-db-backup-*
9 changes: 6 additions & 3 deletions Server/Gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import esbuild from "esbuild";
import packageJSON from "./package.json" with {type: "json"}
import path from "path";

const isDocker = process.env.BURGERPANEL_DOCKER == "1";

async function installWebIfForgotten() {
if(!existsSync("../Web/node_modules")) {
console.log("Installing web packages...");
Expand Down Expand Up @@ -55,10 +57,11 @@ async function runESBuild() {
format: "esm",
target: "es2022",
banner: {
js: "import { createRequire } from 'module'; const require = createRequire(import.meta.url);" // read comments in /src/clients.ts to see explanation for this
js: "import { createRequire } from 'module'; const require = createRequire(import.meta.url);import * as url from 'url';const __filename = url.fileURLToPath(import.meta.url);" // read comments in /src/clients.ts to see explanation for this
},
define: {
"process.env.NODE_ENV": "\"production\""
"process.env.NODE_ENV": "\"production\"",
"process.env.IS_DOCKER": isDocker ? "1" : "0"
},
outfile: "_build/burgerpanel.mjs",
});
Expand Down Expand Up @@ -105,7 +108,7 @@ async function copyFiles() {
fs.copyFileSync("../LICENSE", "_build/LICENSE.txt");
fs.copyFileSync("../README.md", "_build/README.txt");
if(!process.env.SKIP_WEB) fs.cpSync("../Web/dist/", "_build/Web", {recursive: true});
fs.writeFileSync("_build/mongodb_url.txt", "json:data.json");
fs.writeFileSync("_build/package.json", "{}");
}

async function serverSeries() {
Expand Down
32 changes: 17 additions & 15 deletions Server/buildTools/buildInfo.mjs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import fs from "node:fs";
import os from "node:os";
import { execSync } from "node:child_process";
let userInfo = os.userInfo();
let gitHash;
let branch;
try {
gitHash = execSync("git rev-parse HEAD").toString().trim();
branch = execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
} catch {}
import packageJSON from "../package.json" with {type: "json"}
fs.writeFileSync("../Share/BuildInfo.ts", "export let buildInfo = " + JSON.stringify({
date: Date.now(),
version: packageJSON.version,
compiledBy: userInfo.username,
builtOn: process.platform,
gitHash,
branch
}));
if(process.env.BURGERPANEL_DOCKER != "1") {
let userInfo = os.userInfo();
let gitHash;
let branch;
try {
gitHash = execSync("git rev-parse HEAD").toString().trim();
branch = execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
} catch {}
fs.writeFileSync("../Share/BuildInfo.ts", "export let buildInfo = " + JSON.stringify({
date: Date.now(),
version: packageJSON.version,
compiledBy: userInfo.username,
builtOn: process.platform,
gitHash,
branch
}));
}
18 changes: 0 additions & 18 deletions Server/docker-compose.yml

This file was deleted.

10 changes: 0 additions & 10 deletions Server/init-mongo-user.js

This file was deleted.

1 change: 0 additions & 1 deletion Server/mongodb_url.txt

This file was deleted.

14 changes: 7 additions & 7 deletions Server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@
"devDependencies": {
"@types/express": "^4.17.21",
"@types/mime-types": "^2.1.4",
"@types/ws": "^8.5.12",
"@vitest/ui": "^2.1.2",
"@types/ws": "^8.5.13",
"@vitest/ui": "^2.1.8",
"esbuild": "^0.24.0",
"gulp": "^5.0.0",
"typescript": "^5.6.2",
"vitest": "^2.1.2"
"typescript": "^5.7.2",
"vitest": "^2.1.8"
},
"dependencies": {
"@types/better-sqlite3": "^7.6.12",
"better-sqlite3": "^11.7.0",
"blueutilities": "^1.2.2",
"chalk": "^5.3.0",
"express": "^4.21.0",
"mime-types": "^2.1.35",
"mongoose": "^8.7.0",
"express": "^4.21.2",
"ws": "^8.18.0"
},
"packageManager": "[email protected]+sha256.22e36fba7f4880ecf749a5ca128b8435da085ecd49575e7fb9e64d6bf4fad394"
Expand Down
Loading

0 comments on commit fcea282

Please sign in to comment.