Split docker files

This commit is contained in:
Eugene Burmakin
2025-01-09 15:04:05 +01:00
parent 1b6273ba1c
commit c13ebe8d3c
8 changed files with 81 additions and 20 deletions

View File

@@ -1 +1 @@
0.21.6
0.22.0

View File

@@ -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

View File

@@ -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

View File

@@ -20,4 +20,3 @@ test:
production:
<<: *default
database: <%= ENV['DATABASE_NAME'] || 'dawarich_production' %>
# url: <%= ENV['DATABASE_URL'] %>

50
docker/Dockerfile.dev Normal file
View File

@@ -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" ]

View File

@@ -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

View File

@@ -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

View File

@@ -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: