Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A handful of fixes/tweaks #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ ARG BLUEMAP_VERSION=3.20
USER root

# Install dependencies
RUN apk add --no-cache curl unzip
RUN apk add --no-cache curl php83-pdo php83-pdo_mysql unzip

# Install useful tools
RUN apk add --no-cache bind-tools iputils vim

# Download and extract BlueMap.jar to temporary directory
RUN tmpdir=$(mktemp -d) && \
Expand All @@ -21,13 +24,13 @@ RUN tmpdir=$(mktemp -d) && \
rm -rf "${tmpdir}"

# Patch sql.php to use database credentials from environment variables
RUN sed -i "s/\$driver = .*/$driver = getenv('DB_DRIVER') ?: 'mysql';/" /var/www/html/sql.php && \
sed -i "s/\$hostname = .*/$hostname = getenv('DB_HOST') ?: '127.0.0.1';/" /var/www/html/sql.php && \
sed -i "s/\$port = .*/$port = getenv('DB_PORT') ?: 3306;/" /var/www/html/sql.php && \
sed -i "s/\$username = .*/$username = getenv('DB_USER') ?: 'root';/" /var/www/html/sql.php && \
sed -i "s/\$password = .*/$password = getenv('DB_PASSWORD') ?: '';/" /var/www/html/sql.php && \
sed -i "s/\$database = .*/$database = getenv('DB_NAME') ?: 'bluemap';/" /var/www/html/sql.php && \
sed -i "s/\$hiresCompression = .*/$hiresCompression = getenv('HIRES_COMPRESSION') ?: 'gzip';/" /var/www/html/sql.php
RUN sed -i "s/\$driver = .*/\$driver = getenv('DB_DRIVER') ?: 'mysql';/" /var/www/html/sql.php && \
sed -i "s/\$hostname = .*/\$hostname = getenv('DB_HOST') ?: '127.0.0.1';/" /var/www/html/sql.php && \
sed -i "s/\$port = .*/\$port = getenv('DB_PORT') ?: 3306;/" /var/www/html/sql.php && \
sed -i "s/\$username = .*/\$username = getenv('DB_USER') ?: 'root';/" /var/www/html/sql.php && \
sed -i "s/\$password = .*/\$password = getenv('DB_PASSWORD') ?: '';/" /var/www/html/sql.php && \
sed -i "s/\$database = .*/\$database = getenv('DB_NAME') ?: 'bluemap';/" /var/www/html/sql.php && \
sed -i "s/\$hiresCompression = .*/\$hiresCompression = getenv('HIRES_COMPRESSION') ?: 'gzip';/" /var/www/html/sql.php

# Copy nginx configuration
COPY config/nginx.conf /etc/nginx/nginx.conf
Expand Down
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ services:
depends_on:
- mariadb
environment:
MYSQL_HOST: mariadb
MYSQL_PORT: '3306'
MYSQL_USER: bluemap
MYSQL_PASSWORD: thisisaverysecurepassword
MYSQL_DATABASE: bluemap
DB_DRIVER: mariadb
DB_HOST: mariadb
DB_PORT: '3306'
DB_USER: bluemap
DB_PASSWORD: thisisaverysecurepassword
DB_NAME: bluemap
volumes:
- ./data/settings.json:/var/www/html/settings.json

Expand All @@ -43,28 +44,30 @@ You can also deploy this image using the following command:
docker run -d \
--name bluemap \
-p 8100:80/tcp \
-e MYSQL_HOST=mariadb \
-e MYSQL_PORT=3306 \
-e MYSQL_USER=bluemap \
-e MYSQL_PASSWORD=thisisaverysecurepassword \
-e MYSQL_DATABASE=bluemap \
-e DB_DRIVER=mariadb \
-e DB_HOST=mariadb \
-e DB_PORT=3306 \
-e DB_USER=bluemap \
-e DB_PASSWORD=thisisaverysecurepassword \
-e DB_NAME=bluemap \
-v ./data/settings.json:/var/www/html/settings.json \
divadsn/bluemap-nginx:latest
```

Note that in both cases, you need to create a `settings.json` file in the `./data` directory. You can also find this file in the BlueMap webroot directory.

## Environment variables
| Variable | Description | Default value |
| --- | --- | --- |
| `MYSQL_HOST` | Hostname of the MySQL server | `127.0.0.1` |
| `MYSQL_PORT` | Port of the MySQL server | `3306` |
| `MYSQL_USER` | Username of the MySQL user | `root` |
| `MYSQL_PASSWORD` | Password of the MySQL user | `""` |
| `MYSQL_DATABASE` | Name of the MySQL database | `bluemap` |
| Variable | Description | Default value |
|---------------|---------------------------------|---------------|
| `DB_DRIVER` | Type of database | `mysql` |
| `DB_HOST` | Hostname of the database server | `127.0.0.1` |
| `DB_PORT` | Port of the database server | `3306` |
| `DB_USER` | Username of the database user | `root` |
| `DB_PASSWORD` | Password of the database user | `""` |
| `DB_NAME` | Name of the database database | `bluemap` |

## Limitations
- This image does not support HTTPS out of the box. You need to modify the Nginx `default.conf` in order to enable HTTPS or use a reverse proxy.
- You need to enable `write-markers-interval` and `write-players-interval` in BlueMap in order for live data to be written to the database.
- You need to enable `write-markers-interval` and `write-players-interval` in BlueMap in order for live data to be written to the database. This will incur a lot of writes to your database, however.

You can also modify the `default.conf` to [proxy live data requests](https://bluemap.bluecolored.de/wiki/webserver/ExternalWebserversSQL.html) to the BlueMap integrated webserver.
You can also modify the `default.conf` to [proxy live data requests](https://bluemap.bluecolored.de/wiki/webserver/ExternalWebserversSQL.html) to the BlueMap integrated webserver. This is the recommended method for external services to access live player locations.
4 changes: 2 additions & 2 deletions config/conf.d/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ server {
server_name _;

root /var/www/html;
index index.php index.html;
index index.html index.php;

# First attempt to serve request as file, then as directory, then fall back to mysql.php
location / {
try_files $uri $uri/ /mysql.php;
try_files $uri $uri/ /sql.php;
}

# Pass the PHP scripts to PHP-FPM listening on php-fpm.sock
Expand Down
11 changes: 6 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ services:
depends_on:
- mariadb
environment:
MYSQL_HOST: mariadb
MYSQL_PORT: '3306'
MYSQL_USER: bluemap
MYSQL_PASSWORD: thisisaverysecurepassword
MYSQL_DATABASE: bluemap
DB_DRIVER: mariadb
DB_HOST: mariadb
DB_PORT: '3306'
DB_USER: bluemap
DB_PASSWORD: thisisaverysecurepassword
DB_DATABASE: bluemap
volumes:
- ./data/settings.json:/var/www/html/settings.json

Expand Down