- Node.js 4.6.1
- Nginx 1.10.2
- MySQL 5.7
- Git
- Postman
- Docker
- Openshift
Install docker and docker-compose with instructions from https://docs.docker.com/engine/installation/linux/docker-ce/centos/ and https://www.unixmen.com/docker-compose-install-centos-7/
In the .env file you can configure these parameters:
- DB_NAME=nasa-smg # name of the database
- DB_USER=smg # database user
- DB_PASSWORD=T0pcoder # database password
- RESET_TABLES=false # weather to reset the db tables and data
- DOWNLOADS_DIR=./downloads #path to a directory where files will be downloaded. Change this to a and existing directory outside the directory of this document
- FILES_VERSION=1.0.1 # Files version
- APP_PORT=3000 # application port
To start the application just execute docker-compose up
in the base directory. Application will be available on http://localhost:APP_PORT
To generate sample data, after starting the application, in a new terminal run docker-compose exec app node generateRealFrontendData.js
- Download the CLI tools, add the
oc
binary to path and log in to your openshift cluster. More details are available in your openshift Web console at help > Command Line Tools - Create a new project with
oc new-project <project_name> --description="<description>" --display-name="<display_name>"
(use any values for name, description and display name) - Create the application with
oc process -f openshiftConfig.json | oc create -f -
- To get app url, execute
oc get routes
- To execute a command in the container (generate test data) first execute
oc get pods
to get a list of active pods and note the NAME of the running pod. Then executeoc exec <POD_NAME> -c ntlapp node generateData.js
Log in to the the AWS server and change to the root user.
sudo su -
Install the prerequisites for setup.
yum install -y gcc git wget
Install Node.js 4.6.1 for Red Hat Enterprise Linux following the instructions at https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora. To summarise, run
curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
then install Node.js 4.6.1 using
yum install -y nodejs
Add the MySQL YUM repository
wget http://repo.mysql.com//mysql57-community-release-el7-9.noarch.rpm
sudo yum localinstall mysql57-community-release-el7-9.noarch.rpm
Next, install MySQL server.
yum install -y mysql-community-server
Once the server is installed successfully, start the service using service mysqld start
. Obtain the auto-generated temporary password for the root account using grep 'temporary password' /var/log/mysqld.log
.
Log in to mysql using the temporary password and change the password for the account.
mysql -uroot -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'T0pcoder!';
GraphicsMagick will be compiled from source. Download the latest source from ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/GraphicsMagick-LATEST.tar.bz2
wget ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/GraphicsMagick-LATEST.tar.bz2
Install bzip2 and other dependencies required to compile from source.
yum install -y bzip2 freetype-devel libpng-devel libjpeg-devel libtiff-devel libxml2-devel
Extract the GraphicsMagick source archive using tar -jxvf GraphicsMagick-LATEST.tar.bz2
and change the current directory to the extracted folder. Run the following commands to configure and build GraphicsMagick.
./configure --prefix=/usr
make
make install
Run gm
in the shell to verify that the installation was successful.
You can edit env-sample.sh to configure the application for your environment. You can set the following options:
- DB_HOST : The host for MySQL server. (i.e. localhost)
- DB_NAME : The MySQL database name. (i.e. nasa-smg)
- DB_PORT : The port for MySQL server. (default 3306)
- DB_USER : The username to login to MySQL. (default root)
- DB_PASSWORD : The password to mysql server. (default empty password )
- RESET_TABLES : The flag which indicates if the database tables should be created afresh. It will drop and create again all tables. Test data is not inserted. Tables will be reset each time you run node app. (default false)
- DOWNLOADS_DIR : The path to directory where files are downloaded. Default to
<app folder>/downloads
.
In order to apply the environment variables, run . env-sample.sh
You must create only empty database in MySQL server. Default database name is nasa-smg
. Application will create all required tables.
To create the MySQL database, follow these steps.
- Run
mysql -uroot -p
at the shell and enter the password that you configured for the root user after installing MySQL. - Execute
CREATE DATABASE `nasa-smg`;
after successful login with the MySQL client.
- Clone the Github repository to your desired destination folder. For example,
git clone https://github.com/NASA-Tournament-Lab/NTL-Solution-Mechanism-Guide www
. - Change the working directory to the cloned folder in your terminal.
- Run
npm install
. - (optional) Generate some sample data, run
node generateRealFrontendData.js
.
Run node app
in the working directory to start the application. You should now be able to access http://<url-to-aws-instance>:3000/
where <url-to-aws-instance>
is the URL or IP address of the AWS instance the application was deployed to, and 3000 is the configured port.
Please make sure to enable access to the configured port by updating the instance's security policy (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html).
-
Install nginx following the instructions at https://www.nginx.com/resources/wiki/start/topics/tutorials/install/. Use
http://nginx.org/packages/rhel/7/x86_64/
as the configuration value for the repositorybaseurl
. -
Replace the contents of
/etc/nginx/conf.d/default.conf
with the following configuration. Replace<ec2-host-name>
with the host name of your EC2 instance, and replace3000
(if required) with the configured application port.server { listen 80; server_name <ec2-host-name>; location / { proxy_pass http://127.0.0.1:3000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarder-For $proxy_add_x_forwarded_for; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } } ```
-
Verify that the nginx configuration is valid by running
nginx -t
. -
Start nginx using service
nginx start
. -
If you encounter a 502 bad gateway error while trying to access the application using nginx, you may need to adjust the SELinux permissions for nginx. Run the following commands to set the required permissions.
sudo cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M nginx semodule -i nginx.pp
Since cost characteristics values might change in database, we added a new configuration section under Admin portal (Configuration tab) i.e. http://:/admin/help#configuration . The section will list current cost characterstics values, and next to each value there is a drop down that contains three values
Similar to $ mapping. You can map characteristic value to Low, Med or High. By default all values are mapped to Low.