Skip to content

Commit

Permalink
Merge pull request #643 from Freika/fix/missing-bundler-gem
Browse files Browse the repository at this point in the history
Remove unused volumes from docker-compose.yml
  • Loading branch information
Freika authored Jan 9, 2025
2 parents ae60a38 + 4d3daf2 commit c23c8d5
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .app_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.22.0
0.22.1
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 0 additions & 3 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
57 changes: 56 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. ⚠️
Expand All @@ -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.

Expand Down
7 changes: 6 additions & 1 deletion app/controllers/api/v1/health_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 6 additions & 3 deletions docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions docker/Dockerfile.prod
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 ../. ./

Expand Down
4 changes: 0 additions & 4 deletions docker/docker-compose.production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -154,7 +152,5 @@ services:
volumes:
dawarich_db_data:
dawarich_redis_data:
dawarich_gem_cache_app:
dawarich_gem_cache_sidekiq:
dawarich_public:
dawarich_watched:
4 changes: 0 additions & 4 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -151,8 +149,6 @@ services:

volumes:
dawarich_db_data:
dawarich_gem_cache_app:
dawarich_gem_cache_sidekiq:
dawarich_shared:
dawarich_public:
dawarich_watched:
6 changes: 0 additions & 6 deletions docker/docker-compose_mounted_volumes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docs/How_to_install_Dawarich_on_Synology.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions docs/synology/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
restart: unless-stopped
volumes:
- ./redis:/var/shared/redis

dawarich_db:
image: postgres:14.2-alpine
container_name: dawarich_db
Expand All @@ -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
Expand All @@ -52,5 +51,4 @@ services:
env_file:
- .env
volumes:
- ./gem_cache:/usr/local/bundle/gems
- ./public:/var/app/public
12 changes: 12 additions & 0 deletions spec/requests/api/v1/health_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c23c8d5

Please sign in to comment.