many important fixes

This commit is contained in:
2020-02-29 11:43:00 -05:00
parent 2149345d3d
commit 73c207c324
28 changed files with 1463 additions and 242 deletions
+19 -8
View File
@@ -1,7 +1,15 @@
FROM ruby:2.3.0-slim
FROM ruby:2.7-slim
#NOTE: this file must be built from the parent (../) directory
# look at the
# rebuild-docker.sh
# script as kind of manual on how the drb_counter cointainer is managed and used
# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
#RUN bundle config --global frozen 1
RUN apt update
RUN apt install -y curl
RUN gem install bundler:1.17.3
RUN mkdir -p /usr/src/app
@@ -15,14 +23,17 @@ WORKDIR /usr/src/app
# Specific
#RUN apt-get update && apt-get install -y dos2unix --no-install-recommends && rm -rf /var/lib/apt/lists/*
COPY Gemfile /usr/src/app/
COPY Gemfile.lock /usr/src/app/
COPY drb_counter/Gemfile /usr/src/app/
#COPY drb_counter/Gemfile.lock /usr/src/app/
#COPY vendor/cache /usr/src/app/vendor/cache
#RUN bundle install --local
RUN rm -rf /usr/src/app/.bundle
#RUN bundle install
#RUN rm -rf /usr/src/app/.bundle
RUN bundle install
COPY . /usr/src/app
# COPY THE WHOLE DIRECTORY LATER THAN GEMFILE TO AVOID bundle install step on code change
COPY drb_counter /usr/src/app
RUN mkdir -p config
COPY config/couchdb.yml /usr/src/app/config/couchdb.yml
EXPOSE 9022
ENTRYPOINT ["ruby", "drb_counter.rb"]
CMD ["ruby", "drb_counter.rb"]
+2 -2
View File
@@ -1,4 +1,4 @@
source 'https://rubygems.org'
#gem "couchrest"
#gem "pry"
gem "couchrest"
gem "pry"
+16 -185
View File
@@ -1,192 +1,20 @@
GEM
remote: https://rubygems.org/
specs:
coderay (1.1.0)
couchrest (1.2.0)
mime-types (~> 1.15)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
multi_json (~> 1.0)
rest-client (~> 1.6.1)
method_source (0.8.2)
mime-types (1.25.1)
multi_json (1.10.1)
pry (0.10.1)
coderay (1.1.2)
couchrest (2.0.1)
httpclient (~> 2.8)
mime-types (>= 1.15)
multi_json (~> 1.7)
httpclient (2.8.3)
method_source (0.9.2)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
multi_json (1.14.1)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rdoc (4.2.0)
rest-client (1.6.8)
mime-types (~> 1.16)
rdoc (>= 2.4.2)
slop (3.6.0)
method_source (~> 0.9.0)
PLATFORMS
ruby
@@ -194,3 +22,6 @@ PLATFORMS
DEPENDENCIES
couchrest
pry
BUNDLED WITH
1.17.3
+4 -3
View File
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# Make drb server
# See Dockerfile for run instructions
require 'rubygems'
require 'drb/drb'
#require 'pry'
@@ -68,7 +69,7 @@ class InMemoryQCounter
puts "Environment: #{environment.inspect}"
couch_settings = YAML.load_file(couch_settings_path)[environment]
database = couch_settings['database']
db = CouchRest.database(database)
db = CouchRest.database(database) # for debug: db = CouchPotato.database.couchrest_database
design_doc = "_design/order_counter"
view_path = File.join design_doc, "_view/by_supplier_id_and_state"
tries = 0
@@ -105,6 +106,6 @@ class InMemoryQCounter
end
end
drb_port = 9022
environment = (%w[production staging development test] & ARGV).first || 'development'
DRb.start_service "druby://:#{drb_port}", InMemoryQCounter.new(reload_stats: false, environment: environment)
environment = (%w[production staging development test] & [ENV['DRB_ENV']]).first || 'development'
DRb.start_service "druby://:#{drb_port}", InMemoryQCounter.new(reload_stats: environment == 'production', environment: environment)
DRb.thread.join
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# This script rebuilds the whole environment and starts a new container
# 1. ensure this script is run from the project's root, not the drb_counter directory
pwd_dirname=$(basename $(pwd));
script_dirname="drb_counter";
if [ "$pwd_dirname" == "$script_dirname" ]; then
echo "PWD DIRNAME: "$pwd_dirname;
echo "You must run this script from the project's root dir (../) for the Dockerfile to have access to the configs to COPY";
exit 1;
fi
# 2. stop and remove all running/existing containers
docker rm $(docker stop $(docker ps -a -q --filter ancestor=mozo_drb_counter))
# 3. remove the previously built images
docker rmi mozo_drb_counter
# 4. rebuild a fresh image from the latest code
docker build -f drb_counter/Dockerfile -t mozo_drb_counter .
# debug docker and enter the bash:
# docker run --network=host --env DRB_ENV=production -t -i --rm mozo_drb_counter bash
# 5. Spin up the counter container from the generated image
docker run --network=host --env DRB_ENV=production --detach --name=mozo_drb_counter mozo_drb_counter