mirror of https://github.com/JohnHammond/CTFd.git
* Add Vagrantfile for development with an Ubuntu base box * Add Docker support to Vagrant VMselenium-screenshot-testing
parent
7e6d56694e
commit
92b7ca06ca
|
@ -63,3 +63,6 @@ CTFd/uploads
|
|||
.data/
|
||||
.ctfd_secret_key
|
||||
.*.swp
|
||||
|
||||
# Vagrant
|
||||
.vagrant
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
# -*- mode: ruby -*-
|
||||
# vi: set ft=ruby :
|
||||
|
||||
# Install tmux and virtualenv to support development
|
||||
$preProvision= <<SCRIPT
|
||||
sudo apt-get install tmux virtualenvwrapper -y
|
||||
SCRIPT
|
||||
|
||||
# Wrap provisioning script with a virutalenv for pip packages
|
||||
$provision= <<SCRIPT
|
||||
source /usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh
|
||||
mkvirtualenv ctfd
|
||||
workon ctfd
|
||||
cd /vagrant
|
||||
./prepare.sh
|
||||
pip install -r development.txt
|
||||
SCRIPT
|
||||
|
||||
# Start development server in a tmux session
|
||||
$startServer= <<SCRIPT
|
||||
source /usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh
|
||||
workon ctfd
|
||||
tmux new-session -d -n "ctfd" -c "/vagrant" -s "ctfd" "gunicorn --bind 0.0.0.0:8000 -w 4 'CTFd:create_app()'"
|
||||
SCRIPT
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
# ubuntu/xenial64 supports synced folders
|
||||
config.vm.box = "ubuntu/xenial64"
|
||||
|
||||
# Create a private network, which allows host-only access to the machine
|
||||
config.vm.network "private_network", ip: "10.9.8.7"
|
||||
|
||||
# Forward the default port for the development server (4000)
|
||||
# and docker or gunicorn (8000) to host machine
|
||||
config.vm.network "forwarded_port", guest: 4000, host: 4000
|
||||
config.vm.network "forwarded_port", guest: 8000, host: 8000
|
||||
|
||||
# Pre-provision
|
||||
config.vm.provision "shell", inline: $preProvision
|
||||
|
||||
# Provisioning scripts
|
||||
config.vm.provision "shell", inline: $provision, privileged: false
|
||||
|
||||
# Start server in tmux session (every reboot)
|
||||
config.vm.provision "shell", inline: $startServer, privileged: false,
|
||||
run: "always"
|
||||
|
||||
# Install docker (convenience)
|
||||
config.vm.provision "shell", path: "scripts/install_docker_ubuntu.sh"
|
||||
|
||||
end
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get install build-essential python-dev python-pip libffi-dev -y
|
||||
pip install -r requirements.txt
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Script to install docker in Debian Guest VM
|
||||
# per: https://docs.docker.com/engine/installation/linux/debian/#install-docker-ce
|
||||
|
||||
# Install packages to allow apt to use a repository over HTTPS
|
||||
sudo apt-get install -y \
|
||||
python-pip
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg2 \
|
||||
software-properties-common
|
||||
|
||||
# Add Docker’s official GPG key
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||
|
||||
# Set up the stable repository.
|
||||
sudo add-apt-repository \
|
||||
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
|
||||
$(lsb_release -cs) \
|
||||
stable"
|
||||
|
||||
# Update the apt package index
|
||||
sudo apt-get update
|
||||
|
||||
# Install the latest version of Docker
|
||||
sudo apt-get install -y docker-ce
|
||||
|
||||
# Add user to the docker group
|
||||
# Warning: The docker group grants privileges equivalent to the root user.
|
||||
sudo usermod -aG docker ubuntu
|
||||
|
||||
# Configure Docker to start on boot
|
||||
sudo systemctl enable docker
|
||||
|
||||
# Install docker-compose
|
||||
sudo pip install docker-compose
|
Loading…
Reference in New Issue