mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 01:31:39 -05:00
Move some files around
This commit is contained in:
parent
69af9710f5
commit
4d25dbca21
10 changed files with 32 additions and 119 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
FROM ruby:3.3.4-alpine
|
FROM ruby:3.3.4-alpine
|
||||||
|
|
||||||
ENV APP_PATH=/var/app
|
ENV APP_PATH=/var/app
|
||||||
ENV BUNDLE_VERSION=2.5.9
|
ENV BUNDLE_VERSION=2.5.21
|
||||||
ENV BUNDLE_PATH=/usr/local/bundle/gems
|
ENV BUNDLE_PATH=/usr/local/bundle/gems
|
||||||
ENV TMP_PATH=/tmp/
|
ENV TMP_PATH=/tmp/
|
||||||
ENV RAILS_LOG_TO_STDOUT=true
|
ENV RAILS_LOG_TO_STDOUT=true
|
||||||
|
|
@ -27,7 +27,7 @@ RUN apk -U add --no-cache \
|
||||||
&& rm -rf /var/cache/apk/* \
|
&& rm -rf /var/cache/apk/* \
|
||||||
&& mkdir -p $APP_PATH
|
&& mkdir -p $APP_PATH
|
||||||
|
|
||||||
RUN gem update --system 3.5.7 && gem install bundler --version "$BUNDLE_VERSION" \
|
RUN gem update --system 3.6.2 && gem install bundler --version "$BUNDLE_VERSION" \
|
||||||
&& rm -rf $GEM_HOME/cache/*
|
&& rm -rf $GEM_HOME/cache/*
|
||||||
|
|
||||||
# FIXME It would be a good idea to use a other user than root, but this lead to permission error on export and maybe more yet.
|
# FIXME It would be a good idea to use a other user than root, but this lead to permission error on export and maybe more yet.
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ services:
|
||||||
PROMETHEUS_EXPORTER_PORT: 9394
|
PROMETHEUS_EXPORTER_PORT: 9394
|
||||||
ENABLE_TELEMETRY: false # More on telemetry: https://dawarich.app/docs/tutorials/telemetry
|
ENABLE_TELEMETRY: false # More on telemetry: https://dawarich.app/docs/tutorials/telemetry
|
||||||
dawarich_redis:
|
dawarich_redis:
|
||||||
image: redis:7.0-alpine
|
image: redis:7.4-alpine
|
||||||
container_name: dawarich_redis
|
container_name: dawarich_redis
|
||||||
command: redis-server
|
command: redis-server
|
||||||
networks:
|
networks:
|
||||||
|
|
@ -50,7 +50,7 @@ services:
|
||||||
start_period: 30s
|
start_period: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
dawarich_db:
|
dawarich_db:
|
||||||
image: postgres:14.2-alpine
|
image: postgres:17-alpine
|
||||||
container_name: dawarich_db
|
container_name: dawarich_db
|
||||||
volumes:
|
volumes:
|
||||||
- dawarich_db_data:/var/lib/postgresql/data
|
- dawarich_db_data:/var/lib/postgresql/data
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,10 @@ class VisitSuggestingJob < ApplicationJob
|
||||||
def perform(user_ids: [], start_at: 1.day.ago, end_at: Time.current)
|
def perform(user_ids: [], start_at: 1.day.ago, end_at: Time.current)
|
||||||
users = user_ids.any? ? User.where(id: user_ids) : User.all
|
users = user_ids.any? ? User.where(id: user_ids) : User.all
|
||||||
|
|
||||||
users.find_each { Visits::Suggest.new(_1, start_at:, end_at:).call }
|
users.find_each do |user|
|
||||||
|
next if user.tracked_points.empty?
|
||||||
|
|
||||||
|
Visits::Suggest.new(user, start_at:, end_at:).call
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ class RemovePointsWithoutCoordinates < ActiveRecord::Migration[7.1]
|
||||||
|
|
||||||
Rails.logger.info 'Points without coordinates removed.'
|
Rails.logger.info 'Points without coordinates removed.'
|
||||||
|
|
||||||
BulkStatsCalculatingJob.perform_later(User.pluck(:id))
|
BulkStatsCalculatingJob.perform_later
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ RUN bundle config set --local path 'vendor/bundle' \
|
||||||
COPY ../. ./
|
COPY ../. ./
|
||||||
|
|
||||||
# Copy entrypoint scripts and grant execution permissions
|
# Copy entrypoint scripts and grant execution permissions
|
||||||
COPY ./docker/prod-docker-entrypoint.sh /usr/local/bin/entrypoint.sh
|
COPY ./docker/docker-entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
EXPOSE $RAILS_PORT
|
EXPOSE $RAILS_PORT
|
||||||
|
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
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 TMP_PATH=/tmp/
|
|
||||||
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 \
|
|
||||||
# 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/*
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# navigate to app directory
|
|
||||||
WORKDIR $APP_PATH
|
|
||||||
|
|
||||||
EXPOSE $RAILS_PORT
|
|
||||||
|
|
||||||
ENTRYPOINT [ "bundle", "exec" ]
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
unset BUNDLE_PATH
|
|
||||||
unset BUNDLE_BIN
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo "Environment: $RAILS_ENV"
|
|
||||||
|
|
||||||
# set env var defaults
|
|
||||||
DATABASE_HOST=${DATABASE_HOST:-"dawarich_db"}
|
|
||||||
DATABASE_PORT=${DATABASE_PORT:-5432}
|
|
||||||
DATABASE_USERNAME=${DATABASE_USERNAME:-"postgres"}
|
|
||||||
DATABASE_PASSWORD=${DATABASE_PASSWORD:-"password"}
|
|
||||||
DATABASE_NAME=${DATABASE_NAME:-"dawarich_development"}
|
|
||||||
|
|
||||||
# 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 $DATABASE_HOST ${DATABASE_PORT:-5432}; do
|
|
||||||
echo "Waiting for PostgreSQL to be ready..."
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
# Install gems
|
|
||||||
gem update --system 3.6.2
|
|
||||||
gem install bundler --version '2.5.21'
|
|
||||||
|
|
||||||
# Create the database
|
|
||||||
if [ "$(psql "postgres://$DATABASE_USERNAME:$DATABASE_PASSWORD@$DATABASE_HOST:$DATABASE_PORT" -XtAc "SELECT 1 FROM pg_database WHERE datname='$DATABASE_NAME'")" = '1' ]; then
|
|
||||||
echo "Database $DATABASE_NAME already exists, skipping creation..."
|
|
||||||
else
|
|
||||||
echo "Creating database $DATABASE_NAME..."
|
|
||||||
bundle exec rails db:create
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Run database migrations
|
|
||||||
echo "PostgreSQL is ready. Running database migrations..."
|
|
||||||
bundle exec rails db:migrate
|
|
||||||
|
|
||||||
# Run data migrations
|
|
||||||
echo "Running DATA migrations..."
|
|
||||||
bundle exec rake data:migrate
|
|
||||||
|
|
||||||
# Run seeds
|
|
||||||
echo "Running seeds..."
|
|
||||||
bundle exec rake db:seed
|
|
||||||
|
|
||||||
# run passed commands
|
|
||||||
bundle exec ${@}
|
|
||||||
|
|
@ -8,7 +8,7 @@ services:
|
||||||
networks:
|
networks:
|
||||||
- dawarich
|
- dawarich
|
||||||
volumes:
|
volumes:
|
||||||
- shared_data:/var/shared/redis
|
- dawarich_redis_data:/var/shared/redis
|
||||||
restart: always
|
restart: always
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
|
test: [ "CMD", "redis-cli", "--raw", "incr", "ping" ]
|
||||||
|
|
@ -18,10 +18,10 @@ services:
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
dawarich_db:
|
dawarich_db:
|
||||||
image: postgres:17-alpine
|
image: postgres:17-alpine
|
||||||
|
shm_size: 1G
|
||||||
container_name: dawarich_db
|
container_name: dawarich_db
|
||||||
volumes:
|
volumes:
|
||||||
- db_data:/var/lib/postgresql/data
|
- dawarich_db_data:/var/lib/postgresql/data
|
||||||
- shared_data:/var/shared
|
|
||||||
networks:
|
networks:
|
||||||
- dawarich
|
- dawarich
|
||||||
environment:
|
environment:
|
||||||
|
|
@ -39,9 +39,9 @@ services:
|
||||||
image: dawarich:prod
|
image: dawarich:prod
|
||||||
container_name: dawarich_app
|
container_name: dawarich_app
|
||||||
volumes:
|
volumes:
|
||||||
- gem_cache:/usr/local/bundle/gems_app
|
- dawarich_gem_cache_app:/usr/local/bundle/gems
|
||||||
- public:/var/app/public
|
- dawarich_public:/var/app/public
|
||||||
- watched:/var/app/tmp/imports/watched
|
- dawarich_watched:/var/app/tmp/imports/watched
|
||||||
networks:
|
networks:
|
||||||
- dawarich
|
- dawarich
|
||||||
ports:
|
ports:
|
||||||
|
|
@ -99,9 +99,9 @@ services:
|
||||||
image: dawarich:prod
|
image: dawarich:prod
|
||||||
container_name: dawarich_sidekiq
|
container_name: dawarich_sidekiq
|
||||||
volumes:
|
volumes:
|
||||||
- gem_cache:/usr/local/bundle/gems_sidekiq
|
- dawarich_gem_cache_sidekiq:/usr/local/bundle/gems
|
||||||
- public:/var/app/public
|
- dawarich_public:/var/app/public
|
||||||
- watched:/var/app/tmp/imports/watched
|
- dawarich_watched:/var/app/tmp/imports/watched
|
||||||
networks:
|
networks:
|
||||||
- dawarich
|
- dawarich
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
|
|
@ -156,8 +156,9 @@ services:
|
||||||
memory: '2G' # Limit memory usage to 2GB
|
memory: '2G' # Limit memory usage to 2GB
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
db_data:
|
dawarich_db_data:
|
||||||
gem_cache:
|
dawarich_redis_data:
|
||||||
shared_data:
|
dawarich_gem_cache_app:
|
||||||
public:
|
dawarich_gem_cache_sidekiq:
|
||||||
watched:
|
dawarich_public:
|
||||||
|
dawarich_watched:
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ services:
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
# command: postgres -c config_file=/etc/postgresql/postgresql.conf # Use custom config, uncomment if you want to use a custom config
|
# command: postgres -c config_file=/etc/postgresql/postgresql.conf # Use custom config, uncomment if you want to use a custom config
|
||||||
dawarich_app:
|
dawarich_app:
|
||||||
image: freikin/dawarich:latest
|
image: dawarich:prod
|
||||||
container_name: dawarich_app
|
container_name: dawarich_app
|
||||||
volumes:
|
volumes:
|
||||||
- dawarich_gem_cache_app:/usr/local/bundle/gems
|
- dawarich_gem_cache_app:/usr/local/bundle/gems
|
||||||
|
|
@ -51,8 +51,8 @@ services:
|
||||||
# - 9394:9394 # Prometheus exporter, uncomment if needed
|
# - 9394:9394 # Prometheus exporter, uncomment if needed
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
entrypoint: dev-entrypoint.sh
|
entrypoint: entrypoint.sh
|
||||||
command: ['bin/dev']
|
command: ['bin/rails', 'server', '-p', '3000', '-b', '::']
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
environment:
|
environment:
|
||||||
RAILS_ENV: development
|
RAILS_ENV: development
|
||||||
|
|
@ -94,7 +94,7 @@ services:
|
||||||
cpus: '0.50' # Limit CPU usage to 50% of one core
|
cpus: '0.50' # Limit CPU usage to 50% of one core
|
||||||
memory: '2G' # Limit memory usage to 2GB
|
memory: '2G' # Limit memory usage to 2GB
|
||||||
dawarich_sidekiq:
|
dawarich_sidekiq:
|
||||||
image: freikin/dawarich:latest
|
image: dawarich:prod
|
||||||
container_name: dawarich_sidekiq
|
container_name: dawarich_sidekiq
|
||||||
volumes:
|
volumes:
|
||||||
- dawarich_gem_cache_sidekiq:/usr/local/bundle/gems
|
- dawarich_gem_cache_sidekiq:/usr/local/bundle/gems
|
||||||
|
|
@ -104,7 +104,7 @@ services:
|
||||||
- dawarich
|
- dawarich
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
entrypoint: dev-entrypoint.sh
|
entrypoint: entrypoint.sh
|
||||||
command: ['sidekiq']
|
command: ['sidekiq']
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
environment:
|
environment:
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ unset BUNDLE_BIN
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "Environment: $RAILS_ENV"
|
echo "⚠️ Environment: $RAILS_ENV ⚠️"
|
||||||
|
|
||||||
# Parse DATABASE_URL if present, otherwise use individual variables
|
# Parse DATABASE_URL if present, otherwise use individual variables
|
||||||
if [ -n "$DATABASE_URL" ]; then
|
if [ -n "$DATABASE_URL" ]; then
|
||||||
Loading…
Reference in a new issue