From bcd00aa2c46ac4d6107760db2cbde397ab39d504 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Wed, 15 Jan 2025 21:22:45 +0100 Subject: [PATCH] DEV: Remove unused docker images 1. `monitor` uses a 9 year old base image 2. `discourse_fast_switch` uses a 6 year old base image and references ruby 2.4 and 2.5 3. `discourse_bench` uses an 8 year old base image and references postgres 9.5 --- image/README.md | 10 -- image/discourse_bench/Dockerfile | 34 ------- image/discourse_bench/run_bench.sh | 19 ---- image/discourse_fast_switch/Dockerfile | 23 ----- image/discourse_fast_switch/create_switch.rb | 25 ----- image/monitor/Dockerfile | 13 --- image/monitor/src/monitor.rb | 98 -------------------- 7 files changed, 222 deletions(-) delete mode 100644 image/discourse_bench/Dockerfile delete mode 100644 image/discourse_bench/run_bench.sh delete mode 100644 image/discourse_fast_switch/Dockerfile delete mode 100644 image/discourse_fast_switch/create_switch.rb delete mode 100644 image/monitor/Dockerfile delete mode 100644 image/monitor/src/monitor.rb diff --git a/image/README.md b/image/README.md index d29158837..15d7c3944 100644 --- a/image/README.md +++ b/image/README.md @@ -29,13 +29,3 @@ Note that the discourse user is granted "sudo" permission without asking for a p ### discourse_test ([discourse/discourse_test](https://hub.docker.com/r/discourse/discourse_test/)) Builds on the discourse image and adds testing tools and a default testing entrypoint. - - -### discourse_bench ([discourse/discourse_bench](https://hub.docker.com/r/discourse/discourse_bench/)) - -Builds on the discourse_test image and adds benchmark testing. - - -### discourse_fast_switch ([discourse/discourse_fast_switch](https://hub.docker.com/r/discourse/discourse_fast_switch/)) - -Builds on the discourse image and adds the ability to easily switch versions of Ruby. diff --git a/image/discourse_bench/Dockerfile b/image/discourse_bench/Dockerfile deleted file mode 100644 index 8dd9ef7af..000000000 --- a/image/discourse_bench/Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -# NAME: discourse/discourse_bench -# VERSION: 1.4.0 -FROM discourse/discourse_test:1.4.0 -ENV RAILS_ENV profile - -#LABEL maintainer="Gerhard Schlager " - -# Install ApacheBench -RUN apt-get install -y apache2-utils libsqlite3-dev - -# configure Git to suppress warnings -RUN git config --global user.email "you@example.com" &&\ - git config --global user.name "Your Name" - -RUN git pull &&\ - sudo -u discourse bundle install --jobs $(($(nproc) - 1)) --standalone - -RUN gem install facter &&\ - gem install mailcatcher - -# reconfigure PostgreSQL template databases to use UTF-8 -# otherwise rake db:create fails -RUN pg_dropcluster --stop 9.5 main &&\ - pg_createcluster --start -e UTF-8 9.5 main - -# create role "discourse" -RUN /etc/init.d/postgresql start &&\ - sleep 5 &&\ - sudo -u postgres createuser --superuser discourse - -ADD run_bench.sh /tmp/run_bench.sh -RUN chmod +x /tmp/run_bench.sh - -ENTRYPOINT ["/tmp/run_bench.sh"] diff --git a/image/discourse_bench/run_bench.sh b/image/discourse_bench/run_bench.sh deleted file mode 100644 index a9a90f6fb..000000000 --- a/image/discourse_bench/run_bench.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# start Redis-Server -redis-server /etc/redis/redis.conf - -# start PostgreSQL -/etc/init.d/postgresql start - -# get latest source -git pull - -# install needed gems -sudo -E -u discourse bundle install --jobs $(($(nproc) - 1)) - -# start mailcatcher -mailcatcher --http-ip 0.0.0.0 - -# run the benchmark -sudo -E -u discourse ruby script/bench.rb diff --git a/image/discourse_fast_switch/Dockerfile b/image/discourse_fast_switch/Dockerfile deleted file mode 100644 index d900cd56e..000000000 --- a/image/discourse_fast_switch/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -# NAME: discourse/discourse_fast_switch -# VERSION: 1.5.0 - -# Allow to easily switch Ruby version in images that derive off this -FROM discourse/base:2.0.20180608 - -#LABEL maintainer="Sam Saffron \"https://twitter.com/samsaffron\"" - -RUN apt -y install ruby bison autoconf &&\ - cd /src && git clone https://github.com/sstephenson/ruby-build.git &&\ - /src/ruby-build/install.sh &&\ - sudo ruby-build 2.4.4 /usr/ruby_24 &&\ - cp -R /usr/ruby_24/bin/* /usr/local/bin/ &&\ - cp -R /usr/ruby_24/lib/* /usr/local/lib/ &&\ - cp -R /usr/ruby_24/share/* /usr/local/share/ &&\ - cp -R /usr/ruby_24/include/* /usr/local/include/ &&\ - apt -y remove ruby - -RUN cd / && ruby-build 2.5.1 /usr/ruby_25 - -ADD create_switch.rb /src/create_switch.rb - -RUN ruby /src/create_switch.rb diff --git a/image/discourse_fast_switch/create_switch.rb b/image/discourse_fast_switch/create_switch.rb deleted file mode 100644 index 294fb7815..000000000 --- a/image/discourse_fast_switch/create_switch.rb +++ /dev/null @@ -1,25 +0,0 @@ -require "fileutils" - -puts "-" * 100, "creating switch", "-" * 100 - -system("cd /var/www/discourse && git pull") - -%w[24 25].each do |v| - bin = "/usr/local/bin/use_#{v}" - - File.write(bin, < 0 - result["unicorn.max_rss"] = unicorns.max - result["unicorn.median_rss"] = median(unicorns) - end - - if sidekiqs.length > 0 - result["sidekiq.max_rss"] = sidekiqs.max - result["sidekiq.median_rss"] = median(sidekiqs) - end - result["total_mem_usage"] = container.stats["memory_stats"]["usage"] - - @prev_stats ||= {} - prev_stats = @prev_stats[container.name] - @prev_stats[container.name] = stats = container.stats - - if prev_stats - cpu_delta = stats["cpu_stats"]["system_cpu_usage"] - prev_stats["cpu_stats"]["system_cpu_usage"] - app_cpu_delta = stats["cpu_stats"]["cpu_usage"]["total_usage"] - prev_stats["cpu_stats"]["cpu_usage"]["total_usage"] - - result["cpu_usage"] = (app_cpu_delta.to_f / cpu_delta.to_f) * stats["cpu_stats"]["cpu_usage"]["percpu_usage"].length * 100.0 - end - - result - -end - -def containers - Docker::Container.all -end - -hostname = Docker.info["Name"] - -STDERR.puts "#{Time.now} Starting Monitor" - -while true - - begin - containers.each do |c| - - analyze_container(c).each do |k, v| - if v && v > 0 - $statsd.gauge "#{hostname}.#{c.name}.#{k}", v - end - end - end - rescue => e - STDERR.puts e - STDERR.puts e.backtrace - end - - sleep 60 -end -