Skip to content

Commit

Permalink
Merge branch 'feat/docker-simplify' into feat/re-enable-mud-tls
Browse files Browse the repository at this point in the history
  • Loading branch information
myonara authored Aug 12, 2024
2 parents fc34841 + f26b99c commit 197d1bb
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 53 deletions.
36 changes: 31 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
FROM node:20.12.2
FROM node:20.12.2 AS ng-build-stage

# docker build --progress=plain -f Dockerfile -t myonara/webmud3:latest .
# docker build --no-cache --progress=plain -f Dockerfile -t myonara/webmud3:latest .

# Setze das Arbeitsverzeichnis im Container
WORKDIR /usr/src/app
WORKDIR /webmud3

# Kompilat kopieren
COPY backend/dist ./
COPY ./ ./

# Installiere die Abhängigkeiten
RUN npm install --no-package-lock --include=prod
RUN apt-get update -y \
&& apt upgrade -y \
&& npm install -g npm@10.8.2
RUN npm install
RUN npm run build

# get fresh deployment
FROM node:20.12.2 AS webmud3

# Setze das Arbeitsverzeichnis im Container
WORKDIR /webmud3

# copy from build stage
COPY --from=ng-build-stage /webmud3/backend/dist/ /webmud3/

RUN npm install -g npm@10.8.2 && npm install

# Setze die Umgebungsvariable PORT
ENV PORT=5000
Expand All @@ -16,4 +34,12 @@ ENV PORT=5000
EXPOSE 5000

# Starte die Anwendung
CMD ["node", "main.js"]
# CMD ["node", "/webmud3/main.js"]

# for debugging:
ADD dockerfiles/.bashrc /root/

CMD ["/bin/bash"]

