Add support for running documentation server

This commit is contained in:
Dane Everitt 2018-07-22 14:46:03 -07:00
parent 5b359aa471
commit 93ea4a24bb
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
8 changed files with 84 additions and 2 deletions

25
Vagrantfile vendored
View File

@ -59,6 +59,31 @@ Vagrant.configure("2") do |config|
SHELL
end
config.vm.define "docs" do |docs|
docs.vm.hostname = "documentation"
docs.vm.synced_folder ".", "/vagrant", disabled: true
docs.hostmanager.aliases = %w(pterodocs.local)
docs.vm.network "forwarded_port", guest: 80, host: 8088
docs.ssh.insert_key = true
docs.ssh.username = "root"
docs.ssh.password = "vagrant"
docs.vm.provider "docker" do |d|
d.image = "quay.io/pterodactyl/vagrant-core"
d.create_args = ["-it", "--add-host=host.pterodactyl.local:172.17.0.1"]
d.ports = ["8088:80"]
d.volumes = ["#{vagrant_root}/code/documentation:/srv/documentation:cached"]
d.remains_running = true
d.has_ssh = true
end
docs.vm.provision "deploy_files", type: "file", source: "#{vagrant_root}/build/configs", destination: "/tmp/.deploy"
docs.vm.provision "setup_documentation", type: "shell", path: "#{vagrant_root}/scripts/deploy_docs.sh"
end
# Configure a mysql docker container.
config.vm.define "mysql" do |mysql|
mysql.vm.hostname = "mysql"

View File

@ -0,0 +1,23 @@
server {
listen 80;
index index.html;
server_name pterodocs.local;
root /srv/documentation/.vuepress/dist;
location / {
proxy_pass http://127.0.0.1:8080;
}
# security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "same-origin" always;
add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always;
# . files
location ~ /\. {
deny all;
}
}

View File

@ -0,0 +1,7 @@
[program:nginx]
command=/usr/sbin/nginx -g 'daemon off;'
autostart=true
autorestart=true
priority=10
stdout_events_enabled=true
stderr_events_enabled=true

View File

@ -1,8 +1,8 @@
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
cp /tmp/.deploy/pterodactyl.conf /etc/supervisor/conf.d/pterodactyl.conf
cp /tmp/.deploy/pterodactyl.local.conf /etc/nginx/sites-available/pterodactyl.local.conf
cp /tmp/.deploy/supervisor/pterodactyl.conf /etc/supervisor/conf.d/pterodactyl.conf
cp /tmp/.deploy/nginx/pterodactyl.local.conf /etc/nginx/sites-available/pterodactyl.local.conf
# Needed for FPM to start correctly.
mkdir -p /run/php

26
scripts/deploy_docs.sh Normal file
View File

@ -0,0 +1,26 @@
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
# Install dependencies and start supervisor
apt install -y --no-install-recommends nodejs yarn supervisor
/usr/bin/supervisord
# Copy over deployment specific files.
cp /tmp/.deploy/supervisor/pterodocs.conf /etc/supervisor/conf.d/pterodocs.conf
cp /tmp/.deploy/nginx/pterodocs.local.conf /etc/nginx/sites-available/pterodocs.local.conf
cd /srv/documentation
yarn add vuepress
rm -f ~/docs
ln -s /srv/documentation ~/docs
# Configure and restart nginx
rm -rfv /var/www
rm -rv /etc/nginx/sites-enabled/*
ln -s /etc/nginx/sites-available/pterodocs.local.conf /etc/nginx/sites-enabled/pterodocs.local.conf
supervisorctl reread
supervisorctl update
supervisorctl restart nginx

View File

@ -8,6 +8,7 @@ vagrant plugin install vagrant-hostmanager
cd $currentDirectory
git clone https://github.com/pterodactyl/panel.git code/panel
git clone https://github.com/pterodactyl/documentation.git code/documentation
# sudo gem install docker-sync
# docker-sync start