2021-08-06 14:07:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
# Setup prerequisite dependencies
|
2023-08-21 09:57:50 +00:00
|
|
|
sudo apt-get update
|
2023-02-06 12:08:44 +00:00
|
|
|
sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates apt-utils git curl postgresql-client
|
|
|
|
|
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
|
|
|
|
|
export NVM_DIR="$HOME/.nvm"
|
|
|
|
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
|
|
|
nvm install 18.3.0
|
|
|
|
|
sudo ln -s "$(which node)" /usr/bin/node
|
|
|
|
|
sudo ln -s "$(which npm)" /usr/bin/npm
|
2021-08-06 14:07:45 +00:00
|
|
|
|
|
|
|
|
# Setup openresty
|
2021-06-22 05:36:09 +00:00
|
|
|
wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
|
|
|
|
|
echo "deb http://openresty.org/package/ubuntu bionic main" > openresty.list
|
|
|
|
|
sudo mv openresty.list /etc/apt/sources.list.d/
|
|
|
|
|
sudo apt-get update
|
|
|
|
|
sudo apt-get -y install --no-install-recommends openresty
|
|
|
|
|
sudo apt-get install -y curl g++ gcc autoconf automake bison libc6-dev \
|
2021-08-06 14:07:45 +00:00
|
|
|
libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libtool \
|
|
|
|
|
libyaml-dev make pkg-config sqlite3 zlib1g-dev libgmp-dev \
|
|
|
|
|
libreadline-dev libssl-dev libmysqlclient-dev build-essential \
|
|
|
|
|
freetds-dev libpq-dev
|
2021-06-22 05:36:09 +00:00
|
|
|
sudo apt-get install -y luarocks
|
|
|
|
|
sudo luarocks install lua-resty-auto-ssl
|
2021-08-09 04:32:25 +00:00
|
|
|
sudo mkdir /etc/resty-auto-ssl /var/log/openresty /etc/fallback-certs
|
2021-06-22 05:36:09 +00:00
|
|
|
sudo chown -R www-data:www-data /etc/resty-auto-ssl
|
2021-08-06 14:07:45 +00:00
|
|
|
|
2022-03-15 02:30:02 +00:00
|
|
|
# Oracle db client library setup
|
2023-06-21 06:09:30 +00:00
|
|
|
sudo apt install -y libaio1
|
2022-03-15 02:30:02 +00:00
|
|
|
curl -o instantclient-basiclite.zip https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip -SL && \
|
2023-06-21 06:09:30 +00:00
|
|
|
curl -o instantclient-basiclite-11.zip https://tooljet-plugins-production.s3.us-east-2.amazonaws.com/marketplace-assets/oracledb/instantclients/instantclient-basiclite-linux.x64-11.2.0.4.0.zip -SL && \
|
2022-03-15 02:30:02 +00:00
|
|
|
unzip instantclient-basiclite.zip && \
|
2023-06-21 06:09:30 +00:00
|
|
|
unzip instantclient-basiclite-11.zip && \
|
|
|
|
|
sudo mkdir -p /usr/lib/instantclient && sudo mv instantclient*/ /usr/lib/instantclient && \
|
2022-03-15 02:30:02 +00:00
|
|
|
rm instantclient-basiclite.zip && \
|
2023-06-21 06:09:30 +00:00
|
|
|
rm instantclient-basiclite-11.zip && \
|
|
|
|
|
echo /usr/lib/instantclient/* | sudo tee /etc/ld.so.conf.d/oracle-instantclient.conf > /dev/null && sudo ldconfig
|
|
|
|
|
# Set the Instant Client library paths
|
|
|
|
|
export LD_LIBRARY_PATH="/usr/lib/instantclient/instantclient_11_2:/usr/lib/instantclient/instantclient_21_10${LD_LIBRARY_PATH}"
|
2022-03-15 02:30:02 +00:00
|
|
|
|
2021-06-22 05:36:09 +00:00
|
|
|
# Gen fallback certs
|
|
|
|
|
sudo openssl rand -out /home/ubuntu/.rnd -hex 256
|
|
|
|
|
sudo chown www-data:www-data /home/ubuntu/.rnd
|
|
|
|
|
sudo openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 \
|
2021-08-06 14:07:45 +00:00
|
|
|
-subj '/CN=sni-support-required-for-valid-ssl' \
|
2021-08-09 04:32:25 +00:00
|
|
|
-keyout /etc/fallback-certs/resty-auto-ssl-fallback.key \
|
|
|
|
|
-out /etc/fallback-certs/resty-auto-ssl-fallback.crt
|
2021-06-22 05:36:09 +00:00
|
|
|
|
2021-08-09 04:32:25 +00:00
|
|
|
# Setup nginx config
|
|
|
|
|
export SERVER_HOST="${SERVER_HOST:=localhost}"
|
|
|
|
|
export SERVER_USER="${SERVER_USER:=www-data}"
|
2021-10-21 07:32:55 +00:00
|
|
|
VARS_TO_SUBSTITUTE='$SERVER_HOST:$SERVER_USER'
|
2021-08-09 04:32:25 +00:00
|
|
|
envsubst "${VARS_TO_SUBSTITUTE}" < /tmp/nginx.conf > /tmp/nginx-substituted.conf
|
|
|
|
|
sudo cp /tmp/nginx-substituted.conf /usr/local/openresty/nginx/conf/nginx.conf
|
|
|
|
|
|
2023-01-09 09:27:48 +00:00
|
|
|
# Download and setup postgrest binary
|
|
|
|
|
curl -OL https://github.com/PostgREST/postgrest/releases/download/v10.1.1/postgrest-v10.1.1-linux-static-x64.tar.xz
|
|
|
|
|
tar xJf postgrest-v10.1.1-linux-static-x64.tar.xz
|
|
|
|
|
sudo mv ./postgrest /bin/postgrest
|
|
|
|
|
sudo rm postgrest-v10.1.1-linux-static-x64.tar.xz
|
|
|
|
|
|
|
|
|
|
# Setup app and postgrest as systemd service
|
2021-08-06 14:07:45 +00:00
|
|
|
sudo cp /tmp/nest.service /lib/systemd/system/nest.service
|
2023-01-09 09:27:48 +00:00
|
|
|
sudo cp /tmp/postgrest.service /lib/systemd/system/postgrest.service
|
2021-08-06 14:07:45 +00:00
|
|
|
|
2021-08-09 04:32:25 +00:00
|
|
|
# Setup app directory
|
2021-08-06 14:07:45 +00:00
|
|
|
mkdir -p ~/app
|
2021-08-09 04:32:25 +00:00
|
|
|
git clone -b main https://github.com/ToolJet/ToolJet.git ~/app && cd ~/app
|
2021-08-06 14:07:45 +00:00
|
|
|
|
|
|
|
|
|
2021-06-22 05:36:09 +00:00
|
|
|
mv /tmp/.env ~/app/.env
|
|
|
|
|
mv /tmp/setup_app ~/app/setup_app
|
|
|
|
|
sudo chmod +x ~/app/setup_app
|
2021-08-06 14:07:45 +00:00
|
|
|
|
2023-02-06 12:08:44 +00:00
|
|
|
npm install -g npm@8.11.0
|
2022-01-17 07:08:17 +00:00
|
|
|
|
2021-08-06 14:07:45 +00:00
|
|
|
# Building ToolJet app
|
2023-02-06 12:08:44 +00:00
|
|
|
npm install -g @nestjs/cli
|
|
|
|
|
npm run build
|