diff --git a/.app_version b/.app_version index 21574090..a723ece7 100644 --- a/.app_version +++ b/.app_version @@ -1 +1 @@ -0.22.0 +0.22.1 diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a2077946..a61f0adb 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -# Basis-Image für Ruby und Node.js +# Base-Image for Ruby and Node.js FROM ruby:3.3.4-alpine ENV APP_PATH=/var/app diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 56fb8d5f..e2b7aeb3 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -8,7 +8,6 @@ services: container_name: dawarich_dev volumes: - "${PWD}:/var/app:cached" - - dawarich_gem_cache_app:/usr/local/bundle/gems_app - dawarich_public:/var/app/public - dawarich_watched:/var/app/tmp/imports/watched networks: @@ -69,8 +68,6 @@ services: POSTGRES_PASSWORD: password volumes: dawarich_db_data: - dawarich_gem_cache_app: - dawarich_gem_cache_sidekiq: dawarich_shared: dawarich_public: dawarich_watched: diff --git a/CHANGELOG.md b/CHANGELOG.md index 09c51769..f7f7be29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,41 @@ 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.1 - 2025-01-09 + +### Removed + +- Gems caching volume from the `docker-compose.yml` file. + +To update existing `docker-compose.yml` to new changes, refer to the following: + +```diff + dawarich_app: + image: freikin/dawarich:latest +... + volumes: +- - dawarich_gem_cache_app:/usr/local/bundle/gems +... + dawarich_sidekiq: + image: freikin/dawarich:latest +... + volumes: +- - dawarich_gem_cache_app:/usr/local/bundle/gems +... + +volumes: + dawarich_db_data: +- dawarich_gem_cache_app: +- dawarich_gem_cache_sidekiq: + dawarich_shared: + dawarich_public: + dawarich_watched: +``` + +### Changed + +- `GET /api/v1/health` endpoint now returns a `X-Dawarich-Response: Hey, Im alive and authenticated!` header if user is authenticated. + # 0.22.0 - 2025-01-09 ⚠️ This release introduces a breaking change. ⚠️ @@ -13,7 +48,27 @@ Please read this release notes carefully before upgrading. Docker-related files were moved to the `docker` directory and some of them were renamed. Before upgrading, study carefully changes in the `docker/docker-compose.yml` file and update your docker-compose file accordingly, so it uses the new files and commands. Copying `docker/docker-compose.yml` blindly may lead to errors. -No volumes were removed or renamed, so with a proper docker-compose file, you should be able to upgrade without any issues. To make it easier comparing your existing docker-compose file with the new one, you may use https://www.diffchecker.com/. +No volumes were removed or renamed, so with a proper docker-compose file, you should be able to upgrade without any issues. + +To update existing `docker-compose.yml` to new changes, refer to the following: + +```diff + dawarich_app: + image: freikin/dawarich:latest +... +- entrypoint: dev-entrypoint.sh +- command: ['bin/dev'] ++ entrypoint: web-entrypoint.sh ++ command: ['bin/rails', 'server', '-p', '3000', '-b', '::'] +... + dawarich_sidekiq: + image: freikin/dawarich:latest +... +- entrypoint: dev-entrypoint.sh +- command: ['bin/dev'] ++ entrypoint: sidekiq-entrypoint.sh ++ command: ['bundle', 'exec', 'sidekiq'] +``` Although `docker-compose.production.yml` was added, it's not being used by default. It's just an example of how to configure Dawarich for production. The default `docker-compose.yml` file is still recommended for running the app. diff --git a/app/controllers/api/v1/health_controller.rb b/app/controllers/api/v1/health_controller.rb index 62e594e9..87df7d96 100644 --- a/app/controllers/api/v1/health_controller.rb +++ b/app/controllers/api/v1/health_controller.rb @@ -4,7 +4,12 @@ class Api::V1::HealthController < ApiController skip_before_action :authenticate_api_key def index - response.set_header('X-Dawarich-Response', 'Hey, I\'m alive!') + if current_api_user + response.set_header('X-Dawarich-Response', 'Hey, I\'m alive and authenticated!') + else + response.set_header('X-Dawarich-Response', 'Hey, I\'m alive!') + end + render json: { status: 'ok' } end end diff --git a/docker/Dockerfile.dev b/docker/Dockerfile.dev index 381ece15..37b04015 100644 --- a/docker/Dockerfile.dev +++ b/docker/Dockerfile.dev @@ -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=development # Install dependencies for application RUN apk -U add --no-cache \ @@ -30,12 +31,14 @@ RUN gem update --system 3.6.2 \ WORKDIR $APP_PATH -COPY ../Gemfile ../Gemfile.lock ../vendor ../.ruby-version ./ +COPY ../Gemfile ../Gemfile.lock ../.ruby-version ../vendor ./ -# Install all gems including development and test +# Install all gems into the image RUN bundle config set --local path 'vendor/bundle' \ - && bundle install --jobs 4 --retry 3 + && bundle install --jobs 4 --retry 3 \ + && rm -rf vendor/bundle/ruby/3.3.0/cache/*.gem +# Copy the rest of the application COPY ../. ./ # Copy entrypoint scripts and grant execution permissions diff --git a/docker/Dockerfile.prod b/docker/Dockerfile.prod index a8f6a449..ae36af49 100644 --- a/docker/Dockerfile.prod +++ b/docker/Dockerfile.prod @@ -6,6 +6,8 @@ ENV BUNDLE_PATH=/usr/local/bundle/gems ENV RAILS_LOG_TO_STDOUT=true ENV RAILS_PORT=3000 ENV RAILS_ENV=production +ENV SECRET_KEY_BASE=$SECRET_KEY_BASE + # Install dependencies for application RUN apk -U add --no-cache \ @@ -31,11 +33,13 @@ RUN gem update --system 3.6.2 \ WORKDIR $APP_PATH -COPY ../Gemfile ../Gemfile.lock ../vendor ../.ruby-version ./ +COPY ../Gemfile ../Gemfile.lock ../.ruby-version ../vendor ./ # Install production gems only RUN bundle config set --local path 'vendor/bundle' \ - && bundle install --jobs 4 --retry 3 --without development test + && bundle config set --local without 'development test' \ + && bundle install --jobs 4 --retry 3 \ + && rm -rf vendor/bundle/ruby/3.3.0/cache/*.gem COPY ../. ./ diff --git a/docker/docker-compose.production.yml b/docker/docker-compose.production.yml index 1eb90902..90bfec24 100644 --- a/docker/docker-compose.production.yml +++ b/docker/docker-compose.production.yml @@ -39,7 +39,6 @@ services: image: freikin/dawarich:latest container_name: dawarich_app volumes: - - dawarich_gem_cache_app:/usr/local/bundle/gems - dawarich_public:/var/app/public - dawarich_watched:/var/app/tmp/imports/watched networks: @@ -97,7 +96,6 @@ services: image: freikin/dawarich:latest container_name: dawarich_sidekiq volumes: - - dawarich_gem_cache_sidekiq:/usr/local/bundle/gems - dawarich_public:/var/app/public - dawarich_watched:/var/app/tmp/imports/watched networks: @@ -154,7 +152,5 @@ services: volumes: dawarich_db_data: dawarich_redis_data: - dawarich_gem_cache_app: - dawarich_gem_cache_sidekiq: dawarich_public: dawarich_watched: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index d2154c2c..93c0296f 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -41,7 +41,6 @@ services: image: freikin/dawarich:latest container_name: dawarich_app volumes: - - dawarich_gem_cache_app:/usr/local/bundle/gems - dawarich_public:/var/app/public - dawarich_watched:/var/app/tmp/imports/watched networks: @@ -97,7 +96,6 @@ services: image: freikin/dawarich:latest container_name: dawarich_sidekiq volumes: - - dawarich_gem_cache_sidekiq:/usr/local/bundle/gems - dawarich_public:/var/app/public - dawarich_watched:/var/app/tmp/imports/watched networks: @@ -151,8 +149,6 @@ services: volumes: dawarich_db_data: - dawarich_gem_cache_app: - dawarich_gem_cache_sidekiq: dawarich_shared: dawarich_public: dawarich_watched: diff --git a/docker/docker-compose_mounted_volumes.yml b/docker/docker-compose_mounted_volumes.yml index 6a712834..ef61f49a 100644 --- a/docker/docker-compose_mounted_volumes.yml +++ b/docker/docker-compose_mounted_volumes.yml @@ -3,10 +3,6 @@ networks: volumes: - dawarich_gem_cache_app: - name: dawarich_gem_cache_app - dawarich_gem_cache_sidekiq: - name: dawarich_gem_cache_sidekiq dawarich_public: name: dawarich_public dawarich_keydb: @@ -49,7 +45,6 @@ services: 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 healthcheck: @@ -102,7 +97,6 @@ services: 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 logging: diff --git a/docs/How_to_install_Dawarich_on_Synology.md b/docs/How_to_install_Dawarich_on_Synology.md index 228d5137..ff17f1a8 100644 --- a/docs/How_to_install_Dawarich_on_Synology.md +++ b/docs/How_to_install_Dawarich_on_Synology.md @@ -29,7 +29,7 @@ If you don't want to use dedicated share for projects installed by docker skip i ### Dawarich root folder 1. Open your [Docker root folder](#docker-root-share) in **File station**. 2. Create new folder **dawarich** and open it. -3. Create folders **redis**, **db_data**, **db_shared**, **gem_cache** and **public** in **dawarich** folder. +3. Create folders **redis**, **db_data**, **db_shared** and **public** in **dawarich** folder. 4. Copy [docker compose](synology/docker-compose.yml) and [.env](synology/.env) files form **synology** repo folder into **dawarich** folder on your synology. # Installation diff --git a/docs/synology/docker-compose.yml b/docs/synology/docker-compose.yml index 6a9f14ed..5544db41 100644 --- a/docs/synology/docker-compose.yml +++ b/docs/synology/docker-compose.yml @@ -8,7 +8,7 @@ services: restart: unless-stopped volumes: - ./redis:/var/shared/redis - + dawarich_db: image: postgres:14.2-alpine container_name: dawarich_db @@ -34,11 +34,10 @@ services: env_file: - .env volumes: - - ./gem_cache:/usr/local/bundle/gems - ./public:/var/app/public ports: - 32568:3000 - + dawarich_sidekiq: image: freikin/dawarich:latest container_name: dawarich_sidekiq @@ -52,5 +51,4 @@ services: env_file: - .env volumes: - - ./gem_cache:/usr/local/bundle/gems - ./public:/var/app/public diff --git a/spec/requests/api/v1/health_spec.rb b/spec/requests/api/v1/health_spec.rb index 264dbdcb..4861b399 100644 --- a/spec/requests/api/v1/health_spec.rb +++ b/spec/requests/api/v1/health_spec.rb @@ -9,6 +9,18 @@ get '/api/v1/health' expect(response).to have_http_status(:success) + expect(response.headers['X-Dawarich-Response']).to eq('Hey, I\'m alive!') + end + end + + context 'when user is authenticated' do + let(:user) { create(:user) } + + it 'returns http success' do + get '/api/v1/health', headers: { 'Authorization' => "Bearer #{user.api_key}" } + + expect(response).to have_http_status(:success) + expect(response.headers['X-Dawarich-Response']).to eq('Hey, I\'m alive and authenticated!') end end end