Skip to content

Commit

Permalink
Add Docker configuration, update README with instructions. (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecliptik authored and SupremeMortal committed Oct 8, 2018
1 parent 3b5b433 commit ba700c1
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Jenkinsfile
circle.yml
README.md
data
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ resource_packs
resource_packs/*
creativeitems.json
recipes.json

#Nukkit data dir
data
data/*
51 changes: 51 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This Dockerfile uses Docker Multi-Stage Builds
# See https://docs.docker.com/engine/userguide/eng-image/multistage-build/
# Requires Docker v17.05

# Use OpenJDK JDK image for intermiediate build
FROM openjdk:8-jdk-slim AS build

# Install packages required for build
RUN apt update && apt install -y \
build-essential \
git \
maven

# Build from source and create artifact
WORKDIR /src
COPY ./ /src
RUN git submodule update --init
RUN mvn clean package

# Use OpenJDK JRE image for runtime
FROM openjdk:8-jre-slim AS run
LABEL maintainer="Micheal Waltz <dockerfiles@ecliptik.com>"

# Copy artifact from build image
COPY --from=build /src/target/nukkit-1.0-SNAPSHOT.jar /app/nukkit.jar

# Create minecraft user
RUN useradd --user-group \
--no-create-home \
--home-dir /data \
--shell /usr/sbin/nologin \
minecraft

# Volumes
VOLUME /data /home/minecraft

# Ports
EXPOSE 19132

# Make app owned by minecraft user
RUN chown -R minecraft:minecraft /app

# User and group to run as
USER minecraft:minecraft

# Set runtime workdir
WORKDIR /data

# Run app
ENTRYPOINT ["java"]
CMD [ "-jar", "/app/nukkit.jar" ]
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ Plugin API
-------------
Information on Nukkit's API can be found at the [wiki](https://nukkitx.com/wiki/nukkit/).

Docker
-------------

Running Nukkit in [Docker](https://www.docker.com/) (17.05+ or higher).

Build image from source,

```
docker build -t nukkit .
```

Run once to generate the `/data` volume, default settings, and choose language,

```
docker run -it --rm -p 19132:19132 nukkit
```

Use [docker-compose](https://docs.docker.com/compose/overview/) to start server on port `19132` and with `./data` volume,

```
docker-compose up -d
```

Contributing
------------
Please read the [CONTRIBUTING](.github/CONTRIBUTING.md) guide before submitting any issue. Issues with insufficient information or in the wrong format will be closed and will not be reviewed.
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3'
services:
nukkit:
build: ./
ports:
- "19132:19132"
- "19132:19132/udp"
volumes:
- ./data:/data
stdin_open: true
tty: true

0 comments on commit ba700c1

Please sign in to comment.