Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# common
**/node_modules
.git

# client module
www/js
www/js-lib
www/js-bundles
www/media/music
www/resource_packs/bbmodel/*.json
www/resource_packs/bbmodel/textures/*.png
www/resource_packs/bbmodel/textures/*.jpg
www/resource_packs/bbmodel/textures/*.jpeg
www/resource_packs/base/textures
www/resource_packs/base/blocks.json

# server module
node_server/js_server
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/world
/storage
www/js-gen
www/js-bundles
www/js-lib
Expand Down
58 changes: 58 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM node:19.7.0-alpine

WORKDIR /app

# Install necessary dependencies
RUN apk add --no-cache git wget fontconfig

# Create folders
RUN mkdir -p \
/app/webcraft \
/app/webcraft/node_server \
/app/webcraft/ff-worker

# Copy package.json files
COPY package.json /app/webcraft/package.json
COPY node_server/package.json /app/webcraft/node_server/package.json
COPY ff-worker/package.json /app/webcraft/ff-worker/package.json

# Install all dependencies
# TODO: Use npm ci instead of npm install after removing package-lock from .gitignore
RUN cd /app/webcraft && \
npm install && \
cd /app/webcraft/node_server && \
npm install && \
cd /app/webcraft/ff-worker && \
npm install

# Download resourcepacks
RUN mkdir -p /app/resource-packs && \
wget -q -O /app/resource-packs/depixel.zip https://dl.dropboxusercontent.com/s/vjob09w2pn2gv1m/Depixel.zip && \
unzip /app/resource-packs/depixel.zip -d /app/resource-packs/depixel && \
rm /app/resource-packs/depixel.zip && \
git clone --depth=1 --branch=main https://github.com/sciner/webcraft-texturepack /app/resource-packs/1 && \
rm -rf /app/resource-packs/1/.git

# Copy all files
COPY . /app/webcraft

# Create music folder
RUN mkdir -p /app/music && \
cp /app/webcraft/doc/examples/music.json /app/music/music.json

# Compile assets
RUN cd /app/webcraft/node_server && \
npm run compile-assets

# Compile typescript
RUN cd /app/webcraft && \
npm run build:www && \
npm run types:server

# Compile ff_worker
RUN cd /app/webcraft/ff-worker && \
npm run start

WORKDIR /app/webcraft/node_server

CMD npm run start
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '2'


services:
app:
build: .
volumes:
- ./storage:/app/webcraft/storage
ports:
- 5700:5700
2 changes: 1 addition & 1 deletion node_server/conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"AppVersion": "0.0.3",
"AppCode": "madcraft",
"ServerIP": "127.0.0.1",
"ServerIP": "0.0.0.0",
"Port": 5700,
"Addr": ":5700",
"JSONRPCEndpoint": "/api/",
Expand Down
4 changes: 2 additions & 2 deletions node_server/server_game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class ServerGame {
console.log(`>>>>>>> BEFORE LOAD WORLD ${world_guid} <<<<<<<`);
const p = performance.now();
const worldTitlePromise = this.db.getWorld(world_guid);
const conn = await SQLiteServerConnector.connect(`../world/${world_guid}/world.sqlite`);
const conn = await SQLiteServerConnector.connect(`../storage/world/${world_guid}/world.sqlite`);
const world = new ServerWorld(BLOCK);
const db_world = await DBWorld.openDB(conn, world);
const title = (await worldTitlePromise).title;
Expand All @@ -129,7 +129,7 @@ export class ServerGame {

// Start websocket server
async start(config) {
const conn = await SQLiteServerConnector.connect('./game.sqlite3');
const conn = await SQLiteServerConnector.connect('../storage/game.sqlite3');
await DBGame.openDB(conn).then((db) => {
this.db = db;
(global as any).Log = new GameLog(this.db);
Expand Down