-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.sh
41 lines (29 loc) · 1.19 KB
/
app.sh
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
#!/bin/bash
echo 'Starting to Deploy...'
# Install required dependencies
sudo apt-get update
sudo apt-get upgrade
yes | sudo apt-get install nginx
yes | sudo apt install apt-transport-https ca-certificates curl software-properties-common
yes | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
apt-cache policy docker-ce
yes | sudo apt install docker-ce
# make sure manga-scrapper docker is not running
sudo docker rm $(sudo docker stop $(sudo docker ps -a -q --filter ancestor=manga-scrapper:latest --format="{{.ID}}"))
# copy nginx conf to default
sudo cp nginx.conf /etc/nginx/conf.d/default.conf
sudo systemctl restart nginx
cd app
# build dockerfile
sudo docker build --build-arg AWS_ACCESS_KEY_ID=$1 \
--build-arg AWS_SECRET_ACCESS_KEY=$2 \
--build-arg AWS_DEFAULT_REGION=$3 \
--build-arg API_HOST=$4 \
-f dockerfile -t manga-scrapper:latest --no-cache .
echo 'AWS default region: ' $3
# run in detached mode
sudo docker run -p 3000:3000 -v /home/ubuntu/mangas:/usr/src/app/mangas -d manga-scrapper:latest
sleep 15
PORT=3000
echo 'Deployment completed successfully'