# docker run -it -p 5000:5000 --env-file dockerfiles/env-wm3local.list --name wm3test --hostname wm3test myonara/webmud3:latest
# docker run -it -p 2019:5000 --env-file dockerfiles/env-wm3testuni.list --name wm3test --hostname wm3test myonara/webmud3:latest
6 changes: 2 additions & 4 deletions backend/src/core/environment/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ export class Environment implements IEnvironment {

this.telnetPort = Number(getEnvironmentVariable('TELNET_PORT'));

this.telnetTLS =
getEnvironmentVariable('TELNET_TLS', false, 'false') === 'true';

this.socketRoot = String(getEnvironmentVariable('SOCKET_ROOT'));

this.charset = String(getEnvironmentVariable('CHARSET', false, 'utf8'));

Expand All @@ -50,6 +46,8 @@ export class Environment implements IEnvironment {

this.projectRoot = resolveModulePath('../../../main.js');

this.socketRoot = String(getEnvironmentVariable('SOCKET_ROOT',false,'/socket.io'));

logger.info('[Environment] initialized', this);
}

Expand Down
2 changes: 1 addition & 1 deletion backend/src/core/environment/types/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export interface IEnvironment {
readonly telnetHost: string;
readonly telnetPort: number;
readonly telnetTLS: boolean;

readonly projectRoot: string;
readonly socketRoot: string;

Expand Down
24 changes: 24 additions & 0 deletions dockerfiles/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# ~/.bashrc: executed by bash(1) for non-login shells.

# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
# umask 022

# You may uncomment the following lines if you want `ls' to be colorized:
export LS_OPTIONS='--color=auto'
# eval "$(dircolors)"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -lA'
#
# Some more alias to avoid making mistakes:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# start webmud3
alias startwm3='node /webmud3/main.js &'
# startmud
alias startmud='/usr/local/bin/driver_full.sh &'
# copy from mud to mud9
alias copy2mud9='cd /mud && tar cf - . | (cd /mud9 && tar xvf - )'
74 changes: 74 additions & 0 deletions dockerfiles/driver_full.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#! /bin/sh

# if [ ! -e /mud/lib/secure/master.c ]; then
# tar -zxf /mud/lib.tar.gz -C /mud/lib --no-same-owner
# fi

# Erstmal das Logfile linken (wird fuer den Fehlerbrowser gebraucht)
LOGFILE=log/sys/debug.`date +%s`
ln -sf $LOGFILE lib/UNItopia.debug.log

export LC_ALL=de_DE.UTF-8@sz
export PYTHONUNBUFFERED=1

# TELNET_CERT="`openssl x509 -in /UNItopia/mudadm/magyra/tls/keys/telnet.pem -noout -fingerprint -sha1 | sed -e 's/.*=//;'`"
# exec /usr/local/bin/ldmud --no-erq -m /mud/lib -M secure/master.c --python-script ../startup.pyz
# --define TELNET_CERT="\"$TELNET_CERT\"" \
# --define PORTAL_CERT='"00:CC:57:A3:12:39:95:5B:9B:EA:C6:28:69:1E:42:F8:5E:8E:9A:F3"' \
# --tls-keydirectory /UNItopia/mudadm/magyra/tls/keys \
# --tls-trustdirectory /UNItopia/mudadm/magyra/tls/trust \
# --tls-crldirectory /UNItopia/mudadm/magyra/tls/crl \
# [::ffff:172.17.0.2]:23 \
# [::ffff:172.17.0.2]:992 \
# [::ffff:172.17.0.2]:3333 \
# [2a00:1828:2000:161::2]:23 \
# [2a00:1828:2000:161::2]:992 \
# [2a00:1828:2000:161::2]:3333 \
# 3332 4444 5555 8080 \
# --define UNItopia \

exec /usr/local/bin/ldmud \
--define AUTO_COUNTOB \
--define UNION_TYPES \
--define MONSTER_SCHIESSEN_IM_HEARTBEAT \
--define MOVE_UMSTELLUNG \
--define AUX_PORT=33033 \
--mudlib /mud/lib \
--master /secure/master.c \
--hostname homemud \
--hostaddr 172.17.0.2 \
--no-erq \
--python-script ../python.pyz \
--eval-cost 1500000 \
--max-file 100000 \
--max-bytes 100000 \
--max-mapping-keys 10000 \
--max-array 10000 \
--cleanup-time 5400 \
--reset-time 2400 \
--hard-malloc-limit 4294967296 \
--min-malloc 268435456 \
--min-small-malloc 134217728 \
--reserve-user 8388608 \
--reserve-master 2097152 \
--reserve-system 4194304 \
--swap-file /mud/UNItopia.swp \
--swap-time -1 \
--swap-variables -1 \
--gcollect-outfd /mud/gcollect.out \
--pidfile /mud/UNItopia.pid \
--debug-file $LOGFILE \
--strict-euids \
--no-compat \
--udp 3335 \
[::ffff:172.17.0.2]:23 \
[::ffff:172.17.0.2]:992 \
[::ffff:172.17.0.2]:3333 \
[::ffff:127.0.0.1]:23 \
[::ffff:127.0.0.1]:992 \
[::ffff:127.0.0.1]:3333 \
[::1]:23 \
[::1]:992 \
[::1]:3333 \
33033 \
"$@"
9 changes: 9 additions & 0 deletions dockerfiles/env-wm3local.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# env file for webmud3 local
# docker run -d --env-file dockerfiles/env-wm3local.list -p 5000:5000 --name wm3local myonara/webmud3:local
NODE_ENV=development
HOST=wm3test
# TELNET_HOST=unitopia.de
# TELNET_PORT=9988
# TELNET_TLS=false
TELNET_HOST=localhost
TELNET_PORT=3333
8 changes: 8 additions & 0 deletions dockerfiles/env-wm3testuni.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# env file for webmud3 local
# docker run -d --env-file dockerfiles/env-wm3local.list -p 5000:5000 --name wm3local myonara/webmud3:local
NODE_ENV=development
HOST=wm3test
TELNET_HOST=unitopia.de
TELNET_PORT=9988
TELNET_TLS=true
SOCKET_ROOT=/mysocket-test.io
53 changes: 53 additions & 0 deletions dockerfiles/homemud_manual.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#
# docker build --progress=plain -f dockerfiles/homemud_manual.dockerfile -t homemud .
# docker build --no-cache --progress=plain -f dockerfiles/homemud_manual.dockerfile -t homemud .

# _T\armageddon.dockerfile
FROM debian:bookworm

RUN apt-get update

RUN apt-get install -y --no-install-recommends build-essential ca-certificates git bison autoconf autogen automake wget pkg-config libgcrypt20-dev libgnutls28-dev libsqlite3-dev python3-dev libxml2-dev zlib1g-dev libpcre3-dev libc-ares-dev python3-hunspell hunspell-de-de locales \
&& echo "de_DE.UTF-8 UTF-8" > /etc/locale.gen \
&& dpkg-reconfigure --frontend=noninteractive locales \
&& update-locale LANG=de_DE.UTF-8

RUN git clone -b unitopia https://github.com/amotzkau/ldmud.git \
&& cd ldmud/src \
&& ./autogen.sh \
&& settings/unitopia --prefix=/usr/local \
&& make install-driver \
&& cd ../.. \
&& rm -rf ldmud

RUN mkdir /mud && cd /mud && mkdir /mud/lib \
&& cd /mud && wget -O - https://www.unitopia.de/pub/UNItopia/mudlib.tar.gz | tar -zxf - \
&& wget -O - https://www.unitopia.de/pub/UNItopia/muddocs.tar.gz | tar -zxf - \
&& wget -O - https://www.unitopia.de/pub/UNItopia/python-support.tar.gz | tar -zxf -

RUN apt-get clean \
&& apt-mark manual libgnutls30 libsqlite3-0 libpython3.11 libxml2 libpcre3 \
&& apt-get remove --purge -y build-essential ca-certificates git bison autoconf autogen automake wget pkg-config libgcrypt20-dev libgnutls28-dev libsqlite3-dev python3-dev libxml2-dev zlib1g-dev libpcre3-dev \
&& apt-get autoremove -y
RUN apt-get install -y procps tf net-tools

RUN /mud/lib/doc/driver/setup_mudlib

RUN mkdir mud9

ENV LANG=de_DE.UTF-8
ENV LC_ALL=de_DE.UTF-8

ADD dockerfiles/driver_full.sh /usr/local/bin/
ADD dockerfiles/.bashrc /root

EXPOSE 23 992 3333 3335/udp

# CMD [ "/usr/local/bin/driver_full.sh" ]
CMD [ "/bin/bash" ]

# run docker /bash) to copy mfrom mud to mud9 once (tail /root/.bashrc => copy2mud9) Adapt local path if applicable!
# docker run -it -p 23:23 -p 3333:3333 --name homemud --hostname homemud -v C:/_M/mud9:/mud9 docker.io/library/homemud

# run docker (bash) with local volume (adapt local path if applicable)
# docker run -it -p 23:23 -p 3333:3333 --name homemud --hostname homemud -v C:/_M/mud9:/mud docker.io/library/homemud
43 changes: 0 additions & 43 deletions dockerfiles/ng_unitopia_test.dockerfile

This file was deleted.

0 comments on commit 197d1bb

Please sign in to comment.