Merge branch 'docker-zedi' into 'dev'

Add docker functionality and basic documentation

See merge request crafty-controller/crafty-commander!65
This commit is contained in:
computergeek125 2021-09-01 01:42:11 +00:00
commit 95aa228a92
9 changed files with 89 additions and 1 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
docker/

2
.gitignore vendored
View File

@ -27,3 +27,5 @@ default.json
.DS_STORE
app/config/
docker/*
!docker/docker-compose.yml

31
Dockerfile Normal file
View File

@ -0,0 +1,31 @@
FROM python:alpine
LABEL maintainer="Dockerfile created by Zedifus <https://gitlab.com/zedifus>"
# Install Packages, Build Dependencies & Garbage Collect & Harden
# (Testing repo is needed because jre16 is new)
COPY requirements.txt /commander/requirements.txt
RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing openssl-dev rust cargo gcc musl-dev libffi-dev make openjdk8-jre-base openjdk11-jre-headless openjdk16-jre-headless mariadb-dev \
&& pip3 install --no-cache-dir -r /commander/requirements.txt \
&& apk del --no-cache gcc musl-dev libffi-dev make rust cargo openssl-dev \
&& rm -rf /sbin/apk \
&& rm -rf /etc/apk \
&& rm -rf /lib/apk \
&& rm -rf /usr/share/apk \
&& rm -rf /var/lib/apk
# Copy Source & copy default config from image
COPY ./ /commander
WORKDIR /commander
RUN mv ./app/config ./app/config_original \
&& mv ./app/config_original/default.json.example ./app/config_original/default.json
# Expose Web Interface port & Server port range
EXPOSE 8000
EXPOSE 8443
EXPOSE 19132
EXPOSE 25500-25600
# Start Crafty Commander through wrapper
ENTRYPOINT ["/commander/docker_launcher.sh"]
CMD ["-v", "-d", "-i"]

View File

@ -15,4 +15,32 @@ Project Homepage - https://craftycontrol.com
Discord Server - https://discord.gg/9VJPhCE
Git Repository - https://gitlab.com/crafty-controller/crafty-web
Git Repository - https://gitlab.com/crafty-controller/crafty-web
## Basic Docker Usage
A Docker image pipeline is still to be implimented but for example you can expect the image to be located: `crafty/cc-dashboard` and you would change the image in the below `docker run` to this image.
If you are building from the `docker-compose` you can find it in `./docker/docker-compose.yml` just `cd` to the docker directory and `docker-compose up -d`
If you'd rather not use `docker-compose` you can use the following `docker run`:
```
$ docker build . -t cc-dashboard
# REMEMBER, Build your image!
$ docker run \
--name crafty_commander \
-p 8000:8000 \
-p 8443:8443 \
-p 8123:8123 \
-p 19132:19132/udp \
-p 24000-25600:24000-25600 \
-v "/$(pwd)/docker/backups:/commander/backups" \
-v "/$(pwd)/docker/logs:/commander/logs" \
-v "/$(pwd)/docker/servers:/commander/servers" \
-v "/$(pwd)/docker/config:/commander/app/config" \
cc-dashboard
```
A fresh build will take several minutes depending on your system, but will be rapid there after.
If you have a config folder already from previous local installation or docker setup, the image should mount this volume, if none is present then it will populate its own config folder for you.

0
docker/backups/.gitkeep Normal file
View File

17
docker/docker-compose.yml Normal file
View File

@ -0,0 +1,17 @@
version: '3'
services:
cc-dashboard:
container_name: crafty_commander
build: ..
ports:
- "8000:8000" # HTTP
- "8443:8443" # HTTPS
- "8123:8123" # DYNMAP
- "19132:19132/udp" # BEDROCK
- "24000-25600:24000-25600" # MC SERV PORT RANGE
volumes:
- ./backups:/commander/backups
- ./logs:/commander/logs
- ./servers:/commander/servers
- ./config:/commander/app/config

0
docker/logs/.gitkeep Normal file
View File

0
docker/servers/.gitkeep Normal file
View File

9
docker_launcher.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/sh
# Check if config exists from existing installation (venv or previous docker launch)
if [ ! "$(ls -A ./app/config)" ]; then
mkdir ./app/config/
cp -r ./app/config_original/* ./app/config/
fi
exec python3 main.py $@