DEV: Remove unused docker images (#915)
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
This commit is contained in:
parent
aeb28ff600
commit
6c5e2d1412
7 changed files with 0 additions and 222 deletions
image
|
@ -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.
|
||||
|
|
|
@ -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 <mail@gerhard-schlager.at>"
|
||||
|
||||
# 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"]
|
|
@ -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
|
|
@ -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
|
|
@ -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, <<RUBY)
|
||||
#!/usr/ruby_24/bin/ruby
|
||||
|
||||
Dir.glob('/usr/ruby_#{v}/bin/*').each do |file|
|
||||
`rm -f /usr/local/bin/\#{File.basename(file)}`
|
||||
`cd /usr/local/bin && ln -s \#{file}`
|
||||
end
|
||||
|
||||
RUBY
|
||||
|
||||
system("chmod +x #{bin}")
|
||||
system("use_#{v} && gem update --system && gem install bundler --force")
|
||||
system(
|
||||
"use_#{v} && cd /var/www/discourse && sudo -u discourse bundle install --deployment --jobs $(($(nproc) - 1)) --without test development",
|
||||
)
|
||||
end
|
|
@ -1,13 +0,0 @@
|
|||
# Used to gather information about CPU and memory
|
||||
# reporting it back to statsd
|
||||
|
||||
# samsaffron/discourse_monitor
|
||||
# version 0.0.2
|
||||
|
||||
FROM samsaffron/discourse_base:1.0.7
|
||||
#LABEL maintainer="Sam Saffron \"https://twitter.com/samsaffron\""
|
||||
|
||||
ADD src/monitor.rb src/monitor.rb
|
||||
RUN gem install statsd-ruby docker-api
|
||||
|
||||
CMD ruby src/monitor.rb
|
|
@ -1,98 +0,0 @@
|
|||
require 'statsd-ruby'
|
||||
require 'docker'
|
||||
|
||||
$statsd = Statsd.new '10.0.0.1', 8125
|
||||
|
||||
module Docker
|
||||
class CloseConnectionError < StandardError; end
|
||||
class Container
|
||||
def name
|
||||
info["Names"].first[1..-1]
|
||||
end
|
||||
|
||||
def stats
|
||||
path = path_for(:stats)
|
||||
|
||||
result = nil
|
||||
|
||||
streamer = lambda do |chunk, remaining, total|
|
||||
result ||= chunk
|
||||
raise CloseConnectionError if result
|
||||
end
|
||||
options = { response_block: streamer }.merge(connection.options)
|
||||
|
||||
Excon.get(connection.url + path[1..-1], options) rescue CloseConnectionError
|
||||
|
||||
Docker::Util.parse_json(result)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def median(array)
|
||||
sorted = array.sort
|
||||
len = sorted.length
|
||||
return ((sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0).to_i
|
||||
end
|
||||
|
||||
|
||||
def analyze_container(container)
|
||||
|
||||
data = container.exec(["ps", "-eo", "rss,args"])[0].join("\n").split("\n")
|
||||
unicorns = data.grep(/unicorn/).map(&:to_i)
|
||||
sidekiqs = data.grep(/sidekiq/).map(&:to_i)
|
||||
|
||||
result = {}
|
||||
|
||||
if unicorns.length > 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
|
||||
|
Loading…
Add table
Reference in a new issue