diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..aa6a14242 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +name: Release + +on: + push: + tags: + - '*' + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: make + run: make + working-directory: ./ninjam/server + - name: target + run: mkdir target + working-directory: ./ninjam/server + - name: copy-ninjamsrv + run: cp ninjamsrv ./target/ + working-directory: ./ninjam/server + - name: copy-cfg + run: cp example.cfg ./target/config.cfg + working-directory: ./ninjam/server + - name: copy-licence + run: cp cclicense.txt ./target/cclicense.txt + working-directory: ./ninjam/server + - name: tar-gz + run: tar -czvf ninjam.tar.gz -C target . + working-directory: ./ninjam/server/ + - uses: actions/upload-artifact@v4 + with: + name: ninjamsrv + path: ./ninjam/server/target + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./ninjam/server/ninjam.tar.gz + asset_name: ninjam.tar.gz + asset_content_type: application/zip diff --git a/ninjam/server/Dockerfile b/ninjam/server/Dockerfile new file mode 100644 index 000000000..ed85718f1 --- /dev/null +++ b/ninjam/server/Dockerfile @@ -0,0 +1,13 @@ +FROM ubuntu:latest + +ENV PATH /usr/local/ninjam:$PATH +ARG TAG +ADD https://github.com/zeppelinux/ninjam/releases/download/${TAG}/ninjam.tar.gz /var/tmp/ + +RUN mkdir -p /var/tmp/ninjam && tar -xzf /var/tmp/ninjam.tar.gz -C /var/tmp/ninjam && rm /var/tmp/ninjam.tar.gz && mv /var/tmp/ninjam /usr/local/ +WORKDIR /usr/local/ninjam +# forward request and error logs to docker log collector +#RUN ln -sf /dev/stdout ./ninjamserver.log + +EXPOSE 2049 +ENTRYPOINT ["ninjamsrv", "config.cfg"] diff --git a/ninjam/server/example.cfg b/ninjam/server/example.cfg index 3c9894b42..296808e67 100644 --- a/ninjam/server/example.cfg +++ b/ninjam/server/example.cfg @@ -49,7 +49,7 @@ DefaultBPI 8 # write PID file (non-windows version only) # PIDFile ninjamserver.pid -# LogFile ninjamserver.log +LogFile ninjamserver.log # set keep-alive interval in seconds. should probably not bother diff --git a/ninjam/server/helm/Chart.yaml b/ninjam/server/helm/Chart.yaml new file mode 100755 index 000000000..e4f0eda51 --- /dev/null +++ b/ninjam/server/helm/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: ninjam-server +version: 0.1.0 diff --git a/ninjam/server/helm/templates/NOTES.txt b/ninjam/server/helm/templates/NOTES.txt new file mode 100755 index 000000000..e69de29bb diff --git a/ninjam/server/helm/templates/_helpers.tpl b/ninjam/server/helm/templates/_helpers.tpl new file mode 100755 index 000000000..783b5b1e4 --- /dev/null +++ b/ninjam/server/helm/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "ninjam-server.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 "ninjam-server.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 "ninjam-server.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/ninjam/server/helm/templates/config-map.yaml b/ninjam/server/helm/templates/config-map.yaml new file mode 100644 index 000000000..1277d03fa --- /dev/null +++ b/ninjam/server/helm/templates/config-map.yaml @@ -0,0 +1,72 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "ninjam-server.fullname" . }} + labels: + app: {{ template "ninjam-server.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +data: + config.cfg: | + # only one port line allowed (last one will be used) + # these are comments + Port 2049 + + # limit connections of normal users to 10 + MaxUsers 10 + + # limit normal users to 32 channels each, anonymous users to 2 + MaxChannels 32 2 + + ServerLicense cclicense.txt + + #anonymoususers yes or no, or multi (to allow multiple users of the same name from the same IP) + AnonymousUsers no + AnonymousUsersCanChat yes + AnonymousMaskIP yes # shows just the nn.nn.nn.x instead of full IP. + + + AllowHiddenUsers no # set to yes to allow people without channels to not appear in the user list + + + #ACL list lets you specify in order a list, first match is used + ACL 10.0.0.0/8 deny + ACL 192.168.0.0/16 reserve # reserve slots for local + ACL 0.0.0.0/0 allow # allow all + + + #user/password/permissions sets + User administrator myadminpass * # allow all functions + User booga anotherpass CBTKRM # allow chat, bpm/bpi, topic changing, and kicking, a reserved slot, and multiple logins + User myuser mypass # allow default functions (chat, no topic) + + # optional user/pass with simple status retrieving permissions (this also has the advantage of having the server do less work) + # StatusUserPass username password + + DefaultTopic "Welcome to NINJAM. Please play nicely." + DefaultBPM 120 + DefaultBPI 8 + + # two parameters: path to log to, and session length (in minutes). 0 for length means 30 seconds. + # if the first parameter (path) is empty, no logging is done + # SessionArchive . 15 + + + # these two require a full restart to update: + + # write PID file (non-windows version only) + # PIDFile ninjamserver.pid + + # LogFile ninjamserver.log + + + # set keep-alive interval in seconds. should probably not bother + # specifying this, the default is 3, which is adequate. + # SetKeepAlive 3 + + # voting system: + # SetVotingThreshold 50 # sets threshold to 50%. can be 1-100%, or >100 to disable + # SetVotingVoteTimeout 60 # sets timeout before votes are reset, in seconds + + # MOTDFile motd.txt # send this text as a privmsg to all users when they connect diff --git a/ninjam/server/helm/templates/deployment.yaml b/ninjam/server/helm/templates/deployment.yaml new file mode 100755 index 000000000..4b5db7059 --- /dev/null +++ b/ninjam/server/helm/templates/deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "ninjam-server.fullname" . }} + labels: + app: {{ template "ninjam-server.name" . }} + chart: {{ template "ninjam-server.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: 1 + selector: + matchLabels: + app: {{ template "ninjam-server.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "ninjam-server.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: config-volume + mountPath: /usr/local/ninjam/config.cfg + subPath: config.cfg + ports: + - name: ninjam-tcp + containerPort: 2049 + protocol: TCP + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} + volumes: + - name: config-volume + configMap: + name: {{ template "ninjam-server.fullname" . }} diff --git a/ninjam/server/helm/templates/service.yaml b/ninjam/server/helm/templates/service.yaml new file mode 100755 index 000000000..e4b71344c --- /dev/null +++ b/ninjam/server/helm/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "ninjam-server.fullname" . }} + labels: + app: {{ template "ninjam-server.name" . }} + chart: {{ template "ninjam-server.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: ninjam-tcp + protocol: TCP + name: open + selector: + app: {{ template "ninjam-server.fullname" . }} + release: {{ .Release.Name }} diff --git a/ninjam/server/helm/values.yaml b/ninjam/server/helm/values.yaml new file mode 100755 index 000000000..f4a8d2143 --- /dev/null +++ b/ninjam/server/helm/values.yaml @@ -0,0 +1,29 @@ +# Default values for teamcity. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +image: + repository: zeppelinux/ninjam-server + tag: v0.081 + pullPolicy: IfNotPresent + +service: + type: ClusterIP + port: 2049 + +# We usually recommend not to specify default resources and to leave this as a conscious +# choice for the user. This also increases chances charts run on environments with little +# resources, such as Minikube. If you do want to specify resources, uncomment the following +# lines, adjust them as necessary, and remove the curly braces after 'resources:'. +# limits: +# cpu: 800m +# memory: 968Mi +# requests: +# cpu: 600m +# memory: 968Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/ninjam/server/hooks/build b/ninjam/server/hooks/build new file mode 100644 index 000000000..9e4895682 --- /dev/null +++ b/ninjam/server/hooks/build @@ -0,0 +1,3 @@ +#!/bin/bash + +docker build --build-arg TAG=$DOCKER_TAG -t $IMAGE_NAME .