anchor.diff:        postgresql-devel \
         pgbouncer \
         git \
  -      nodejs
  -RUN yum -y install nginx
  +      nodejs &&\
  +    yum -y install nginx
   
  -# rbenv Setup
  -RUN useradd kagetra
  +
  +RUN useradd -G postgres,nginx kagetra
  +RUN chown kagetra:postgres -R /var/lib/pgsql/ /var/run/postgresql/ &&\
  +    chown kagetra:nginx -R /var/lib/nginx/ /var/log/nginx/ /etc/nginx/
  +
   
   USER kagetra
   ENV HOME=/home/kagetra LANGUAGE="en_US.UTF-8"  LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8"
  
positive.code: FROM centos:7
  
  # Basic Package Install
  RUN yum -y update
  RUN yum -y groupinstall "Development Tools"
  RUN curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
  RUN yum -y install \
        epel-release \
        ruby-devel ruby ruby-irb \
        openssl-devel \
        readline-devel \
        sqlite-devel \ 
  
negative.code: RUN sed -i -e '/^add_import_path/{s/#{RUBY_VERSION}/2.4.0/}' deploy/compass_conf.rb
  RUN bash -lc "cd deploy && make"
  
  RUN initdb -D /var/lib/pgsql/data && \
      pg_ctl start -D /var/lib/pgsql/data -s -w -t 300 && \
      createdb -E UTF8 -O kagetra kagetra && \
      bash -lc "bundle exec ./scripts/initial_config.rb" && \
      bash -lc "bundle exec ./scripts/initial_config.rb -p kagetora" && \
      pg_ctl stop -D /var/lib/pgsql/data
  
  COPY nginx.conf /etc/nginx/nginx.conf
  RUN cp /home/kagetra/kagetra/deploy/nginx.site.example /etc/nginx/conf.d/kagetra.conf &&\
      sed -i -e 's!/path/to/kagetra!/home/kagetra/kagetra!' /etc/nginx/conf.d/kagetra.conf &&\
      sed -i -e 's/listen 80;/listen 1530;/' /etc/nginx/conf.d/kagetra.conf
  
  CMD /usr/sbin/nginx &&\
      pg_ctl start -D /var/lib/pgsql/data -s -w -t 300 &&\
      bash -lc "cd scripts && ./unicorn_ctl.sh start" &&\
      while true; do sleep 1000; done
  
  EXPOSE 1530
  