diff --git a/.docker-profile b/.docker-profile deleted file mode 100644 index 5980f702e..000000000 --- a/.docker-profile +++ /dev/null @@ -1,4 +0,0 @@ -export PATH=$PATH:/usr/local/bin:/usr/local/bundle/bin -export GEM_HOME=/usr/local/bundle -export BUNDLE_APP_CONFIG=/usr/local/bundle -export RAILS_ENV=production diff --git a/Dockerfile b/Dockerfile index a349fdb28..223dbc7da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -53,8 +53,6 @@ ENV PUPPETEER_EXECUTABLE_PATH /usr/bin/chromium-browser ENV APP_HOME /srv ENV RAILS_ENV ${RAILS_ENV:-production} -COPY .docker-profile /root/.profile - RUN mkdir -p ${APP_HOME}/tmp/pids ${APP_HOME}/log WORKDIR ${APP_HOME} diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 2e9d8e424..7de9e4bc0 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -2,8 +2,21 @@ # ------------------------------------------------------------------------------ set -e -if [ !${RAILS_ENV}=="production" ] +if [ ${RAILS_ENV} != "production" ] then + + if [ -z ${PROXY_CERT} ] + then + echo "No proxy certificate to append" + else + echo "Appending proxy certificate" + cat $PROXY_CERT >> /etc/ssl/certs/ca-certificates.crt + fi + +# +# Development & Test +# +# ------------------------------------------------------------------------------ if bundle check then echo "$RAILS_ENV gems already bundled" @@ -11,48 +24,53 @@ then bundle fi - if [ ! -d "node_modules" ]; then + if [ ! -d "node_modules" ] + then bundle exec rails yarn:install fi - rm -f tmp/pids/server.pid - - if [ -z ${PROXY_CERT} ] + if [ -z ${DATABASE_URL} ] then - echo "No proxy certificate to append" + echo "DATABASE_URL is not defined and cannot be prepared" else - echo "Appending proxy certificate" - cat $PROXY_CERT >> /etc/ssl/certs/ca-certificates.crt + bundle exec rails db:create db:migrate fi -fi -if [ -z ${DATABASE_URL} ] -then - echo "DATABASE_URL is not defined and cannot be prepared" -else - bundle exec rails db:create db:migrate -fi + rm -f tmp/pids/server.pid -if [ -z ${ENVIRONMENT} ] -then - echo "ENVIRONMENT is not defined so the app may not startup as intended" +# ------------------------------------------------------------------------------ else - /usr/sbin/sshd - if [ !${ENVIRONMENT}=="development" ] +# +# Production +# +# ------------------------------------------------------------------------------ + if [ -z ${ENVIRONMENT} ] then - bundle exec rails db:prepare assets:precompile db:seed eyfs:bot sitemap:refresh:no_ping - fi + echo "Azure ENVIRONMENT is not defined" + else + # Azure WebSSH + /usr/sbin/sshd + eval $(printenv | xargs 2>/dev/null | export > /root/.profile) - if [ !${ENVIRONMENT}=="staging" ] - then - bundle exec rails db:prepare assets:precompile - fi + bundle exec rails db:prepare - if [ !${ENVIRONMENT}=="production" ] - then - rm public/robots.txt && touch public/robots.txt && bundle exec rails db:prepare assets:precompile + case ${ENVIRONMENT} in + "development" ) + bundle exec rails db:seed eyfs:bot sitemap:refresh:no_ping + ;; + "staging" ) + # no op + ;; + "production" ) + rm public/robots.txt && touch public/robots.txt + ;; + * ) + echo "Azure ENVIRONMENT ${ENVIRONMENT} is not supported" + esac fi + +# ------------------------------------------------------------------------------ fi exec bundle exec "$@"