Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker compose clean up #470

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .app_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.18.2
0.18.3
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: freika # Replace with a single Patreon username
github: Freika
patreon: freika
open_collective: # Replace with a single Open Collective username
ko_fi: freika
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@ 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.18.3 - 2024-12-01

### Changed

- The `docker-compose.yml` file was refactored to use new container names.
- Default path for redis volume was changed from `/var/shared/redis` to `/data` to fix persistence issues. #148

### Removed

ENV vars removed from the docker-compose.yml:

```
TIME_ZONE: Europe/London
APPLICATION_PROTOCOL: http
DISTANCE_UNIT: km
PHOTON_API_HOST: photon.komoot.io
PHOTON_API_USE_HTTPS: true
MIN_MINUTES_SPENT_IN_CITY: 60
APPLICATION_HOST: localhost
```

Link to the https://dawarich.app/docs/environment-variables-and-settings page added instead, and the app itself is now using defaults that can be changed if env vars are provided.

# 0.18.2 - 2024-11-29

### Added
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Application < Rails::Application
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
config.time_zone = ENV.fetch('TIME_ZONE', 'Europe/Berlin')
config.time_zone = ENV.fetch('TIME_ZONE', 'UTC')
# config.eager_load_paths << Rails.root.join("extras")

# Don't generate system test files.
Expand Down
9 changes: 5 additions & 4 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@

# Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = true
config.action_mailer.default_url_options = { host: ENV.fetch('APPLICATION_HOST', 'localhost'), port: 3000 }
config.hosts << ENV.fetch('APPLICATION_HOST', 'localhost')

hosts = ENV.fetch('APPLICATION_HOSTS', 'localhost')
config.hosts.concat(hosts.split(',')) if hosts.present?
hosts = ENV.fetch('APPLICATION_HOSTS', 'localhost').split(',')

config.action_mailer.default_url_options = { host: hosts[0], port: 3000 }

config.hosts << hosts

config.force_ssl = ENV.fetch('APPLICATION_PROTOCOL', 'http').downcase == 'https'

Expand Down
14 changes: 9 additions & 5 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "active_support/core_ext/integer/time"
require 'active_support/core_ext/integer/time'

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
Expand Down Expand Up @@ -53,16 +53,16 @@

# Log to STDOUT by default
config.logger = ActiveSupport::Logger.new(STDOUT)
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
.tap { |logger| logger.formatter = ::Logger::Formatter.new }
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }

# Prepend all log lines with the following tags.
config.log_tags = [ :request_id ]
config.log_tags = [:request_id]

# Info include generic and useful information about system operation, but avoids logging too much
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
# want to log everything, set the level to "debug".
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info')

# Use a different cache store in production.
# config.cache_store = :mem_cache_store
Expand Down Expand Up @@ -95,4 +95,8 @@
# ]
# Skip DNS rebinding protection for the default health check endpoint.
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }

hosts = ENV.fetch('APPLICATION_HOSTS', 'localhost').split(',')
config.action_mailer.default_url_options = { host: hosts[0], port: 3000 }
config.hosts << hosts
end
2 changes: 1 addition & 1 deletion config/initializers/01_constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

MIN_MINUTES_SPENT_IN_CITY = ENV.fetch('MIN_MINUTES_SPENT_IN_CITY', 60).to_i
REVERSE_GEOCODING_ENABLED = ENV.fetch('REVERSE_GEOCODING_ENABLED', 'true') == 'true'
PHOTON_API_HOST = ENV.fetch('PHOTON_API_HOST', nil)
PHOTON_API_HOST = ENV.fetch('PHOTON_API_HOST', 'photon.komoot.io')
PHOTON_API_USE_HTTPS = ENV.fetch('PHOTON_API_USE_HTTPS', 'true') == 'true'
DISTANCE_UNIT = ENV.fetch('DISTANCE_UNIT', 'km').to_sym
APP_VERSION = File.read('.app_version').strip
25 changes: 6 additions & 19 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ networks:
services:
dawarich_redis:
image: redis:7.0-alpine
container_name: dawarich_redis
command: redis-server
networks:
- dawarich
volumes:
- dawarich_shared:/var/shared/redis
- dawarich_redis_data:/data
restart: always
healthcheck:
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
Expand All @@ -18,10 +17,8 @@ services:
timeout: 10s
dawarich_db:
image: postgres:14.2-alpine
container_name: dawarich_db
volumes:
- dawarich_db_data:/var/lib/postgresql/data
- dawarich_shared:/var/shared
networks:
- dawarich
environment:
Expand All @@ -36,7 +33,6 @@ services:
timeout: 10s
dawarich_app:
image: freikin/dawarich:latest
container_name: dawarich_app
volumes:
- dawarich_gem_cache_app:/usr/local/bundle/gems_app
- dawarich_public:/var/app/public
Expand All @@ -52,20 +48,15 @@ services:
command: ['bin/dev']
restart: on-failure
environment:
# All env vars with their defaults can be found here:
# https://dawarich.app/docs/environment-variables-and-settings
RAILS_ENV: development
REDIS_URL: redis://dawarich_redis:6379/0
DATABASE_HOST: dawarich_db
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: password
DATABASE_NAME: dawarich_development
MIN_MINUTES_SPENT_IN_CITY: 60
APPLICATION_HOST: localhost
APPLICATION_HOSTS: localhost
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
Expand Down Expand Up @@ -94,7 +85,6 @@ services:
memory: '2G' # Limit memory usage to 2GB
dawarich_sidekiq:
image: freikin/dawarich:latest
container_name: dawarich_sidekiq
volumes:
- dawarich_gem_cache_sidekiq:/usr/local/bundle/gems_sidekiq
- dawarich_public:/var/app/public
Expand All @@ -107,19 +97,16 @@ services:
command: ['sidekiq']
restart: on-failure
environment:
# All env vars with their defaults can be found here:
# https://dawarich.app/docs/environment-variables-and-settings
RAILS_ENV: development
REDIS_URL: redis://dawarich_redis:6379/0
DATABASE_HOST: dawarich_db
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: password
DATABASE_NAME: dawarich_development
APPLICATION_HOST: localhost
APPLICATION_HOSTS: localhost
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
Expand Down Expand Up @@ -152,8 +139,8 @@ services:

