Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bleeding' into v1.4/feature/iron…
Browse files Browse the repository at this point in the history
…-golem
  • Loading branch information
joserobjr committed Feb 13, 2021
2 parents 3a6a654 + 439e94e commit 9ad96eb
Show file tree
Hide file tree
Showing 117 changed files with 2,016 additions and 414 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: powernukkit # Replace with a single Patreon username
open_collective: powernukkit # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
35 changes: 35 additions & 0 deletions .github/workflows/notify-sentry-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Sentry release

on:
push:
branches:
- bleeding
- bleeding-*
- master

jobs:
sentry-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
submodules: true
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Get version
run: |
SHA=$(echo $GITHUB_SHA | cut -c1-7)
PN_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)-git-$SHA
echo "Version: $PN_VERSION"
echo "PN_VERSION=$PN_VERSION-git" >> $GITHUB_ENV
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
environment: production
version: ${{ env.PN_VERSION }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,6 @@ data/*
/.idea/codeStyles/*
!/.idea/codeStyles/codeStyleConfig.xml
!/.idea/codeStyles/Project.xml

# a file that can be used for your helm chart values
/helm-values.local.yaml
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ This changelog is still being worked on.
- [#902] NetherPortal block can't be destroyed by liquid flow
- [#902] Lava doesn't turn concrete powder into concrete

### Added
- [#917] Adds automatic bug reports using Sentry, can be opted out in `server.properties`

## 1.3.2.0-PN-ALPHA.3 - 2020-12-12

### Fixes
Expand Down Expand Up @@ -671,3 +674,4 @@ Fixes several anvil issues.
[#778]: https://github.com/PowerNukkit/PowerNukkit/issues/778
[#882]: https://github.com/PowerNukkit/PowerNukkit/issues/882
[#902]: https://github.com/PowerNukkit/PowerNukkit/issues/902
[#917]: https://github.com/PowerNukkit/PowerNukkit/issues/917
33 changes: 33 additions & 0 deletions Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM arm64v8/openjdk:8-jdk-slim AS build
WORKDIR /usr/local/src/nukkit
COPY src /usr/local/src/nukkit/src
COPY mvn* pom.xml /usr/local/src/nukkit/
COPY .git /usr/local/src/nukkit/.git
COPY .mvn /usr/local/src/nukkit/.mvn
COPY .gitmodules /usr/local/src/nukkit/.gitmodules
RUN apt-get -y update && \
apt-get install -y build-essential git maven && \
git submodule update --init && \
mvn clean package

FROM arm64v8/openjdk:8-jre-slim AS run
LABEL maintainer="Chris Fordham <chris@fordham.id.au>"
COPY --from=build /usr/local/src/nukkit/target/nukkit-1.0-SNAPSHOT.jar /opt/nukkit/nukkit.jar
COPY nukkit.yml.default /etc/opt/nukkit/nukkit.yml
RUN useradd --user-group \
--no-create-home \
--home-dir /var/opt/nukkit \
--shell /usr/sbin/nologin \
minecraft && \
mkdir -p /var/opt/nukkit && \
chown -R minecraft /opt/nukkit /var/opt/nukkit /etc/opt/nukkit/nukkit.yml && \
ln -sfv /etc/opt/nukkit/nukkit.yml /var/opt/nukkit/nukkit.yml && \
apt-get -y update && \
apt-get -y install lsof && \
rm -rf /var/lib/apt/lists/*
USER minecraft
VOLUME /etc/opt/nukkit /var/opt/nukkit /opt/nukkit
EXPOSE 19132
WORKDIR /var/opt/nukkit
ENTRYPOINT ["java"]
CMD [ "-jar", "/opt/nukkit/nukkit.jar" ]
85 changes: 85 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
DOCKER_REGISTRY = index.docker.io
IMAGE_NAME = nukkit
IMAGE_VERSION = latest
IMAGE_ORG = flaccid
IMAGE_TAG = $(DOCKER_REGISTRY)/$(IMAGE_ORG)/$(IMAGE_NAME):$(IMAGE_VERSION)
export DOCKER_BUILDKIT = 1

WORKING_DIR := $(shell pwd)

.DEFAULT_GOAL := docker-build

.PHONY: build run

# TODO: finish
#build:: ## builds nukkit

# TODO: finish
#run:: ## runs the binary

docker-release:: docker-build docker-push ## builds and pushes the docker image to the registry
docker-release-arm64:: docker-build-arm64 docker-push-arm64 ## builds and pushes the arm64 docker image to the registry

docker-push:: ## pushes the docker image to the registry
@docker push $(IMAGE_TAG)

docker-push-arm64:: ## pushes the arm64 docker image to the registry
@docker push $(DOCKER_REGISTRY)/$(IMAGE_ORG)/$(IMAGE_NAME):arm64

docker-build:: ## builds the docker image locally
@echo http_proxy=$(HTTP_PROXY) http_proxy=$(HTTPS_PROXY)
@echo building $(IMAGE_TAG)
@docker build --pull \
--build-arg=http_proxy=$(HTTP_PROXY) \
--build-arg=https_proxy=$(HTTPS_PROXY) \
-t $(IMAGE_TAG) $(WORKING_DIR)

docker-build-arm64:: ## builds the arm64 docker image locally
@echo http_proxy=$(HTTP_PROXY) http_proxy=$(HTTPS_PROXY)
@echo building $(IMAGE_TAG)
@docker build --pull \
--build-arg=http_proxy=$(HTTP_PROXY) \
--build-arg=https_proxy=$(HTTPS_PROXY) \
-f Dockerfile.arm64 \
-t $(DOCKER_REGISTRY)/$(IMAGE_ORG)/$(IMAGE_NAME):arm64 $(WORKING_DIR)

docker-run:: ## runs the docker image locally
@docker run \
-it \
-p 19132:19132 \
$(DOCKER_REGISTRY)/$(IMAGE_ORG)/$(IMAGE_NAME):$(IMAGE_VERSION)

helm-install:: ## installs using helm from chart in repo
@helm install --name nukkit ./charts/nukkit

helm-upgrade:: ## upgrades deployed helm release
@helm upgrade nukkit ./charts/nukkit

helm-purge:: ## deletes and purges deployed helm release
@helm delete --purge nukkit

helm-render:: ## prints out the rendered chart
@helm install --dry-run --debug charts/nukkit

helm-validate:: ## runs a lint on the helm chart
@helm lint charts/nukkit

install-ghr:: ## installs ghr
@cd /tmp
@wget https://github.com/tcnksm/ghr/releases/download/v0.12.2/ghr_v0.12.2_linux_amd64.tar.gz
@tar zxvf ghr_v0.12.2_linux_amd64.tar.gz
@sudo mv ghr_v0.12.2_linux_amd64/ghr /usr/local/bin/

# a help target including self-documenting targets (see the awk statement)
define HELP_TEXT
Usage: make [TARGET]... [MAKEVAR1=SOMETHING]...

Available targets:
endef
export HELP_TEXT
help: ## this help target
@cat .banner
@echo
@echo "$$HELP_TEXT"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / \
{printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ It has a few key advantages over other server software:
* Written in Java, Nukkit is faster and more stable.
* Having a friendly structure, it's easy to contribute to Nukkit's development and rewrite plugins from other platforms into Nukkit plugins.

Nukkit is **under improvement** yet, we welcome contributions.
Nukkit is **under improvement** yet, we welcome contributions.

**PowerNukkit** is a modified version of Nukkit that adds support to a huge amount of features like water-logging, all new blocks, more plugin events, offhand slot, bug fixes and many more.

Expand Down Expand Up @@ -138,6 +138,51 @@ Check the [docker-compose.yml](docker-compose.yml) file for more details.
* 1.1.1.1, 1.1.1, 1.1
* 1.1.1.0

Kubernetes & Helm
-------------

Validate the chart:

`helm lint charts/nukkit`

Dry run and print out rendered YAML:

`helm install --dry-run --debug nukkit charts/nukkit`

Install the chart:

`helm install nukkit charts/nukkit`

Or, with some different values:

```
helm install nukkit \
--set image.tag="arm64" \
--set service.type="LoadBalancer" \
charts/nukkit
```

Or, the same but with a custom values from a file:

```
helm install nukkit \
-f helm-values.local.yaml \
charts/nukkit
```

Upgrade the chart:

`helm upgrade nukkit charts/nukkit`

Testing after deployment:

`helm test nukkit`

Completely remove the chart:

`helm uninstall nukkit`


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.
Expand Down
23 changes: 23 additions & 0 deletions charts/nukkit/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions charts/nukkit/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: nukkit
description: A Helm chart for Nukkit
type: application
version: 0.1.0
appVersion: 0.1.0
15 changes: 15 additions & 0 deletions charts/nukkit/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
1. Get the application URL by running these commands:
{{- if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "nukkit.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "nukkit.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "nukkit.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "nukkit.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }}
63 changes: 63 additions & 0 deletions charts/nukkit/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "nukkit.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "nukkit.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "nukkit.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "nukkit.labels" -}}
helm.sh/chart: {{ include "nukkit.chart" . }}
{{ include "nukkit.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "nukkit.selectorLabels" -}}
app.kubernetes.io/name: {{ include "nukkit.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "nukkit.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "nukkit.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
14 changes: 14 additions & 0 deletions charts/nukkit/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "nukkit.name" . }}-conf
labels:
app: {{ template "nukkit.name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
data:
nukkit.yml: |-
{{- if .Values.config }}
{{ .Values.config | indent 4 }}
{{- end -}}
Loading

0 comments on commit 9ad96eb

Please sign in to comment.