Skip to content
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

Dockerization #115

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
84 changes: 84 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
FROM jruby:9.2.19.0-jdk11

# JRuby available at /opt/jruby/bin/jruby

RUN set -x && \
apt update && \
apt install -y ruby ruby-dev build-essential git

# MRI symlinked to /usr/bin/ruby (-> ruby2.5)

# Due (old) EventMachine we need to OpenSSL 1.0 bits
WORKDIR /tmp
RUN wget http://deb.debian.org/debian/pool/main/o/openssl1.0/libssl1.0.2_1.0.2u-1~deb9u1_amd64.deb
RUN dpkg -i libssl1.0.2_1.0.2u-1~deb9u1_amd64.deb
RUN wget http://deb.debian.org/debian/pool/main/o/openssl1.0/libssl1.0-dev_1.0.2u-1~deb9u1_amd64.deb
RUN dpkg -i libssl1.0-dev_1.0.2u-1~deb9u1_amd64.deb
RUN rm /tmp/*.deb

# MRI symlinked to /usr/bin/ruby (-> ruby2.5)

RUN echo 'gem: --no-document' >> /etc/gemrc

RUN /usr/bin/ruby -S gem install bundler -v '~> 2.1.4'

# Download Logstash to a known location to keep the image self-contained, instead of downloading on demand
# e.g. plugin publishing will than reference LOGSTASH_PATH=/usr/share/logstash by default
WORKDIR /usr/share
RUN wget https://artifacts.elastic.co/downloads/logstash/logstash-6.8.17.tar.gz
RUN tar -xzf logstash-6.8.17.tar.gz && rm logstash-6.8.17.tar.gz
RUN ln -s logstash-6.8.17 logstash

# Create jarvis (non-root) user for running the Ruby process
RUN addgroup --gid 1000 jarvis && \
adduser --uid 1000 --gid 1000 --gecos "" --disabled-password jarvis

USER jarvis

# git (ssh) commands should be able to authenticate with github.com
RUN mkdir ~/.ssh && ssh-keyscan -H github.com >> ~/.ssh/known_hosts
# a ssh keypair to be used to authenticate with github on git push-es
RUN ssh-keygen -t ed25519 -N "" -C "jarvis" -f ~/.ssh/id_ed25519
RUN echo && echo && \
echo "Generated a new key pair to be used with the github.com/elasticsearch-bot account" && \
echo "Please add the public key to the user\'s account (https://git.io/JlUMu):" && \
echo && echo && cat ~/.ssh/id_ed25519.pub && echo && echo

COPY --chown=jarvis:jarvis Gemfile* *.gemspec /usr/share/jarvis/

WORKDIR /usr/share/jarvis
RUN /usr/bin/ruby -S bundle install --deployment

# Restore system ruby to JRuby
USER root
RUN update-alternatives --install /usr/local/bin/ruby ruby /opt/jruby/bin/jruby 1

ENV JRUBY_OPTS="--dev -J-Xmx1g"

# We also assume Bundler installed for commands run by Jarvis
RUN /opt/jruby/bin/jruby -S gem install bundler -v '~> 2.1.4'

COPY --chown=jarvis:jarvis . /usr/share/jarvis/

#RUN ruby -v
# jruby 9.2.19.0 (2.5.8) 2021-06-15 55810c552b OpenJDK 64-Bit Server VM 11.0.11+9 on 11.0.11+9 [linux-x86_64]

#RUN env
# JRUBY_VERSION=9.2.19.0
# HOSTNAME=d80ab642f6dc
# HOME=/home/jarvis
# LANG=C.UTF-8
# BUNDLE_APP_CONFIG=/usr/local/bundle
# BUNDLE_SILENCE_ROOT_WARNING=1
# JRUBY_OPTS=--dev -J-Xmx1g
# JAVA_VERSION=11.0.11+9
# PATH=/usr/local/bundle/bin:/opt/jruby/bin:/usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
# JRUBY_SHA256=1f74885a2d3fa589fcbeb292a39facf7f86be3eac1ab015e32c65d32acf3f3bf
# GEM_HOME=/usr/local/bundle
# JAVA_HOME=/usr/local/openjdk-11
# PWD=/usr/share/jarvis

USER jarvis

WORKDIR /usr/share/jarvis
CMD /usr/bin/ruby bin/lita start --config lita_config.docker.rb
236 changes: 236 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
PATH
remote: .
specs:
lita-jarvis (0.4.0)
cabin
clamp (~> 1.0.0)
concurrent-ruby (~> 1.0)
down
faraday
faraday_middleware
gems
git (~> 1.2.9)
lita (~> 4.8)
lita-hipchat
lita-slack
mbox
mustache
octokit
open4
rfc2047
stud
travis
tzinfo

GEM
remote: https://rubygems.org/
specs:
activesupport (5.2.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
cabin (0.9.0)
call-me (0.0.2.3)
refining
clamp (1.0.1)
coderay (1.1.3)
concurrent-ruby (1.1.9)
diff-lcs (1.4.4)
down (5.2.2)
addressable (~> 2.5)
eventmachine (1.2.7)
faraday (1.5.1)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
faraday-patron (~> 1.0)
multipart-post (>= 1.2, < 3)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday_middleware (1.0.0)
faraday (~> 1.0)
faye-websocket (0.11.1)
eventmachine (>= 0.12.0)
websocket-driver (>= 0.5.1)
ffi (1.15.3)
flores (0.0.7)
formatador (0.3.0)
gems (1.2.0)
gh (0.18.0)
activesupport (~> 5.0)
addressable (~> 2.4)
faraday (~> 1.0)
faraday_middleware (~> 1.0)
multi_json (~> 1.0)
net-http-persistent (~> 2.9)
net-http-pipeline
git (1.2.9.1)
guard (2.17.0)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (>= 1.0.12, < 2.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-bundler (3.0.0)
bundler (>= 2.1, < 3)
guard (~> 2.2)
guard-compat (~> 1.1)
guard-compat (1.2.1)
guard-process (1.2.1)
guard-compat (~> 1.2, >= 1.2.1)
spoon (~> 0.0.1)
guard-rspec (4.7.3)
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
highline (2.0.3)
http_router (0.11.2)
rack (>= 1.0.0)
url_mount (~> 0.2.1)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
json (2.5.1)
json_pure (2.5.1)
launchy (2.4.3)
addressable (~> 2.3)
listen (3.5.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
lita (4.8.0)
bundler (>= 2.0)
faraday (>= 1.0)
http_router (>= 0.11)
i18n (>= 1.8)
ice_nine (>= 0.11)
multi_json (>= 1.15)
puma (>= 4.3)
rack (>= 2.2)
rb-readline (>= 0.5)
redis-namespace (>= 1.7)
thor (>= 1.0)
lita-hipchat (3.0.2)
lita (>= 4.4.3)
xmpp4r (>= 0.5.6)
lita-slack (1.8.0)
eventmachine
faraday
faye-websocket (>= 0.8.0)
lita (>= 4.7.1)
multi_json
lumberjack (1.2.8)
mbox (0.1.0)
call-me
method_source (1.0.0)
minitest (5.14.4)
multi_json (1.15.0)
multipart-post (2.1.1)
mustache (1.1.1)
nenv (0.3.0)
net-http-persistent (2.9.4)
net-http-pipeline (1.0.1)
nio4r (2.5.7)
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
octokit (4.21.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
open4 (1.3.4)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (4.0.6)
puma (5.3.2)
nio4r (~> 2.0)
pusher-client (0.6.2)
json
websocket (~> 1.0)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rake (13.0.6)
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
rb-readline (0.5.5)
redis (4.3.1)
redis-namespace (1.8.1)
redis (>= 3.0.4)
refining (0.0.5.5)
rfc2047 (0.3)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
rspec-wait (0.0.9)
rspec (>= 3, < 4)
ruby2_keywords (0.0.4)
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
shellany (0.0.1)
spoon (0.0.6)
ffi
stud (0.0.23)
thor (1.1.0)
thread_safe (0.3.6)
travis (1.10.0)
faraday (~> 1.0)
faraday_middleware (~> 1.0)
gh (~> 0.13)
highline (~> 2.0)
json_pure (~> 2.3)
launchy (~> 2.1, < 2.5.0)
pusher-client (~> 0.4)
tzinfo (1.2.9)
thread_safe (~> 0.1)
url_mount (0.2.1)
rack
websocket (1.2.9)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xmpp4r (0.5.6)

PLATFORMS
ruby

DEPENDENCIES
flores
guard
guard-bundler
guard-process
guard-rspec
lita-jarvis!
rack-test
rake
rspec (>= 3.0.0)
rspec-wait

BUNDLED WITH
2.1.4
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ sufficient.

You'll probably want a `lita_config.rb` if you want to have this connect to
Slack. The following is an example lita configuration. Put this in a file
called `lita_config.rb` in your git clone of this repo. You'll need to edit it to add github, slack, and other credential information.
called `lita_config.rb` in your git clone of this repo. You'll need to edit it to add github, slack, and other credential information.

DO NOT ADD THIS FILE TO GIT. It is too easy to accidentally commit credentials to git, and public git is not the right place to store credentials ;)

Expand Down Expand Up @@ -57,6 +57,23 @@ Lita.configure do |config|
end
```

### Running with Docker

0. Jarvis requires Redis (running on localhost:6379) as a pre-requisite!

1. Build the image `docker build -t jarvis:0.X.0 .`

2. Running the image requires 3 environmental variables for full functionality.
- **GITHUB_TOKEN** access token (from https://github.com/settings/tokens)
- **SLACK_TOKEN** https://api.slack.com/authentication/token-types#legacy_bot
- **GEM_HOST_API_KEY** the `rubygems_api_key` for pushing gems to rubygems.org

`docker run -d --env GITHUB_TOKEN=abcdef --env SLACK_TOKEN=ghijkl --env GEM_HOST_API_KEY=mnoprs --net=host jarvis:0.X.0`

Alternatively use the **docker-compose.yml** sample if Redis is not available locally:

e.g. `docker-compose --env-file ./.env.local up --build`

## Contributing

Patches, ideas, and bug reports welcome. :)
8 changes: 8 additions & 0 deletions bin/lita
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env ruby

require 'bundler/setup'

require 'lita'
require 'lita/cli'

Lita::CLI.start
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '3'

services:

jarvis:
build:
context: .
tty: true
environment:
- GITHUB_TOKEN=${GITHUB_TOKEN}
- SLACK_TOKEN=${SLACK_TOKEN}
- GEM_HOST_API_KEY=${GEM_HOST_API_KEY}
network_mode: host

redis:
image: docker.io/bitnami/redis:6.0
container_name: redis-server
environment:
- ALLOW_EMPTY_PASSWORD=yes
- REDIS_AOF_ENABLED=no
- REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL
ports:
- '6379:6379'
Loading