Giter Club home page Giter Club logo

portrait's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

portrait's Issues

Resolve puppeteer global dependency

Right now you are required to install node, npm, puppeteer, and minimist globally.

We should either put this into the bin/setup script OR reconfigure to use the version installed by yarn.

Setting up Portrait on Linux (CentOS 7.4)

Install CentOS

  • Install as Infrastructure Server
  • Select Development Tools
  • Select Security Tools
  • Set a root password
  • Create user imageserver, set as Administrator

Post Install

  • Login as imageserver
  • ping yahoo.com to see if network was established. If no response, you will need to configure network:
  • nmtui
  • select "Edit a Connection"
  • Select "Automatically connect"
  • Remaining defaults are fine
  • Select OK, Select back
  • Select "Activate a Connection"
  • Ensure that enp0s3 is activated (starred)
  • Select back, select quit.
  • You should now be able to ping yahoo.com and receive a response.

Update the system:
sudo yum -y update

RVM

Install some basic dependencies:

sudo yum install -y curl-devel sqlite-devel libyaml-devel

Install RVM keys:

sudo command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -

Get RVM

sudo curl -L get.rvm.io | bash -s stable

Compile RVM

source /home/imageserver/.rvm/scripts/rvm

Reload RVM

rvm reload

Install Ruby

rvm install 2.3.3
This takes time, as it compiles from source. Drink some coffee.

Prepare for NodeJS

  • su
  • login
  • yum clean all && yum update
  • curl -L https://rpm.nodesource.com/setup_7.x | bash -
  • exit

sudo yum install nodejs -y

Install Rails

gem install bundler rails

Install Passenger

gem install passenger
run passenger to ensure that install succeeded. If no errors, proceed

Install nginx

sudo chmod o+x "/home/imageserver"
rvmsudo passenger-install-nginx-module

  • Select Ruby for language
  • Select Option 1 for compile and install
  • Hit Enter (default selection) for prefix directory
  • Allow install to finish

Inital Portrait Config

  • cd to /var
  • sudo mkdir www
  • sudo git clone https://github.com/techvalidate/portait.git

Setup nginx Scripts

sudo vi /etc/rc.d/init.d/nginx

paste/create:

#!/bin/sh
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network
[ "$NETWORKING" = "no" ] && exit 0

nginx="/opt/nginx/sbin/nginx"
prog=$(basename $nginx)

NGINX_CONF_FILE="/opt/nginx/conf/nginx.conf"

lockfile=/var/lock/subsys/nginx

start() {
    [ -x $nginx ] || exit 5
    [ -f $NGINX_CONF_FILE ] || exit 6
    echo -n $"Starting $prog: "
    daemon $nginx -c $NGINX_CONF_FILE
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stopping $prog: "
    killproc $prog -QUIT
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    configtest || return $?
    stop
    start
}

reload() {
    configtest || return $?
    echo -n $”Reloading $prog: ”
    killproc $nginx -HUP
    RETVAL=$?
    echo
}

force_reload() {
    restart
}

configtest() {
    $nginx -t -c $NGINX_CONF_FILE
}

rh_status() {
    status $prog
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}

case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac

sudo vi /opt/nginx/conf/nginx.conf
uncomment #user nobody; and change to user imageserver;

Comment out the default location:

location / {
   root html;
   index index.html index.htm
}

to

#location / {
#   root html;
#   index index.html index.htm;
#}

Create a new location node:

location / {
	root /var/www/portrait/public;
	passenger_enabled on;
}

sudo /etc/init.d/nginx restart

To show nginx status: sudo /etc/init.d/nginx status

Install Puppeteer Dependencies

sudo yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver-1.2.2-6.1.el7.x86_64 libXrandr.x86_64 GConf2 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 -y

sudo yum install ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc -y

**note: I had to install libXScrnSaver-1.2.2-6.1.el7.x86_64 twice on both installations I did. I am uncertain if this was because I fat-fingered the name both times or if something overwrote the libXss library that's needed by Puppeteer each time. Something to keep in mind when testing Puppeteer. The nginx error log will show the error for libXss. If it does, simply reinstall libXScrnSaver-1.2.2-6.1.el7.x86_64

Update Node tasks in Portrait

Code needs to be changed in our node tasks, for now, on the Linux platform. See puppeteer/puppeteer#290. This may change in the future.
const browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});

Install Yarn

sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
sudo yum install yarn -y

Set Permissions

Proper permissions have to be on the files and dirs in the app directory

  • cd to /var/www
  • sudo chown -R imageserver portfolio/
  • sudo chmod -R 750 portfolio/
  • sudo chmod g+s portfolio/

Set Firewall

firewall-cmd needs to be configured for port 80 access (see https://linuxconfig.org/how-to-open-http-port-80-on-redhat-7-linux-using-firewall-cmd):
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

Install Project Dependencies

Since I wasn't sure how to get scripts in ./bin to execute, I performed the following steps manually, instead of using ./bin/setup:
First, copy config/database.yml.example to config/database.yml
Migration files may need version
bundle install
rails db:migrate RAILS_ENV=production
yarn install
rails webpacker:install
rails restart

Setup User

rails c production
u = User.create name: "name", password: "password", admin: true
u.valid?
u.save

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.