Skip to content

week 4 optimisation (Shlyapnikov) #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dev_to/Dockerfile
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
ARG PG_MAJOR
RUN curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
gpg --dearmor -o /usr/share/keyrings/postgres-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/postgres-archive-keyring.gpg] https://apt.postgresql.org/pub/repos/apt/" \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/postgres-archive-keyring.gpg] https://apt-archive.postgresql.org/pub/repos/apt" \
$DISTRO_NAME-pgdg main $PG_MAJOR | tee /etc/apt/sources.list.d/postgres.list > /dev/null
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
25 changes: 25 additions & 0 deletions .dev_to/compose.yml
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@ x-app: &app
tmpfs:
- /tmp
- /app/tmp/pids
stdin_open: true
tty: true

x-backend: &backend
<<: *app
@@ -52,6 +54,29 @@ x-backend: &backend
condition: service_healthy

services:
dockerhost:
image: qoomon/docker-host
cap_add: [ 'NET_ADMIN', 'NET_RAW' ]
mem_limit: 8M
restart: on-failure
prometheus:
depends_on: [ dockerhost ]
image: prom/prometheus:0.18.0
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
command:
- '-config.file=/etc/prometheus/prometheus.yml'
ports:
- '9090:9090'
grafana:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

image: grafana/grafana:3.0.0-beta7
environment:
- GF_SECURITY_ADMIN_PASSWORD=pass
depends_on:
- prometheus
ports:
- "3030:3000"

rails:
<<: *backend
command: bundle exec rails
3 changes: 3 additions & 0 deletions .dev_to/dev_to.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
start_local_production:
RAILS_ENV=local_production dip rails assets:precompile
RAILS_ENV=local_production dip compose up
11 changes: 11 additions & 0 deletions .dev_to/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
global:
scrape_interval: 5s
external_labels:
monitor: 'my-monitor'
scrape_configs:
- job_name: 'prometheus'
target_groups:
- targets: ['localhost:9090']
- job_name: 'devdev'
target_groups:
- targets: ['dockerhost:9394']
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -56,3 +56,5 @@ package-lock.json

#sitemap
/public/sitemap.xml.gz
*/.env
.env
15 changes: 11 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -60,6 +60,7 @@ gem "kaminari", "~> 1.1"
gem "libhoney", "~> 1.11"
gem "liquid", "~> 4.0"
gem "nokogiri", "~> 1.10"
gem 'newrelic_rpm'
gem "octokit", "~> 4.13"
gem "omniauth", "~> 1.9"
gem "omniauth-github", "~> 1.3"
@@ -89,7 +90,13 @@ gem "sdoc", "~> 1.0", group: :doc
gem "serviceworker-rails", "~> 0.5"
gem "share_meow_client", "~> 0.1"
gem "sitemap_generator", "~> 6.0"
gem "skylight", "~> 3.1"
gem "skylight"
gem "prometheus_exporter"
# gem "pg_query"
# gem 'yabeda-prometheus'
gem 'dotenv-rails'
gem 'rack-mini-profiler'
gem "pghero"
gem "slack-notifier", "~> 2.3"
gem "sprockets", "~> 3.7"
gem "staccato", "~> 0.5"
@@ -103,7 +110,7 @@ gem "validate_url", "~> 1.0"
gem "webpacker", "~> 3.5"
gem "webpush", "~> 0.3"

group :development do
group :development, :local_production do
gem "better_errors", "~> 2.5"
gem "binding_of_caller", "~> 0.8"
gem "brakeman", "~> 4.4", require: false
@@ -117,7 +124,7 @@ group :development do
gem "web-console", "~> 3.7"
end

group :development, :test do
group :development, :test, :local_production do
gem "capybara", "~> 3.13"
gem "derailed", "~> 0.1"
gem "erb_lint", "~> 0.0", require: false
@@ -136,7 +143,7 @@ group :development, :test do
end

