Skip to content

Commit

Permalink
Merge pull request #388 from lionelyoung/feat/docker-compose
Browse files Browse the repository at this point in the history
Add docker-compose alternative and allow websocket host override
  • Loading branch information
Seifert69 authored Sep 23, 2024
2 parents db858d1 + 92c70b4 commit ac578af
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,59 @@ See 'docker run --help'.
32:DOCKER_CONTENT_TRUST=1
[user@localhost]$ DOCKER_CONTENT_TRUST=0 docker run -d -p 4280:4280 dikumud3
```

## Docker Compose

Alternative to docker, you may use docker-compose.

1. Build the image
```console
docker-compose build
```

2. Modify the docker-compose.yaml file to your needs, there are two variables you may set:
- WS_HOST: The host the websocket server will bind to. By default, it is set to localhost.
- WS_PORT: The port the websocket server will bind to. By default, it is set to 4280.

For example in `docker-compose.yaml`:
```diff
version: '3.8'

services:
dikumud3:
build:
context: .
dockerfile: Dockerfile
ports:
- - "4280:4280"
+ - "34280:4280"
- "80:80"
environment:
- - WS_HOST=localhost
- - WS_PORT=4280
+ - WS_HOST=ws.example.com
+ - WS_PORT=34280
volumes:
- ./vme/lib:/dikumud3/vme/lib
```

3. Modify the volume mounts to your needs. By default, it is set to the current directory for persisting the mud data.

4. Run the container
```console
docker-compose up
```
- Optionally, run it in detached mode with: `docker-compose up -d`

5. For development, you can rebuild the container when you make changes by running:
```console
docker-compose up -d --build
```

6. When finished, stop the container with:
```console
docker-compose down
```



16 changes: 16 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3.8'

services:
dikumud3:
build:
context: .
dockerfile: Dockerfile
ports:
- "4280:4280"
- "80:80"
environment:
- WS_HOST=localhost
- WS_PORT=4280
# Remove the volume mount below, if you do not want to persist the mud data.
volumes:
- ./vme/lib:/dikumud3/vme/lib
12 changes: 12 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ function signals()

trap signals INT TERM EXIT HUP


# Override the default values if the environment variables are set.
WS_HOST=${WS_HOST:-localhost}
WS_PORT=${WS_PORT:-4280}
if [ "$WS_HOST" != "localhost" ] || [ "$WS_PORT" != "4280" ] ; then
echo "Starting websocket server on ws://${WS_HOST}:${WS_PORT}/echo"
DOCKER_CLIENT_FPATH="/dikumud3/vme/www/docker/index.html"
sed -i "s/encodeURI('localhost')/encodeURI('${WS_HOST}')/g" ${DOCKER_CLIENT_FPATH}
sed -i "s/encodeURI('4280')/encodeURI('${WS_PORT}')/g" ${DOCKER_CLIENT_FPATH}
fi

# Start services.
service nginx restart
cd /dikumud3/vme/bin
rm -f vme.log mplex.log
Expand Down

0 comments on commit ac578af

Please sign in to comment.