Skip to content

Instantly share code, notes, and snippets.

@azechi
Created April 10, 2020 13:40
Show Gist options
  • Save azechi/fefb0ee8266da1d4cfed018c0884410c to your computer and use it in GitHub Desktop.
Save azechi/fefb0ee8266da1d4cfed018c0884410c to your computer and use it in GitHub Desktop.
docker discordrb
require 'discordrb'
bot = Discordrb::Bot.new token: ENV["TOKEN"]
bot.message(with_text: 'Ping!') do |event|
event.respond 'Pong!'
end
require 'thread'
Signal.trap(:TERM) do
Thread.new { bot.stop }
end
bot.run
FROM ruby AS builder
COPY Gemfile Gemfile.lock ./
RUN env DEBCONF_NOWARNINGS=yes bundle install -j "$(getconf _NPROCESSORS_ONLN)" --retry 3 \
&& rm -rf /usr/local/bundle/cache/*.gem \
&& find /usr/local/bundle/gems/ -name '*.c' -delete \
&& find /usr/local/bundle/gems/ -name '*.o' -delete
# app
FROM ruby:slim
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends libsodium-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /usr/local/bundle /usr/local/bundle
COPY ./app .
CMD ["ruby", "bot.rb"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment