diff --git a/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index 28bf9359..00000000 --- a/.gitpod.yml +++ /dev/null @@ -1,8 +0,0 @@ -tasks: -- command: yarn -ports: -- port: 8080 - onOpen: open-browser -- port: 8888 - onOpen: ignore - visibility: public \ No newline at end of file diff --git a/package.json b/package.json index 67974faf..a3f5e07c 100644 --- a/package.json +++ b/package.json @@ -16,18 +16,16 @@ "yarn": "1.x" }, "scripts": { - "test": "jest --verbose", - "coverage": "jest --coverage", + "test": "jest --config ./test/jest.config.js --verbose", + "coverage": "jest --config ./test/jest.config.js --coverage", "dev": "webpack", "prettify": "prettier --cache true --write --trailing-comma es5 --no-semi {src,test}/**/*.[jt]s dist/**/*.{css,html} *.[jt]s *.json dist/lobby/*", "markdownlint": "npx markdownlint-cli2 README.md --fix", "serve": "webpack serve", - "servegitpod": "webpack serve --client-web-socket-url $(gp url 8080 | sed 's/http/ws/' | sed 's#$#/ws#')", "deps": "npx yarn-check --skip-unused", - "websocket": "node dist/server.js", - "build:server": "webpack --config webpack.server.config.js", + "websocket": "nodemon ./src/network/server/server.ts", + "build:server": "webpack --config ./src/network/server/webpack.server.config.js", "start:server": "node dist/server.js", - "nop": "echo nop", "dockerify": "docker build -f dist/Dockerfile -t tailuge/billiards-nginx .", "gltfpack": "npx gltfpack -i dist/models/p8.gltf -o dist/models/p8.min.gltf && npx gltfpack -i dist/models/threecushion.gltf -o dist/models/threecushion.min.gltf && npx gltfpack -i dist/models/snooker.gltf -o dist/models/snooker.min.gltf && npx gltfpack -i dist/models/d-snooker.gltf -o dist/models/d-snooker.min.gltf" }, diff --git a/src/network/Dockerfile b/src/network/server/Dockerfile similarity index 69% rename from src/network/Dockerfile rename to src/network/server/Dockerfile index d5038f6b..c97d3afe 100644 --- a/src/network/Dockerfile +++ b/src/network/server/Dockerfile @@ -2,9 +2,6 @@ FROM node:22-alpine WORKDIR /app -# Install nodemon globally -RUN npm install -g nodemon - # Create a non-root user RUN addgroup -S appgroup && adduser -S appuser -G appgroup USER appuser @@ -13,8 +10,8 @@ USER appuser COPY . . # Expose the application port -EXPOSE 8888 +EXPOSE 10000 # Command to run the application -CMD ["nodemon", "src/network/server/server.ts"] +CMD ["node", "dist/server.js"] diff --git a/src/network/server/webpack.server.config.js b/src/network/server/webpack.server.config.js new file mode 100644 index 00000000..3e55ccec --- /dev/null +++ b/src/network/server/webpack.server.config.js @@ -0,0 +1,25 @@ +const path = require("path"); +const nodeExternals = require(path.resolve(__dirname, "../../../node_modules/webpack-node-externals")); + +module.exports = { + target: "node", + externals: [nodeExternals()], + entry: "./src/network/server/server.ts", + output: { + path: path.resolve(__dirname, "../../../dist"), + filename: "server.js", + }, + resolve: { + extensions: [".ts", ".js"], + modules: [path.resolve(__dirname, "../../../node_modules"), "node_modules"], + }, + module: { + rules: [ + { + test: /\.ts$/, + use: "ts-loader", + exclude: /node_modules/, + }, + ], + }, +}; diff --git a/jest.config.js b/test/jest.config.js similarity index 97% rename from jest.config.js rename to test/jest.config.js index 07ac5e59..31925889 100644 --- a/jest.config.js +++ b/test/jest.config.js @@ -1,4 +1,5 @@ module.exports = { + rootDir: "../", preset: "ts-jest", transformIgnorePatterns: ["node_modules/(?!jsoncrush)"], transform: { diff --git a/webpack.server.config.js b/webpack.server.config.js deleted file mode 100644 index b6889ecd..00000000 --- a/webpack.server.config.js +++ /dev/null @@ -1,24 +0,0 @@ -const path = require('path'); -const nodeExternals = require('webpack-node-externals'); - -module.exports = { - entry: './src/network/server/server.ts', - target: 'node', - externals: [nodeExternals()], - output: { - path: path.resolve(__dirname, 'dist'), - filename: 'server.js', - }, - resolve: { - extensions: ['.ts', '.js'], - }, - module: { - rules: [ - { - test: /\.ts$/, - use: 'ts-loader', - exclude: /node_modules/, - }, - ], - }, -};