diff --git a/scripts/deploy/aws-lightsail.sh b/scripts/deploy/aws-lightsail.sh new file mode 100644 index 00000000..a25f44b6 --- /dev/null +++ b/scripts/deploy/aws-lightsail.sh @@ -0,0 +1,65 @@ +# move to bitnami folder first and update dependencies +cd /home/bitnami +sudo apt update + +git clone https://github.com/hudy9x/namviek +cd namviek + +# Declare REDIS_HOST, NEXT_PUBLIC_FE_GATEWAY, PORT, MONGODB_URL + +echo "REDIS_HOST=$REDIS_HOST +NEXT_PUBLIC_FE_GATEWAY=$NEXT_PUBLIC_FE_GATEWAY +PORT=$PORT +MONGODB_URL=$MONGODB_URL + +JWT_VERIFY_USER_LINK_TOKEN_EXPIRED=10m +JWT_SECRET_KEY=09123skjdhfwe +JWT_TOKEN_EXPIRED=30m +JWT_REFRESH_KEY=Iw98erhsd +JWT_REFRESH_EXPIRED=2d +" > .env + +# =================== create apache virtual host =============== + +sudo echo " + + ServerAlias * + DocumentRoot "/opt/bitnami/projects/myapp/public" + + Require all granted + + ProxyPass / http://localhost:3000/ + ProxyPassReverse / http://localhost:3000/ + +" > /opt/bitnami/apache/conf/vhosts/myapp-http-vhost.conf + +sudo echo " + + ServerAlias * + SSLEngine on + SSLCertificateFile "/opt/bitnami/apache/conf/bitnami/certs/server.crt" + SSLCertificateKeyFile "/opt/bitnami/apache/conf/bitnami/certs/server.key" + DocumentRoot "/opt/bitnami/projects/myapp" + + Require all granted + + ProxyPass / http://localhost:3000/ + ProxyPassReverse / http://localhost:3000/ + + +" > /opt/bitnami/apache/conf/vhosts/myapp-https-vhost.conf + +sudo /opt/bitnami/ctlscript.sh restart apache + + +# install forever and node_modules +sudo chmod 0777 * +sudo npm install forever -g +sudo yarn install + +# build code +sudo yarn generate2 +sudo yarn build:be + +# start backend +sudo forever start ./dist/packages/be-gateway/main.js