volumes:
dawarich_db_data:
dawarich_redis_data:
dawarich_gem_cache_app:
dawarich_gem_cache_sidekiq:
dawarich_shared:
dawarich_public:
dawarich_watched:
52 changes: 17 additions & 35 deletions docker-compose_mounted_volumes.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
networks:
dawarich:


volumes:
dawarich_gem_cache_app:
name: dawarich_gem_cache_app
Expand All @@ -17,44 +16,37 @@ volumes:
name: dawarich_watched

services:
app:
container_name: dawarich_app
dawarich_app:
image: freikin/dawarich:latest
restart: unless-stopped
depends_on:
db:
dawarich_db:
condition: service_healthy
restart: true
keydb:
dawarich_keydb:
condition: service_healthy
restart: true
networks:
- dawarich
ports:
- 3000:3000
environment:
TIME_ZONE: Europe/London
RAILS_ENV: development
REDIS_URL: redis://keydb:6379/0
DATABASE_HOST: db
REDIS_URL: redis://dawarich_keydb:6379/0
DATABASE_HOST: dawarich_db
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: password
DATABASE_NAME: dawarich_development
MIN_MINUTES_SPENT_IN_CITY: 60
APPLICATION_HOST: localhost
APPLICATION_HOSTS: localhost
APPLICATION_PROTOCOL: http
DISTANCE_UNIT: km
PHOTON_API_HOST: photon.komoot.io
PHOTON_API_USE_HTTPS: true
stdin_open: true
tty: true
entrypoint: dev-entrypoint.sh
command: [ 'bin/dev' ]
volumes:
- dawarich_gem_cache_app:/usr/local/bundle/gems
- dawarich_public:/var/app/dawarich_public
- watched:/var/app/tmp/imports/watched
- dawarich_watched:/var/app/tmp/imports/watched
healthcheck:
test: [ "CMD-SHELL", "wget -qO - http://127.0.0.1:3000/api/v1/health | grep -q '\"status\"\\s*:\\s*\"ok\"'" ]
start_period: 60s
Expand All @@ -64,53 +56,46 @@ services:
logging:
driver: "json-file"
options:
max-size: "10m"
max-size: "100m"
max-file: "5"
deploy:
resources:
limits:
cpus: '0.50' # Limit CPU usage to 50% of one core
memory: '2G' # Limit memory usage to 2GB

sidekiq:
container_name: dawarich_sidekiq
hostname: sidekiq
dawarich_sidekiq:
image: freikin/dawarich:latest
restart: unless-stopped
depends_on:
app:
dawarich_app:
condition: service_healthy
restart: true
db:
dawarich_db:
condition: service_healthy
restart: true
keydb:
dawarich_keydb:
condition: service_healthy
restart: true
networks:
- dawarich
environment:
RAILS_ENV: development
REDIS_URL: redis://keydb:6379/0
DATABASE_HOST: db
REDIS_URL: redis://dawarich_keydb:6379/0
DATABASE_HOST: dawarich_db
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: password
DATABASE_NAME: dawarich_development
APPLICATION_HOST: localhost
APPLICATION_HOSTS: localhost
BACKGROUND_PROCESSING_CONCURRENCY: 10
APPLICATION_PROTOCOL: http
DISTANCE_UNIT: km
PHOTON_API_HOST: photon.komoot.io
PHOTON_API_USE_HTTPS: true
stdin_open: true
tty: true
entrypoint: dev-entrypoint.sh
command: [ 'sidekiq' ]
volumes:
- dawarich_gem_cache_sidekiq:/usr/local/bundle/gems
- dawarich_public:/var/app/dawarich_public
- watched:/var/app/tmp/imports/watched
- dawarich_watched:/var/app/tmp/imports/watched
logging:
driver: "json-file"
options:
Expand All @@ -128,14 +113,13 @@ services:
cpus: '0.50' # Limit CPU usage to 50% of one core
memory: '2G' # Limit memory usage to 2GB

keydb:
container_name: dawarich-keydb
dawarich_keydb:
image: eqalpha/keydb:x86_64_v6.3.4
restart: unless-stopped
networks:
- dawarich
environment:
- TZ=Europe/London
- TZ=UTC
- PUID=1000
- PGID=1000
command: keydb-server /etc/keydb/keydb.conf --appendonly yes --server-threads 4 --active-replica no
Expand All @@ -149,9 +133,7 @@ services:
timeout: 5s
retries: 3

db:
container_name: dawarich-db
hostname: db
dawarich_db:
image: postgres:16.4-alpine3.20
restart: unless-stopped
networks:
Expand Down