From c13ebe8d3c2e61ae2ded3fbb1d7382efc22a8c01 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Thu, 9 Jan 2025 15:04:05 +0100 Subject: [PATCH] Split docker files --- .app_version | 2 +- .github/workflows/build_and_push.yml | 2 +- CHANGELOG.md | 22 ++++++++++++ config/database.yml | 1 - docker/Dockerfile.dev | 50 ++++++++++++++++++++++++++ docker/{Dockerfile => Dockerfile.prod} | 16 +++------ docker/docker-compose.production.yml | 4 --- docker/docker-compose.yml | 4 +-- 8 files changed, 81 insertions(+), 20 deletions(-) create mode 100644 docker/Dockerfile.dev rename docker/{Dockerfile => Dockerfile.prod} (75%) diff --git a/.app_version b/.app_version index 78cfa5eb..21574090 100644 --- a/.app_version +++ b/.app_version @@ -1 +1 @@ -0.21.6 +0.22.0 diff --git a/.github/workflows/build_and_push.yml b/.github/workflows/build_and_push.yml index 05173d53..00a78a71 100644 --- a/.github/workflows/build_and_push.yml +++ b/.github/workflows/build_and_push.yml @@ -40,7 +40,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: ./docker/Dockerfile + file: ./docker/Dockerfile.dev push: true tags: freikin/dawarich:latest,freikin/dawarich:${{ github.event.inputs.branch || github.ref_name }} platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b2e1169..d02b51c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +# 0.22.0 - 2025-01-09 + +⚠️ This release introduces a breaking change. ⚠️ + +Please read this release notes carefully before upgrading. + +### Changed + +- All docker-related files were moved to the `docker` directory. +- Default memory limit for `dawarich_app` and `dawarich_sidekiq` services was increased to 4GB. +- `dawarich_app` and `dawarich_sidekiq` services now use separate entrypoint scripts. +- Gems (dependency libraries) are now being shipped as part of the Dawarich Docker image. + +### Fixed + +- Visit suggesting job does nothing if user has no tracked points. +- `BulkStatsCalculationJob` now being called without arguments in the data migration. + +### Added + +- A proper production Dockerfile, docker-compose and env files. + # 0.21.6 - 2025-01-07 ### Changed diff --git a/config/database.yml b/config/database.yml index 0dc98e97..fca7a51c 100644 --- a/config/database.yml +++ b/config/database.yml @@ -20,4 +20,3 @@ test: production: <<: *default database: <%= ENV['DATABASE_NAME'] || 'dawarich_production' %> - # url: <%= ENV['DATABASE_URL'] %> diff --git a/docker/Dockerfile.dev b/docker/Dockerfile.dev new file mode 100644 index 00000000..381ece15 --- /dev/null +++ b/docker/Dockerfile.dev @@ -0,0 +1,50 @@ +FROM ruby:3.3.4-alpine + +ENV APP_PATH=/var/app +ENV BUNDLE_VERSION=2.5.21 +ENV BUNDLE_PATH=/usr/local/bundle/gems +ENV RAILS_LOG_TO_STDOUT=true +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 \ + yaml-dev \ + gcompat \ + && mkdir -p $APP_PATH + +# Update gem system and install bundler +RUN gem update --system 3.6.2 \ + && gem install bundler --version "$BUNDLE_VERSION" \ + && rm -rf $GEM_HOME/cache/* + +WORKDIR $APP_PATH + +COPY ../Gemfile ../Gemfile.lock ../vendor ../.ruby-version ./ + +# Install all gems including development and test +RUN bundle config set --local path 'vendor/bundle' \ + && bundle install --jobs 4 --retry 3 + +COPY ../. ./ + +# Copy entrypoint scripts and grant execution permissions +COPY ./docker/web-entrypoint.sh /usr/local/bin/web-entrypoint.sh +RUN chmod +x /usr/local/bin/web-entrypoint.sh + +COPY ./docker/sidekiq-entrypoint.sh /usr/local/bin/sidekiq-entrypoint.sh +RUN chmod +x /usr/local/bin/sidekiq-entrypoint.sh + +EXPOSE $RAILS_PORT + +ENTRYPOINT [ "bundle", "exec" ] diff --git a/docker/Dockerfile b/docker/Dockerfile.prod similarity index 75% rename from docker/Dockerfile rename to docker/Dockerfile.prod index ce4d8455..a8f6a449 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile.prod @@ -5,6 +5,7 @@ ENV BUNDLE_VERSION=2.5.21 ENV BUNDLE_PATH=/usr/local/bundle/gems ENV RAILS_LOG_TO_STDOUT=true ENV RAILS_PORT=3000 +ENV RAILS_ENV=production # Install dependencies for application RUN apk -U add --no-cache \ @@ -28,26 +29,19 @@ RUN gem update --system 3.6.2 \ && gem install bundler --version "$BUNDLE_VERSION" \ && rm -rf $GEM_HOME/cache/* -# Navigate to app directory WORKDIR $APP_PATH COPY ../Gemfile ../Gemfile.lock ../vendor ../.ruby-version ./ -# Install missing gems +# Install production gems only RUN bundle config set --local path 'vendor/bundle' \ - && if [ "$RAILS_ENV" = "production" ]; then \ - bundle install --jobs 4 --retry 3 --without development test; \ - else \ - bundle install --jobs 4 --retry 3; \ - fi + && bundle install --jobs 4 --retry 3 --without development test COPY ../. ./ # Precompile assets for production -RUN if [ "$RAILS_ENV" = "production" ]; then \ - bundle exec rake assets:precompile \ - && rm -rf node_modules tmp/cache; \ - fi +RUN bundle exec rake assets:precompile \ + && rm -rf node_modules tmp/cache # Copy entrypoint scripts and grant execution permissions COPY ./docker/web-entrypoint.sh /usr/local/bin/web-entrypoint.sh diff --git a/docker/docker-compose.production.yml b/docker/docker-compose.production.yml index 3603eefb..df815317 100644 --- a/docker/docker-compose.production.yml +++ b/docker/docker-compose.production.yml @@ -65,8 +65,6 @@ services: TIME_ZONE: Europe/London APPLICATION_PROTOCOL: http DISTANCE_UNIT: km - PHOTON_API_HOST: photon.komoot.io - PHOTON_API_USE_HTTPS: true PROMETHEUS_EXPORTER_ENABLED: false PROMETHEUS_EXPORTER_HOST: 0.0.0.0 PROMETHEUS_EXPORTER_PORT: 9394 @@ -121,8 +119,6 @@ services: BACKGROUND_PROCESSING_CONCURRENCY: 10 APPLICATION_PROTOCOL: http DISTANCE_UNIT: km - PHOTON_API_HOST: photon.komoot.io - PHOTON_API_USE_HTTPS: true PROMETHEUS_EXPORTER_ENABLED: false PROMETHEUS_EXPORTER_HOST: dawarich_app PROMETHEUS_EXPORTER_PORT: 9394 diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index bee3df25..e44ab15c 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -92,7 +92,7 @@ services: resources: limits: cpus: '0.50' # Limit CPU usage to 50% of one core - memory: '2G' # Limit memory usage to 2GB + memory: '4G' # Limit memory usage to 4GB dawarich_sidekiq: image: dawarich:prod container_name: dawarich_sidekiq @@ -147,7 +147,7 @@ services: resources: limits: cpus: '0.50' # Limit CPU usage to 50% of one core - memory: '2G' # Limit memory usage to 2GB + memory: '4G' # Limit memory usage to 4GB volumes: dawarich_db_data: