Skip to content

Commit

Permalink
make main docker build 5x smaller, add only proxy dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Jul 13, 2024
1 parent 698779f commit 512bc09
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 15 deletions.
32 changes: 21 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
FROM node:18-alpine
# ---- Build Stage ----
FROM node:18-alpine AS build
# Without git installing the npm packages fails
RUN apk add git
RUN mkdir /app
RUN apk add --no-cache git python3 make g++ cairo-dev pango-dev jpeg-dev giflib-dev librsvg-dev
WORKDIR /app
COPY . /app
# install python and other dependencies
RUN apk add python3 make g++ cairo-dev pango-dev jpeg-dev giflib-dev librsvg-dev
# install pnpm
RUN npm i -g [email protected]
RUN pnpm install
# only for prod
RUN pnpm run build
# ---
EXPOSE 8080
# uncomment for development

# TODO for development
# EXPOSE 9090
# VOLUME /app/src
# VOLUME /app/prismarine-viewer
# ENTRYPOINT ["pnpm", "run", "run-all"]

# only for prod
ENTRYPOINT ["npm", "run", "prod-start"]
RUN pnpm run build

# ---- Run Stage ----
FROM node:18-alpine
RUN apk add git
WORKDIR /app
# Copy build artifacts from the build stage
COPY --from=build /app/dist /app/dist
COPY server.js /app/server.js
# Install express
RUN npm i -g [email protected]
RUN npm init -yp
RUN pnpm i express github:zardoy/prismarinejs-net-browserify compression cors
EXPOSE 8080
ENTRYPOINT ["node", "server.js"]
11 changes: 11 additions & 0 deletions Dockerfile.proxy
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ---- Run Stage ----
FROM node:18-alpine
RUN apk add git
WORKDIR /app
COPY server.js /app/server.js
# Install server dependencies
RUN npm i -g [email protected]
RUN npm init -yp
RUN pnpm i express github:zardoy/prismarinejs-net-browserify compression cors
EXPOSE 8080
ENTRYPOINT ["node", "server.js"]
15 changes: 11 additions & 4 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ See the [Mineflayer](https://github.com/PrismarineJS/mineflayer) repo for the li
There is a builtin proxy, but you can also host your one! Just clone the repo, run `pnpm i` (following CONTRIBUTING.MD) and run `pnpm prod-start`, then you can specify `http://localhost:8080` in the proxy field.
MS account authentication will be supported soon.

### Docker Files

- [Main Dockerfile](./Dockerfile) - for production build & offline/private usage. Includes full web-app + proxy server for connecting to Minecraft servers.
- [Proxy Dockerfile](./Dockerfile.proxy) - for proxy server only - that one you would be able to specify in the proxy field on the client (`docker build . -f Dockerfile.proxy -t minecraft-web-proxy`)

In case of using docker, you don't have to follow preparation steps from CONTRIBUTING.MD, like installing Node.js, pnpm, etc.

### Rendering

#### Three.js Renderer
Expand All @@ -55,10 +62,6 @@ MS account authentication will be supported soon.

<!-- TODO proxy server communication graph -->

### Things that are not planned yet

- Mods, plugins (basically JARs) support, shaders - since they all are related to specific game pipelines

### Advanced Settings

There are many many settings, that are not exposed in the UI yet. You can find or change them by opening the browser console and typing `options`. You can also change them by typing `options.<setting_name> = <value>`.
Expand Down Expand Up @@ -131,6 +134,10 @@ Press `Y` to set query parameters to url of your current game state.
- [Peer.js](https://peerjs.com/) - P2P networking (when you open to wan)
- [Three.js](https://threejs.org/) - Helping in 3D rendering

### Things that are not planned yet

- Mods, plugins (basically JARs) support, shaders - since they all are related to specific game pipelines

### Alternatives

- [https://github.com/ClassiCube/ClassiCube](ClassiCube - Better C# Rewrite) [DEMO](https://www.classicube.net/server/play/?warned=true)

0 comments on commit 512bc09

Please sign in to comment.