Skip to content

Commit

Permalink
remove adminer by default, expose UDP ports
Browse files Browse the repository at this point in the history
  • Loading branch information
Mick Vermeulen authored and Mick Vermeulen committed Sep 20, 2020
1 parent 5e347b0 commit 0273cec
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
data/*
.env
.DS_Store
.DS_Store
cert.pfx
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ This can also be done by creating a new folder named `data` manually, without th
docker-compose up -d
```

This runs Uchu in the background along with Postgres, Redis and Adminer. You can attach to the `Uchu.Master` shell using:
This runs Uchu in the background along with Postgres and Redis. You can attach to the `Uchu.Master` shell using:

```bash
docker attach uchudocker_uchu_1
```

This allows you to input shell commands like `/adduser <username>`. You can exit the shell using `Ctrl+C`.
This allows you to input shell commands like `/adduser <username>`. You can exit the shell using `Ctrl+P + Ctrl+Q` (`Ctrl+C` closes the container, not just your attach session).

## Closing

Expand All @@ -72,10 +72,8 @@ When applying any changes to the `.env` file after your initial `docker-compose

## Adminer

Uchu Docker also automatically runs [Adminer](https://www.adminer.org), which allows you to easily modify the Uchu database in a user friendly way. After running Uchu Docker you can access Adminer through your browser at 0.0.0.0:8080. Select the `PostgreSQL` database type, set the server to `db` and enter the credentials found in the `.env` file to login. More info on how to use Adminer can be found on their website.
Uchu Docker can also run [Adminer](https://www.adminer.org), which allows you to easily modify the Uchu database in a user friendly way. You can activate this by uncommenting the lines after `# Uncomment this if you wish to use adminer` in `docker-compose.yaml`, note that you probably don't need this by default but can assist with more user friendly database management. Select the `PostgreSQL` database type, set the server to `db` and enter the credentials found in the `.env` file to login. More info on how to use Adminer can be found on their website.

## Hosting (Advanced)

This Docker setup can be used to host Uchu as long as all ports are exposed (see the .env.sample file for all ports that need to be exposed). Do note that hosting Uchu on anything other than `localhost` requires a valid PFX certificate from a trusted CA like Let's Encrypt and therefore also a valid domain name. You *cannot* use a self signed certificate even if you first generate your own root certificate, as the TcpUdp mod does not look at the OS certificate store for valid root certificates. You can specify the path to your PFX certificate using the `$CERTIFICATE` environment variable.

When hosting Uchu on a private network, for example in a LAN scenario, it might be a bit cumbersome to get a valid certficate and a domain. An alternative solution would be to run Uchu on a host device, find it's private network IP using `ipconfig` or `ifconfig` and port-forwarding all Uchu ports on `localhost` on client machines to the private network IP and the respective ports. This way clients on the private network can connect with Uchu through `localhost` and therefore no certificate is required. To ensure this works port-forward all the ports from the `.env` file on all client machines to the host machine.
This Docker setup can be used to host Uchu as long as all ports are exposed (see the .env.sample file for all ports that need to be exposed). Do note that hosting Uchu on anything other than `localhost` requires a valid PFX certificate from a trusted CA like Let's Encrypt and therefore also a valid domain name. You *cannot* use a self signed certificate even if you first generate your own root certificate, as the TcpUdp mod does not look at the OS certificate store for valid root certificates. You can add a certificate to the container by adding it to this directory under the name `cert.pfx`. Finally set the `HOSTNAME` variable in the `.env` file to the hostname for the certificate.
4 changes: 2 additions & 2 deletions Uchu.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine
COPY Uchu config.default.xml .env ./
COPY Uchu config.default.xml .env cert.pfx* ./

RUN apk update && apk add --no-cache gettext && apk add --no-cache openssl
RUN apk update && apk add --no-cache gettext && apk add --no-cache curl

RUN set -o allexport && source .env && set +o allexport && envsubst < config.default.xml > config.xml
RUN dotnet build
Expand Down
4 changes: 2 additions & 2 deletions config.default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<GameResourceFolder>/res</GameResourceFolder>
</ResourcesConfiguration>
<Networking>
<Certificate>$CERTIFICATE</Certificate>
<Hostname>localhost</Hostname>
<Certificate>cert.pfx</Certificate>
<Hostname>$HOSTNAME</Hostname>
<CharacterPort>2002</CharacterPort>
<HostAuthentication>true</HostAuthentication>
<HostCharacter>true</HostCharacter>
Expand Down
24 changes: 16 additions & 8 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ services:
restart: always
volumes:
- ${DATA_FOLDER}:/var/lib/postgresql/data
adminer:
image: adminer
restart: always
depends_on:
- db
ports:
- ${ADMINER_PORT}:8080
# Uncomment this if you wish to use adminer
# adminer:
# image: adminer
# restart: always
# depends_on:
# - db
# ports:
# - ${ADMINER_PORT}:8080
redis:
image: redis:6.0.8-alpine
env_file:
Expand All @@ -40,5 +41,12 @@ services:
- ${UCHU_WORLD_PORT_RANGE}:20000-20100
- ${UCHU_SERVER_PORT}:21836
- ${UCHU_AUTH_PORT}:40000
- ${UCHU_HANDSHAKE_PORT}:1001/udp
- ${UCHU_CHARACTER_PORT}:2002/udp
- ${UCHU_CHAT_PORT}:2004/udp
- ${UCHU_API_PORT_RANGE}:10000-10100/udp
- ${UCHU_WORLD_PORT_RANGE}:20000-20100/udp
- ${UCHU_SERVER_PORT}:21836/udp
- ${UCHU_AUTH_PORT}:40000/udp
tty: true
stdin_open: true
stdin_open: true
36 changes: 36 additions & 0 deletions uchu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# WIP Install script

if ! [ -f ".env" ]; then
echo "Environment file does not exist yet, setting it up for you."
echo "Please specify a valid absolute path to the /res folder inside your LU client (make sure to escape spaces):"

while ! [ -d "$GAME_FOLDER" ]; do
read GAME_FOLDER
if ! [ -d "$GAME_FOLDER" ]; then
echo "$GAME_FOLDER is not a valid directory, retry:"
fi
done

if ! [ -d "$GAME_FOLDER/../mods" ]; then
echo "It seems like you don't have the TcpUdp mod installed in your client, you won't be able to connect with Uchu until you install this mod. More information can be found in the README."
else
echo "$GAME_FOLDER seems like a valid location, continuing."
fi

sed "s|/res|$GAME_FOLDER|g" .env.sample > .env

echo "Finished setting up environment file."
fi

if ! [ -d "data" ]; then
echo "Database folder not found, adding \"data\" folder."
mkdir data
fi

if [ -x "$(command -v docker)" ] && [ -x "$(command -v docker-compose)" ]; then
echo "Starting Uchu"
docker-compose up --build
else
echo "You don't have docker or docker-compose installed, refer to the README for installation instructions."
fi

0 comments on commit 0273cec

Please sign in to comment.