diff --git a/README.md b/README.md index 5546f59..1a8078c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,76 @@ # WorkAdventure XCE for Binary Kitchen +## Install Docker + +### Set up the repository +1. Update the `apt` package index and install packages to allow `apt` to use a repository over HTTPS: +``` + sudo apt-get update + sudo apt-get install \ + ca-certificates \ + curl \ + gnupg \ + lsb-release +``` + +2. Add Docker’s official GPG key: +`curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg` + +3. Use the following command to set up the stable repository. To add the nightly or test repository, add the word `nightly` or `test` (or both) after the word `stable` in the commands below. Learn about nightly and test channels. +``` + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \ + $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +``` + +### Install Docker Engine +This procedure works for Debian on `x86_64` / `amd64`, `armhf`, `arm64`, and Raspbian. +Update the `apt` package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version: +``` + sudo apt-get update + sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose +``` + +## Install other requirements +``` + sudo apt-get install nginx git +``` + +## Create user and directories +``` + sudo useradd -M workadventure + sudo adduser workadventure docker + sudo mkdir /opt/workadventure + sudo chown workadventure.workadventure /opt/workadventure +``` + +## Get workadventure source +Please make sure to edit the `.env` file to match your hostnames and Jitsi Servers before startup. + ``` cd /opt/workadventure sudo -u workadventure git clone --recurse-submodules https://git.binary-kitchen.de/noby/workadventure-xce.git source -cd source -docker-compose up ``` + +## Install and start systemd service +``` + sudo cp /opt/workadventure/source/dist/workadventure.service /etc/systemd/system + sudo systemctl daemon-reload + sudo systemctl enable workadventure + sudo systemctl start workadventure +``` + +## Install nginx vhost +``` + sudo cp /opt/workadventure/source/dist/vhost /etc/nginx/sites-available/workadventure + sudo ln -s /etc/nginx/sites-available/workadventure /etc/nginx/sites-enabled/workadventure +``` + +Make sure to edit the `/etc/nginx/sites-enabled/workadventure` file and replace all occurances of +`{{ workadventure_domain }}` with your own domain. You also have to make sure that you specify the +correct paths to your certificates. You need a certificate for all the subdomains shown in the config. + +If everything is done, restart nginx: +``` + sudo systemctl restart nginx +``` \ No newline at end of file diff --git a/dist/vhost b/dist/vhost new file mode 100644 index 0000000..64ae8de --- /dev/null +++ b/dist/vhost @@ -0,0 +1,76 @@ +server { + listen 80; + listen [::]:80; + + server_name {{ workadventure_domain }} play.{{ workadventure_domain }} pusher.{{ workadventure_domain }} uploader.{{ workadventure_domain }}; + + location /.well-known/acme-challenge { + default_type "text/plain"; + alias /var/www/acme-challenge; + } + + location / { + return 301 https://$host$request_uri; + } +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + + server_name {{ workadventure_domain }}; + + ssl_certificate_key /etc/nginx/ssl/{{ workadventure_domain }}.key; + ssl_certificate /etc/nginx/ssl/{{ workadventure_domain }}.crt; + + location / { + root /opt/workadventure/source/landing/dist; + } +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + + server_name play.{{ workadventure_domain }}; + + ssl_certificate_key /etc/nginx/ssl/{{ workadventure_domain }}.key; + ssl_certificate /etc/nginx/ssl/{{ workadventure_domain }}.crt; + + location / { + root /opt/workadventure/source/src/front/dist; + try_files $uri uri/ /index.html?$args; + } +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + + server_name pusher.{{ workadventure_domain }}; + + ssl_certificate_key /etc/nginx/ssl/{{ workadventure_domain }}.key; + ssl_certificate /etc/nginx/ssl/{{ workadventure_domain }}.crt; + + location / { + proxy_pass http://localhost:8002; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + proxy_set_header Host $host; + } +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + + server_name uploader.{{ workadventure_domain }}; + + ssl_certificate_key /etc/nginx/ssl/{{ workadventure_domain }}.key; + ssl_certificate /etc/nginx/ssl/{{ workadventure_domain }}.crt; + + location / { + proxy_pass http://localhost:8005; + } +} \ No newline at end of file diff --git a/dist/workadventure.service b/dist/workadventure.service new file mode 100644 index 0000000..769c38d --- /dev/null +++ b/dist/workadventure.service @@ -0,0 +1,28 @@ +[Unit] +Description=WorkAdventure service using docker compose +Requires=docker.service +After=docker.service +Before=nginx.service + +[Service] +Type=simple + +User=workadventure +Group=workadventure + +Restart=always +TimeoutStartSec=1200 + +WorkingDirectory=/opt/workadventure/source/ + +# Make sure no old containers are running +ExecStartPre=/usr/bin/docker-compose down -v + +# Compose up +ExecStart=/usr/bin/docker-compose up + +# Compose down, remove containers and volumes +ExecStop=/usr/bin/docker-compose down -v + +[Install] +WantedBy=multi-user.target