diff --git a/.dev_to/Dockerfile b/.dev_to/Dockerfile index e05cd541..ebbdec10 100644 --- a/.dev_to/Dockerfile +++ b/.dev_to/Dockerfile @@ -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 \ diff --git a/.dev_to/compose.yml b/.dev_to/compose.yml index ec0af700..4253c5d5 100644 --- a/.dev_to/compose.yml +++ b/.dev_to/compose.yml @@ -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: + 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 diff --git a/.dev_to/dev_to.mk b/.dev_to/dev_to.mk new file mode 100644 index 00000000..98fc2f87 --- /dev/null +++ b/.dev_to/dev_to.mk @@ -0,0 +1,3 @@ +start_local_production: + RAILS_ENV=local_production dip rails assets:precompile + RAILS_ENV=local_production dip compose up diff --git a/.dev_to/prometheus.yml b/.dev_to/prometheus.yml new file mode 100644 index 00000000..de2a3fe6 --- /dev/null +++ b/.dev_to/prometheus.yml @@ -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'] diff --git a/.gitignore b/.gitignore index 53c5b710..ff6f1634 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,5 @@ package-lock.json #sitemap /public/sitemap.xml.gz +*/.env +.env diff --git a/Gemfile b/Gemfile index d55a1cad..8cf60fc9 100644 --- a/Gemfile +++ b/Gemfile @@ -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" diff --git a/Gemfile.lock b/Gemfile.lock index 84c23147..af9a39d5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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,6 +1005,7 @@ DEPENDENCIES liquid (~> 4.0) memory_profiler (~> 0.9) nakayoshi_fork + newrelic_rpm nokogiri (~> 1.10) octokit (~> 4.13) omniauth (~> 1.9) @@ -1003,6 +1013,8 @@ DEPENDENCIES 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) diff --git a/Makefile b/Makefile index 97e82a01..08063477 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +include .dev_to/dev_to.mk + .PHONY: run run: diff --git a/Procfile b/Procfile index ae689ef5..a3a8e11c 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ web: bin/start-pgbouncer bundle exec puma -C config/puma.rb -worker: bundle exec rake jobs:work \ No newline at end of file +worker: bundle exec rake jobs:work diff --git a/Procfile.dev b/Procfile.dev index f6093523..a3558538 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -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 diff --git a/app/views/articles/tag_index.html.erb b/app/views/articles/tag_index.html.erb index fa6854cb..6023ad94 100644 --- a/app/views/articles/tag_index.html.erb +++ b/app/views/articles/tag_index.html.erb @@ -1,113 +1,115 @@ -<%= content_for :page_meta do %> - <%= render "articles/tags/meta" %> -<% end %> - -