group :test do
gem "approvals", "~> 0.0"
# gem "approvals", "~> 0.0"
gem "chromedriver-helper", "~> 2.1"
gem "database_cleaner", "~> 1.7"
gem "factory_bot_rails", "~> 4.11"
33 changes: 23 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -82,9 +82,9 @@ GEM
nokogiri
railties
safely_block (>= 0.1.1)
airbrake (8.1.4)
airbrake-ruby (~> 3.2)
airbrake-ruby (3.2.5)
airbrake (8.3.2)
airbrake-ruby (~> 4.1)
airbrake-ruby (4.15.0)
rbtree3 (~> 0.5)
algoliasearch (1.26.0)
httpclient (~> 2.8, >= 2.8.3)
@@ -97,9 +97,6 @@ GEM
json (~> 1.8)
ancestry (3.0.5)
activerecord (>= 3.2.0)
approvals (0.0.24)
nokogiri (~> 1.6)
thor (~> 0.18)
archive-zip (0.11.0)
io-like (~> 0.3.0)
arel (8.0.0)
@@ -248,6 +245,10 @@ GEM
docile (1.3.1)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
dotenv (2.8.1)
dotenv-rails (2.8.1)
dotenv (= 2.8.1)
railties (>= 3.2)
draper (3.0.1)
actionpack (~> 5.0)
activemodel (~> 5.0)
@@ -599,6 +600,7 @@ GEM
net-http-persistent (3.0.0)
connection_pool (~> 2.2)
netrc (0.11.0)
newrelic_rpm (9.17.0)
nio4r (2.3.1)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
@@ -637,7 +639,11 @@ GEM
parser (2.6.0.0)
ast (~> 2.4.0)
pg (1.1.4)
pghero (2.8.3)
activerecord (>= 5)
powerpack (0.1.2)
prometheus_exporter (2.1.0)
webrick
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
@@ -664,6 +670,8 @@ GEM
rack (2.0.6)
rack-host-redirect (1.3.0)
rack
rack-mini-profiler (3.1.1)
rack (>= 1.2.0)
rack-protection (2.0.4)
rack
rack-proxy (0.6.5)
@@ -683,7 +691,7 @@ GEM
bundler (>= 1.3.0)
railties (= 5.1.6.2)
sprockets-rails (>= 2.0.0)
rails-assets-airbrake-js-client (1.5.0)
rails-assets-airbrake-js-client (1.6.6)
rails-controller-testing (1.0.4)
actionpack (>= 5.0.1.x)
actionview (>= 5.0.1.x)
@@ -706,7 +714,7 @@ GEM
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rbtree3 (0.5.0)
rbtree3 (0.7.1)
rbvmomi (1.11.6)
builder (~> 3.0)
json (>= 1.8)
@@ -915,6 +923,7 @@ GEM
webpush (0.3.2)
hkdf (~> 0.2)
jwt
webrick (1.9.1)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
@@ -939,7 +948,6 @@ DEPENDENCIES
algoliasearch-rails (~> 1.21)
algorithmia (~> 1.0)
ancestry (~> 3.0)
approvals (~> 0.0)
autoprefixer-rails (~> 9.4)
aws-sdk-lambda (~> 1.16)
better_errors (~> 2.5)
@@ -963,6 +971,7 @@ DEPENDENCIES
derailed (~> 0.1)
derailed_benchmarks (~> 1.3)
devise (~> 4.6)
dotenv-rails
draper (~> 3.0)
email_validator (~> 1.6)
emoji_regex (~> 1.0)
@@ -996,13 +1005,16 @@ DEPENDENCIES
liquid (~> 4.0)
memory_profiler (~> 0.9)
nakayoshi_fork
newrelic_rpm
nokogiri (~> 1.10)
octokit (~> 4.13)
omniauth (~> 1.9)
omniauth-github (~> 1.3)
omniauth-twitter (~> 1.4)
parallel_tests (~> 2.27)
pg (~> 1.1)
pghero
prometheus_exporter
pry (~> 0.12)
pry-byebug (~> 3.7)
pry-rails (~> 0.3)
@@ -1012,6 +1024,7 @@ DEPENDENCIES
pusher (~> 1.3)
pusher-push-notifications (~> 1.0)
rack-host-redirect (~> 1.3)
rack-mini-profiler
rack-timeout (~> 0.5)
rails (~> 5.1.6)
rails-assets-airbrake-js-client (~> 1.5)!
@@ -1040,7 +1053,7 @@ DEPENDENCIES
simplecov (~> 0.16)
sinatra (~> 2.0)
sitemap_generator (~> 6.0)
skylight (~> 3.1)
skylight
slack-notifier (~> 2.3)
sprockets (~> 3.7)
staccato (~> 0.5)
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include .dev_to/dev_to.mk

.PHONY: run

run:
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: bin/start-pgbouncer bundle exec puma -C config/puma.rb
worker: bundle exec rake jobs:work
worker: bundle exec rake jobs:work
4 changes: 2 additions & 2 deletions Procfile.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
web: bin/rails s -p 3000
webpacker: ./bin/webpack-dev-server
job: bin/rake jobs:work

prometheus_exporter: bundle exec prometheus_exporter
Loading