-
Notifications
You must be signed in to change notification settings - Fork 0
/
amazon.conf
47 lines (38 loc) · 1.1 KB
/
amazon.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# Install dependencies
dnf check-update --releasever=latest
dnf install -y curl
dnf install -y tar
dnf install -y python3
dnf install -y nginx
# Download repo
curl -Ls https://github.com/RFCreate/ec2-webpage/archive/refs/heads/main.tar.gz -o /tmp/repo.tar.gz
tar zxf /tmp/repo.tar.gz -C /tmp
# Copy python app to root directory
cp -r /tmp/ec2-webpage-main/flask-nginx/app /
# Create and activate virtual environment
python3 -m venv /app/.venv
source /app/.venv/bin/activate
# Install pip requirements
pip install -r /app/requirements.txt
# Create flask service to start automatically
tee /etc/systemd/system/flask-app.service > /dev/null << EOF
[Unit]
Description=Flask service with Waitress for web app
After=network.target
[Service]
Type=simple
ExecStart=/app/.venv/bin/python /app/app.py
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
# Start flask service
systemctl daemon-reload
systemctl enable flask-app
systemctl start flask-app
# Set nginx config
cp /tmp/ec2-webpage-main/flask-nginx/nginx.conf /etc/nginx/conf.d/default.conf
# Start nginx
systemctl enable nginx
systemctl restart nginx