Skip to content

Commit 0c9fce3

Browse files
committedApr 21, 2023
Update Vagrant files
1 parent 8e4f598 commit 0c9fce3

File tree

4 files changed

+49
-38
lines changed

4 files changed

+49
-38
lines changed
 

‎Vagrantfile

+20-32
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,28 @@ Vagrant.configure("2") do |config|
4646
# argument is a set of non-required options.
4747
# config.vm.synced_folder "../data", "/vagrant_data"
4848

49+
# config.vm.synced_folder "./", "/home/vagrant/app", type: "rsync", rsync__auto: true, rsync__exclude: ["./*venv*", "./vscode", "./.github", "./assets", "__pycache__", "./*.md"]
50+
51+
4952
# Provider-specific configuration so you can fine-tune various
5053
# backing providers for Vagrant. These expose provider-specific options.
51-
# Example for VirtualBox:
52-
#
53-
config.vm.provider "vmware_desktop" do |vb|
54+
# VMware Workstation/Fusion provider
55+
config.vm.provider "vmware_desktop" do |vmware|
5456
# Display the GUI when booting the machine
55-
vb.gui = true
57+
vmware.gui = true
5658

57-
# Customize the amount of memory on the VM:
59+
# Customize the amount of memory and CPU on the VM
60+
vmware.vmx["memsize"] = "4096"
61+
vmware.vmx["numvcpus"] = "2"
62+
end
63+
# Virtualbox provider
64+
config.vm.provider "virtualbox" do |vb|
65+
# Display the GUI when booting the machine
66+
vb.gui = true
67+
68+
# Customize the amount of memory and CPU on the VM
5869
vb.memory = "4096"
70+
vb.cpus = 2
5971
end
6072
#
6173
# View the documentation for the provider you are using for more
@@ -64,31 +76,7 @@ Vagrant.configure("2") do |config|
6476
# Enable provisioning with a shell script. Additional provisioners such as
6577
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
6678
# documentation for more information about their specific syntax and use.
67-
config.vm.provision "shell", inline: <<-SHELL
68-
# Update and Install requirements
69-
apt-get update
70-
apt-get install -y python3-pip python3-dev python3-venv python3-setuptools nginx redis supervisor git
71-
72-
# Configure Nginx
73-
unlink /etc/nginx/sites-enabled/default
74-
cp /home/vagrant/app/nginx.conf /etc/nginx/sites-enabled/
75-
76-
# Clone the Flask application from GitHub to /home/vagrant/app
77-
git clone -b feature/vagrant https://github.com/Tes3awy/PSIRT.git /home/vagrant/app
78-
79-
# Install requirements, Gunicorn, and Flask-Limiter
80-
python3 -m venv /home/vagrant/app/venv
81-
source /home/vagrant/app/venv/bin/activate
82-
python3 -m pip install --no-cache-dir -r /home/vagrant/app/requirements.txt gunicorn Flask-Limiter[redis]==3.3.0
83-
84-
# Start the application
85-
nginx -s reload
86-
87-
# Configure supervisor
88-
mkdir /var/log/psiapp
89-
mkdir /etc/supervisor/conf.d/psiapp
90-
cp /home/vagrant/app/supervisor.conf /etc/supervisor/conf.d/psiapp
91-
sudo supervisorctl reload
92-
93-
SHELL
79+
config.vm.synced_folder ".", "/home/vagrant/app", type: "rsync",
80+
rsync__exclude: [".git", "*env", "__pycache__", "*/__pycache__", "^[Dd]ocker*", ".git*" "*.md", "security.txt"]
81+
config.vm.provision "shell", keep_color: true, path: "setup.sh"
9482
end

‎nginx.conf

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
server {
22
listen 80;
33
server_name $server_addr;
4-
5-
location /static {
6-
alias /home/vagrant/app/psiapp/static;
7-
}
4+
rewrite ^/$ /main permanent;
85

96
location / {
107
proxy_pass http://localhost:8000;

‎setup.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Update and Install requirements
2+
apt-get update && apt-get upgrade -y tzdata
3+
apt-get install -y python3-pip python3-dev python3-venv python3-setuptools nginx redis supervisor git
4+
5+
# Create Python Virtual Environment and install requirements, Gunicorn, and Flask-Limiter
6+
python3 -m venv /home/vagrant/app/venv
7+
source /home/vagrant/app/venv/bin/activate
8+
python3 -m pip install --no-cache-dir --upgrade pip setuptools
9+
python3 -m pip install --no-cache-dir -r /home/vagrant/app/requirements.txt gunicorn Flask-Limiter[redis]==3.3.0
10+
11+
# Configure Nginx
12+
unlink /etc/nginx/sites-enabled/default
13+
cp /home/vagrant/app/nginx.conf /etc/nginx/sites-enabled/
14+
15+
# Start the application
16+
nginx -s reload
17+
18+
# Configure supervisor
19+
mkdir /var/log/psiapp
20+
touch /var/log/psiapp/psiapp.out.log
21+
touch /var/log/psiapp/psiapp.err.log
22+
cp /home/vagrant/app/supervisor.conf /etc/supervisor/conf.d/
23+
supervisorctl reload
24+
25+
# Check VM's assigned IP Address
26+
hostname -I

‎supervisor.conf

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[program:psiapp]
22
directory=/home/vagrant/app
3-
command=/home/vagrant/app/venv/bin/gunicorn -w 5 wsgi:app -b 0.0.0.0:8000
3+
command=/home/vagrant/app/venv/bin/gunicorn -w 5 wsgi:app
44
user=vagrant
55
autostart=true
66
autorestart=true
77
stopasgroup=true
88
killasgroup=true
99
stderr_logfile=/var/log/psiapp/psiapp.err.log
10-
stdout_logfile=/var/log/psiapp/psiapp.out.log
10+
stdout_logfile=/var/log/psiapp/psiapp.out.log

0 commit comments

Comments
 (0)
Please sign in to comment.