Skip to content
Snippets Groups Projects
Commit 7f0244d3 authored by iaibrys's avatar iaibrys
Browse files

Cleanup scripts and move precompile to dockerfile

parent 5df4103a
No related branches found
No related tags found
No related merge requests found
Pipeline #67 passed
...@@ -88,5 +88,7 @@ RUN mkdir -p ${APP_ROOT}/log ...@@ -88,5 +88,7 @@ RUN mkdir -p ${APP_ROOT}/log
# Generate cookie key # Generate cookie key
RUN RAILS_ENV=production PRECOMPILE=1 bundle exec rake secret > ~/secret-key-base.txt RUN RAILS_ENV=production PRECOMPILE=1 bundle exec rake secret > ~/secret-key-base.txt
RUN RAILS_ENV=production PRECOMPILE=1 bundle exec rake assets:precompile
CMD ["/bin/bash", "-l", "-c", "./scripts/run-server.sh 2>&1 | tee ${APP_ROOT}/log/run-server.log"] CMD ["/bin/bash", "-l", "-c", "./scripts/run-server.sh 2>&1 | tee ${APP_ROOT}/log/run-server.log"]
Subproject commit 342df358ddfdce10717598e5ea39f59094e21cb5 Subproject commit bd85823fdb0a6926f45023dd886e290b1379db89
#!/bin/bash #!/bin/bash
timestamp() timestamp() { date "+%FT%T%z"; }
{
date "+%FT%T%z" log() { echo "[$(timestamp)] ${@}"; }
}
public=/data/website-public public=/data/website-public
CHOWN=${CHOWN:-dtuuser:dtugroup}
echo [$(timestamp)] RUNNING WEBSITE SERVER AS `whoami` log "RUNNING WEBSITE SERVER AS $(whoami) (${CHOWN})"
echo [$(timestamp)] RUNNING WEBSITE IN TIMEZONE ${TZ} log "RUNNING WEBSITE IN TIMEZONE ${TZ}"
echo [$(timestamp)] STARTING SERVER FOR STARTUP MESSAGE log "STARTING SERVER FOR STARTUP MESSAGE"
export PORT=3000 export PORT=3000
indexpage=_rails_starting.html bundle exec thin -R ./maintenance.ru -p $PORT start & indexpage=_rails_starting.html bundle exec thin -R ./maintenance.ru -p ${PORT} start &
ruby -v | grep "2\.5\.1" ruby -v | grep "2\.5\.1"
rc=$? if [[ $? != 0 ]]; then
if [[ ${rc} != 0 ]]; then
echo "Wrong version of Ruby installed!" echo "Wrong version of Ruby installed!"
ruby -v ruby -v
exit ${rc}; exit ${?};
fi fi
RAILS_ENV=${RAILS_ENV:="development"} RAILS_ENV=${RAILS_ENV:="development"}
...@@ -35,26 +34,23 @@ curl http://localhost:${PORT} ...@@ -35,26 +34,23 @@ curl http://localhost:${PORT}
SECRET_KEY_BASE=${SECRET_KEY_BASE:=`cat ~/secret-key-base.txt`} SECRET_KEY_BASE=${SECRET_KEY_BASE:=`cat ~/secret-key-base.txt`}
export SECRET_KEY_BASE=${SECRET_KEY_BASE} export SECRET_KEY_BASE=${SECRET_KEY_BASE}
echo REMOVING TMP log "REMOVING TMP"
rm -rf tmp/* rm -rf tmp/*
rm -rf ${APP_ROOT}/log/* rm -rf ${APP_ROOT}/log/*
mkdir -p ${APP_ROOT}/log/ mkdir -p ${APP_ROOT}/log/
echo [$(timestamp)] LINKING SHARED ASSETS AND LOGFILES log "LINKING SHARED ASSETS AND LOG FILES"
RAILS_ENV=production bundle exec rake assets:clobber
RAILS_ENV=production bundle exec rake assets:precompile
# gross! https://github.com/docker/docker/issues/2259 # gross! https://github.com/docker/docker/issues/2259
sudo chown -R dtuuser:dtuuser /data/* sudo chown -R ${CHOWN} /data/*
sshdir=/home/`whoami`/.ssh sshdir=/home/$(whoami)/.ssh
[[ -d ${sshdir} ]] || mkdir ${sshdir} [[ -d ${sshdir} ]] || mkdir ${sshdir}
sudo sh -c "cp /get-pdf-keys/* ${sshdir} && chown -R dtuuser:dtugroup ${sshdir}/*" sudo sh -c "cp /get-pdf-keys/* ${sshdir} && chown -R ${CHOWN} ${sshdir}/*"
sudo chmod 0600 ${sshdir}/* sudo chmod 0600 ${sshdir}/*
echo COPYING PRECOMPILED APP ASSETS log "COPYING PRECOMPILED APP ASSETS"
# make these available for nginx to serve statically # make these available for nginx to serve statically
cp -R ./public/* ${public} cp -R ./public/* ${public}
...@@ -68,7 +64,7 @@ cp -R deps/pdfjs/build/generic/web/* ${public}/assets/pdfjs-viewer/ ...@@ -68,7 +64,7 @@ cp -R deps/pdfjs/build/generic/web/* ${public}/assets/pdfjs-viewer/
cp -R deps/pdfjs/build/generic/web ${public}/assets/pdfjs-viewer/ cp -R deps/pdfjs/build/generic/web ${public}/assets/pdfjs-viewer/
cp -R deps/pdfjs/build/generic/build ${public}/assets/pdfjs-viewer/ cp -R deps/pdfjs/build/generic/build ${public}/assets/pdfjs-viewer/
echo [$(timestamp)] FLUSHING REDIS SOFT-STATE CACHE log "FLUSHING REDIS SOFT-STATE CACHE"
redis-cli -h redis -n 1 flushdb redis-cli -h redis -n 1 flushdb
...@@ -79,26 +75,26 @@ redis-cli -h redis -n 1 flushdb ...@@ -79,26 +75,26 @@ redis-cli -h redis -n 1 flushdb
# For feedback.js # For feedback.js
cp ./vendor/assets/components/feedback/stable/2.0/icons.png ${public}/assets cp ./vendor/assets/components/feedback/stable/2.0/icons.png ${public}/assets
echo [$(timestamp)] DONE PRECOMPILING ASSETS log "DONE PRECOMPILING ASSETS"
echo [$(timestamp)] MIGRATING DB log "MIGRATING DB"
bundle exec rake db:migrate bundle exec rake db:migrate
echo [$(timestamp)] KILLING SERVER FOR STARTUP MESSAGE log "KILLING SERVER FOR STARTUP MESSAGE"
kill $(jobs -p) kill $(jobs -p)
wait wait
echo [$(timestamp)] STARTING RAILS WITH RAILS_ENV=${RAILS_ENV} log "STARTING RAILS WITH RAILS_ENV=${RAILS_ENV}"
foreman start foreman start
echo [$(timestamp)] RAILS DIED! log "RAILS DIED!"
echo [$(timestamp)] STARTING SERVER FOR FAIL MESSAGE log "STARTING SERVER FOR FAIL MESSAGE"
indexpage=_rails_failed.html bundle exec thin -R ./maintenance.ru -p ${PORT} start indexpage=_rails_failed.html bundle exec thin -R ./maintenance.ru -p ${PORT} start
echo [$(timestamp)] WAITING FOREVER SO CONTAINER STAYS ACTIVE FOR DEBUGGING log "WAITING FOREVER SO CONTAINER STAYS ACTIVE FOR DEBUGGING"
tail -F -n0 /etc/hosts tail -F -n0 /etc/hosts
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment