mirror of
https://github.com/hakanensari/frankfurter.git
synced 2024-10-29 23:32:35 +01:00
parent
69c53367b1
commit
697b941632
@ -56,12 +56,6 @@ To run locally with Docker, type
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
Then seed data with
|
||||
|
||||
```bash
|
||||
docker-compose run web rake db:migrate rates:reload
|
||||
```
|
||||
|
||||
Now you can access the API at
|
||||
|
||||
```
|
||||
|
@ -4,6 +4,6 @@ RUN mkdir /app
|
||||
WORKDIR /app
|
||||
ADD Gemfile /app/Gemfile
|
||||
ADD Gemfile.lock /app/Gemfile.lock
|
||||
RUN bundle install --without development test
|
||||
RUN bundle install --jobs=8 --without development
|
||||
ADD . /app
|
||||
CMD ["unicorn", "-c", "./config/unicorn.rb"]
|
||||
|
12
app/bin/schedule
Executable file
12
app/bin/schedule
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
system 'rake db:setup'
|
||||
|
||||
require 'rufus-scheduler'
|
||||
|
||||
scheduler = Rufus::Scheduler.new
|
||||
scheduler.cron '*/15 15,16,17 * * 1-5', timeout: '1m' do
|
||||
system 'rake rates:update'
|
||||
end
|
||||
scheduler.join
|
@ -9,8 +9,3 @@ timeout 10
|
||||
before_fork do |_, _|
|
||||
Sequel::DATABASES.each(&:disconnect)
|
||||
end
|
||||
|
||||
fork do
|
||||
require_relative 'environment'
|
||||
require 'schedule'
|
||||
end
|
||||
|
@ -1,12 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'bank'
|
||||
require 'rufus-scheduler'
|
||||
|
||||
schedule = Rufus::Scheduler.new
|
||||
|
||||
schedule.cron '*/15 15,16,17 * * 1-5' do
|
||||
Bank.fetch_current_rates!
|
||||
end
|
||||
|
||||
schedule.join
|
@ -1,11 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
namespace :db do
|
||||
desc 'Create db'
|
||||
task :create do
|
||||
`createdb fixer`
|
||||
end
|
||||
|
||||
desc 'Run database migrations'
|
||||
task migrate: :environment do
|
||||
Sequel.extension(:migration)
|
||||
@ -16,4 +11,6 @@ namespace :db do
|
||||
|
||||
Sequel::IntegerMigrator.new(db, dir, opts).run
|
||||
end
|
||||
|
||||
task setup: %w[db:migrate rates:reload]
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
return if ENV['RACK_ENV'] == 'production'
|
||||
return unless defined?(Rubocop)
|
||||
|
||||
require 'rake/testtask'
|
||||
require 'rubocop/rake_task'
|
||||
@ -13,4 +13,4 @@ end
|
||||
|
||||
RuboCop::RakeTask.new
|
||||
|
||||
task default: %w[db:migrate rates:reload test rubocop]
|
||||
task default: %w[db:setup test rubocop]
|
||||
|
@ -6,6 +6,10 @@ services:
|
||||
environment:
|
||||
RACK_ENV: development
|
||||
VIRTUAL_HOST: localhost
|
||||
nginx-proxy:
|
||||
ports:
|
||||
- '8080:80'
|
||||
- "8080:8080"
|
||||
scheduler:
|
||||
build:
|
||||
context: ./app
|
||||
environment:
|
||||
RACK_ENV: development
|
||||
|
@ -10,7 +10,16 @@ services:
|
||||
max-size: "50m"
|
||||
max-file: "10"
|
||||
restart: unless-stopped
|
||||
scheduler:
|
||||
env_file: .env
|
||||
image: hakanensari/fixer
|
||||
logging:
|
||||
options:
|
||||
max-size: "50m"
|
||||
max-file: "10"
|
||||
restart: unless-stopped
|
||||
nginx-proxy:
|
||||
image: jwilder/nginx-proxy
|
||||
labels:
|
||||
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
|
||||
logging:
|
||||
@ -23,6 +32,7 @@ services:
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- /etc/nginx/conf.d
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
- ./limit_req.conf:/etc/nginx/conf.d/limit_req.conf:ro
|
||||
- certs:/etc/nginx/certs:ro
|
||||
- html:/usr/share/nginx/html
|
||||
|
@ -6,16 +6,19 @@ services:
|
||||
- data:/var/lib/postgresql/data
|
||||
web:
|
||||
command: unicorn -c config/unicorn.rb
|
||||
entrypoint: bin/wait-for-it.sh db:5432 -s --
|
||||
environment:
|
||||
DATABASE_URL: postgres://postgres@db/postgres
|
||||
entrypoint: ./wait-for-it.sh db:5432 -s --
|
||||
expose:
|
||||
- '8080'
|
||||
links:
|
||||
- db
|
||||
nginx-proxy:
|
||||
image: jwilder/nginx-proxy
|
||||
volumes:
|
||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||
scheduler:
|
||||
command: bin/schedule
|
||||
entrypoint: bin/wait-for-it.sh db:5432 -s --
|
||||
environment:
|
||||
DATABASE_URL: postgres://postgres@db/postgres
|
||||
links:
|
||||
- db
|
||||
volumes:
|
||||
data:
|
||||
|
Loading…
Reference in New Issue
Block a user