diff --git a/app/controllers/api/v1/health_controller.rb b/app/controllers/api/v1/health_controller.rb index 53563cb0..62e594e9 100644 --- a/app/controllers/api/v1/health_controller.rb +++ b/app/controllers/api/v1/health_controller.rb @@ -8,4 +8,3 @@ class Api::V1::HealthController < ApiController render json: { status: 'ok' } end end - diff --git a/docker/Dockerfile b/docker/Dockerfile index 07334a1f..73644a6a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -21,7 +21,6 @@ RUN apk -U add --no-cache \ tzdata \ less \ yaml-dev \ - # gcompat for nokogiri on mac m1 gcompat \ && rm -rf /var/cache/apk/* \ && mkdir -p $APP_PATH diff --git a/docker/Dockerfile.dev b/docker/Dockerfile.dev index 8d668cf3..ad2336aa 100644 --- a/docker/Dockerfile.dev +++ b/docker/Dockerfile.dev @@ -1,7 +1,7 @@ FROM ruby:3.3.4-alpine ENV APP_PATH=/var/app -ENV BUNDLE_VERSION=2.5.9 +ENV BUNDLE_VERSION=2.5.21 ENV BUNDLE_PATH=/usr/local/bundle/gems ENV TMP_PATH=/tmp/ ENV RAILS_LOG_TO_STDOUT=true @@ -9,24 +9,24 @@ ENV RAILS_PORT=3000 # install dependencies for application RUN apk -U add --no-cache \ - build-base \ - git \ - postgresql-dev \ - postgresql-client \ - libxml2-dev \ - libxslt-dev \ - nodejs \ - yarn \ - imagemagick \ - tzdata \ - less \ - # gcompat for nokogiri on mac m1 - gcompat \ - && rm -rf /var/cache/apk/* \ - && mkdir -p $APP_PATH + build-base \ + git \ + postgresql-dev \ + postgresql-client \ + libxml2-dev \ + libxslt-dev \ + nodejs \ + yarn \ + imagemagick \ + tzdata \ + less \ + # gcompat for nokogiri on mac m1 + gcompat \ + && rm -rf /var/cache/apk/* \ + && mkdir -p $APP_PATH RUN gem install bundler --version "$BUNDLE_VERSION" \ - && rm -rf $GEM_HOME/cache/* + && rm -rf $GEM_HOME/cache/* # copy entrypoint scripts and grant execution permissions COPY ./dev-docker-entrypoint.sh /usr/local/bin/dev-entrypoint.sh diff --git a/docker/prod-docker-entrypoint.sh b/docker/prod-docker-entrypoint.sh index 683ae2f0..50ff835c 100644 --- a/docker/prod-docker-entrypoint.sh +++ b/docker/prod-docker-entrypoint.sh @@ -17,45 +17,13 @@ if [ -n "$DATABASE_URL" ]; then DATABASE_NAME=$(echo $DATABASE_URL | awk -F[@/] '{print $5}') else # Use existing environment variables - DATABASE_HOST=${DATABASE_HOST:-dawarich_db} - DATABASE_PORT=${DATABASE_PORT:-5432} - DATABASE_USERNAME=${DATABASE_USERNAME:-postgres} - DATABASE_PASSWORD=${DATABASE_PASSWORD:-password} - DATABASE_NAME=${DATABASE_NAME:-dawarich_production} + DATABASE_HOST=${DATABASE_HOST} + DATABASE_PORT=${DATABASE_PORT} + DATABASE_USERNAME=${DATABASE_USERNAME} + DATABASE_PASSWORD=${DATABASE_PASSWORD} + DATABASE_NAME=${DATABASE_NAME} fi -# Function to test database connection -test_db_connection() { - echo "Testing connection to PostgreSQL..." - echo "Host: $DATABASE_HOST" - echo "Port: $DATABASE_PORT" - echo "Username: $DATABASE_USERNAME" - echo "Database: postgres (default database)" - - if PGPASSWORD=$DATABASE_PASSWORD psql -h "$DATABASE_HOST" -p "$DATABASE_PORT" -U "$DATABASE_USERNAME" -d postgres -c "SELECT 1" > /dev/null 2>&1; then - echo "✅ Successfully connected to PostgreSQL!" - return 0 - else - echo "❌ Failed to connect to PostgreSQL" - return 1 - fi -} - -# Try to connect to PostgreSQL, with a timeout -max_attempts=30 -attempt=1 - -while ! test_db_connection; do - if [ $attempt -ge $max_attempts ]; then - echo "Failed to connect to PostgreSQL after $max_attempts attempts. Exiting." - exit 1 - fi - - echo "Attempt $attempt of $max_attempts. Waiting 2 seconds before retry..." - attempt=$((attempt + 1)) - sleep 2 -done - # Remove pre-existing puma/passenger server.pid rm -f $APP_PATH/tmp/pids/server.pid