mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 01:01:39 -05:00
Add Dockerfile and update docker-compose.yml to use the new Dockerfile
This commit is contained in:
parent
3c74bc2937
commit
ff57efab01
5 changed files with 100 additions and 43 deletions
53
Dockerfile
Normal file
53
Dockerfile
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
FROM ruby:3.2.3-alpine
|
||||
|
||||
ENV APP_PATH /var/app
|
||||
ENV BUNDLE_VERSION 2.3.3
|
||||
ENV BUNDLE_PATH /usr/local/bundle/gems
|
||||
ENV TMP_PATH /tmp/
|
||||
ENV RAILS_LOG_TO_STDOUT true
|
||||
ENV RAILS_PORT 3000
|
||||
|
||||
# Copy entrypoint scripts and grant execution permissions
|
||||
COPY ./dev-docker-entrypoint.sh /usr/local/bin/dev-entrypoint.sh
|
||||
COPY ./test-docker-entrypoint.sh /usr/local/bin/test-entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/dev-entrypoint.sh && chmod +x /usr/local/bin/test-entrypoint.sh
|
||||
|
||||
# Copy application files to workdir
|
||||
COPY . $APP_PATH
|
||||
|
||||
# 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 for nokogiri on mac m1
|
||||
gcompat \
|
||||
&& rm -rf /var/cache/apk/* \
|
||||
&& mkdir -p $APP_PATH
|
||||
|
||||
RUN gem install bundler --version "$BUNDLE_VERSION" \
|
||||
&& rm -rf $GEM_HOME/cache/*
|
||||
|
||||
# Navigate to app directory
|
||||
WORKDIR $APP_PATH
|
||||
|
||||
COPY Gemfile Gemfile.lock ./
|
||||
|
||||
# Install missing gems
|
||||
RUN bundle config set --local path 'vendor/bundle' \
|
||||
&& bundle install --jobs 20 --retry 5
|
||||
|
||||
COPY . ./
|
||||
|
||||
EXPOSE $RAILS_PORT
|
||||
|
||||
ENTRYPOINT [ "bundle", "exec" ]
|
||||
5
Makefile
5
Makefile
|
|
@ -65,3 +65,8 @@ tail_production_log:
|
|||
|
||||
production_migrate:
|
||||
ssh dokku_frey 'dokku run dawarich bundle exec rails db:migrate'
|
||||
|
||||
build_and_push:
|
||||
docker build . -t dawarich --platform=linux/amd64 --no-cache
|
||||
docker tag dawarich registry.chibi.rodeo/dawarich
|
||||
docker push registry.chibi.rodeo/dawarich
|
||||
|
|
|
|||
7
config/initializers/sidekiq.rb
Normal file
7
config/initializers/sidekiq.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
Sidekiq.configure_server do |config|
|
||||
config.redis = { url: ENV['REDIS_URL'] }
|
||||
end
|
||||
|
||||
Sidekiq.configure_client do |config|
|
||||
config.redis = { url: ENV['REDIS_URL'] }
|
||||
end
|
||||
|
|
@ -4,11 +4,22 @@ set -e
|
|||
|
||||
echo "Environment: $RAILS_ENV"
|
||||
|
||||
# install missing gems
|
||||
bundle check || bundle install --jobs 20 --retry 5
|
||||
|
||||
# Remove pre-existing puma/passenger server.pid
|
||||
rm -f $APP_PATH/tmp/pids/server.pid
|
||||
|
||||
# Wait for the database to be ready
|
||||
until nc -zv wardu_db 5432; do
|
||||
echo "Waiting for PostgreSQL to be ready..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Create the database
|
||||
echo "Creating database $DATABASE_NAME..."
|
||||
bundle exec rails db:create
|
||||
|
||||
# Run database migrations
|
||||
echo "PostgreSQL is ready. Running database migrations..."
|
||||
bundle exec rails db:prepare
|
||||
|
||||
# run passed commands
|
||||
bundle exec ${@}
|
||||
|
|
|
|||
|
|
@ -1,42 +1,33 @@
|
|||
version: '3'
|
||||
networks:
|
||||
development:
|
||||
test:
|
||||
volumes:
|
||||
db_data:
|
||||
gem_cache:
|
||||
shared_data:
|
||||
services:
|
||||
dawarich_redis:
|
||||
image: redis:4.0-alpine
|
||||
wardu_redis:
|
||||
image: redis:7.0-alpine
|
||||
command: redis-server
|
||||
networks:
|
||||
- development
|
||||
- test
|
||||
volumes:
|
||||
- shared_data:/var/shared/redis
|
||||
dawarich_db:
|
||||
ports:
|
||||
- 6379:6379
|
||||
wardu_db:
|
||||
image: postgres:14.2-alpine
|
||||
container_name: dawarich_db
|
||||
container_name: wardu_db
|
||||
volumes:
|
||||
- db_data:/var/lib/postgresql/data
|
||||
- shared_data:/var/shared
|
||||
networks:
|
||||
- development
|
||||
- test
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: password
|
||||
ports:
|
||||
- 5099:5432
|
||||
dawarich_app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.dev
|
||||
container_name: dawarich_app
|
||||
wardu_app:
|
||||
image: registry.chibi.rodeo/wardu:latest
|
||||
container_name: wardu_app
|
||||
volumes:
|
||||
- .:/var/app
|
||||
- shared_data:/var/shared
|
||||
- gem_cache:/usr/local/bundle/gems
|
||||
networks:
|
||||
- development
|
||||
|
|
@ -44,30 +35,20 @@ services:
|
|||
- 3000:3000
|
||||
stdin_open: true
|
||||
tty: true
|
||||
env_file: .env.development
|
||||
entrypoint: dev-entrypoint.sh
|
||||
command: ['bin/dev']
|
||||
environment:
|
||||
RAILS_ENV: development
|
||||
REDIS_URL: redis://wardu_redis:6379/0
|
||||
DATABASE_HOST: wardu_db
|
||||
DATABASE_USERNAME: postgres
|
||||
DATABASE_PASSWORD: password
|
||||
DATABASE_NAME: wardu_development
|
||||
depends_on:
|
||||
- dawarich_db
|
||||
dawarich_test:
|
||||
image: dawarich_dawarich_app
|
||||
container_name: dawarich_test
|
||||
volumes:
|
||||
- .:/var/app
|
||||
- shared_data:/var/shared
|
||||
- gem_cache:/usr/local/bundle/gems
|
||||
networks:
|
||||
- test
|
||||
ports:
|
||||
- 3001:3000
|
||||
stdin_open: true
|
||||
tty: true
|
||||
env_file: .env.test
|
||||
entrypoint: test-entrypoint.sh
|
||||
command: ["rails", "-v"]
|
||||
environment:
|
||||
RAILS_ENV: test
|
||||
depends_on:
|
||||
- dawarich_db
|
||||
- wardu_db
|
||||
- wardu_redis
|
||||
|
||||
volumes:
|
||||
db_data:
|
||||
gem_cache:
|
||||
shared_data:
|
||||
|
|
|
|||
Loading…
Reference in a new issue