diff --git a/.github/workflows/uffizzi-build.yml b/.github/workflows/uffizzi-build.yml index f437b6ff9..d27b515f9 100644 --- a/.github/workflows/uffizzi-build.yml +++ b/.github/workflows/uffizzi-build.yml @@ -54,6 +54,7 @@ jobs: run: | APP_IMAGE=$(echo ${{ needs.build-application.outputs.tags }}) export APP_IMAGE + export UFFIZZI_URL=\$UFFIZZI_URL # Render simple template from environment variables. envsubst < ./uffizzi/docker-compose.uffizzi.yml > docker-compose.rendered.yml cat docker-compose.rendered.yml diff --git a/uffizzi/docker-compose.uffizzi.yml b/uffizzi/docker-compose.uffizzi.yml index f90f8f5ca..e541a5222 100644 --- a/uffizzi/docker-compose.uffizzi.yml +++ b/uffizzi/docker-compose.uffizzi.yml @@ -26,7 +26,7 @@ services: APP_DOMAIN: localhost:3000 APP_PROTOCOL: https:// entrypoint: ["dockerize", "-wait", "tcp://localhost:5432", "-wait", "tcp://localhost:6379", "-wait", "file:///opt/apps/forem/vendor/bundle/.bundle_finished", "-timeout", "5400s"] - command: [ "bash", "-c", "./scripts/entrypoint.sh bootstrap && bundle exec rails server -b 0.0.0.0 -p 3000"] + command: [ "bash", "-c", "./uffizzi/entrypoint.sh bootstrap"] deploy: resources: limits: diff --git a/uffizzi/entrypoint.sh b/uffizzi/entrypoint.sh new file mode 100755 index 000000000..997f75599 --- /dev/null +++ b/uffizzi/entrypoint.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +set -e + +if [ -f tmp/pids/server.pid ]; then + rm -f tmp/pids/server.pid +fi + +export url="$UFFIZZI_URL" +export UFFIZZI_URL_WITH_ESCAPE_CHAR=$(echo $UFFIZZI_DOMAIN | sed "s/\//\\\\\//g") +export APP_DOMAIN="$UFFIZZI_DOMAIN" +sed -i "s/localhost:3000/${UFFIZZI_URL_WITH_ESCAPE_CHAR}/g" /opt/apps/forem/.env +sed -i "s/http:\\/\\//https:\\/\\//g" /opt/apps/forem/.env +export RELEASE_FOOTPRINT=$(date -u +'%Y-%m-%dT%H:%M:%SZ') + +if [[ "${RAILS_ENV}" = "development" || "${RAILS_ENV}" = "test" ]]; then + + export FOREM_BUILD_DATE=RELEASE_FOOTPRINT + export FOREM_BUILD_SHA=$(git rev-parse --short HEAD) + +else + + export FOREM_BUILD_DATE=$(cat FOREM_BUILD_DATE) + export FOREM_BUILD_SHA=$(cat FOREM_BUILD_SHA) + +fi + +case "$@" in + + precompile) + echo "Running rake assets:precompile..." + bundle exec rake assets:precompile + ;; + + clean) + echo "Running rake assets:clean..." + bundle exec rake assets:clean + ;; + + clobber) + echo "Running rake assets:clobber..." + bundle exec rake assets:clobber + ;; + + bootstrap) + echo "Running rake app_initializer:setup..." + bundle exec rake app_initializer:setup + ;; + *) + echo "Running command:" + echo "$@" + exec "$@" + ;; + +esac + +bundle exec rails server -b 0.0.0.0 -p 3000 \ No newline at end of file