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

Alpine docker image #3063

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ deployment/cookbooks
manifest.yml
config/unicorn.rb
db/schema.rb
Dockerfile
13 changes: 0 additions & 13 deletions .github/FUNDING.yml

This file was deleted.

92 changes: 0 additions & 92 deletions .github/workflows/ci.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: build

on:
push:
branches: alpine

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
- name: install buildx
id: buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
version: latest
- name: login to docker hub
run: echo "${{ secrets.DOCKER_TOKEN }}" | docker login -u "${{ secrets.DOCKER_USER }}" --password-stdin
- name: get date
id: date
run: echo "::set-output name=date::$(date +'%Y%m%d')"
- name: build the image
run: |
docker buildx build --push \
--tag $GITHUB_REPOSITORY:latest \
--tag $GITHUB_REPOSITORY:${{steps.date.outputs.date}} \
--platform linux/amd64 .
87 changes: 87 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
FROM ruby:2.6-alpine AS builder

RUN apk --update add --no-cache \
build-base \
git \
zlib-dev \
yaml-dev \
openssl-dev \
gdbm-dev \
readline-dev \
ncurses-dev \
libffi-dev \
libxml2-dev \
libxslt-dev \
icu-dev \
mariadb-connector-c-dev \
libpq-dev \
sqlite-dev \
graphviz \
curl \
tzdata \
shared-mime-info \
iputils \
jq \
libc6-compat \
nodejs && \
mkdir /app && \
ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2

WORKDIR /app

COPY ["Gemfile", "Gemfile.lock", "./"]
COPY lib/gemfile_helper.rb lib/
COPY vendor/gems/ vendor/gems/
COPY .env.example .env

RUN umask 002 && git init && \
gem install bundler && \
bundle install --without test development -j 4 && \
rm -rf /usr/local/bundle/cache/*.gem && \
find /usr/local/bundle/gems/ -name "*.c" -delete && \
find /usr/local/bundle/gems/ -name "*.o" -delete

COPY . .

ENV LC_ALL=en_US.UTF-8 RAILS_ENV=production DATABASE_URL=sqlite3:/data/huginn.db

RUN bundle exec rails assets:precompile && rm -rf app/assets spec

# -------

FROM ruby:2.6-alpine

WORKDIR /app

RUN addgroup -g 1000 -S app \
&& adduser -u 1000 -S app -G app

RUN apk --update add --no-cache \
git zlib yaml libssl3 gdbm readline ncurses-libs libffi libxml2 libxslt icu \
sqlite-libs mariadb-connector-c libpq \
graphviz curl tzdata shared-mime-info iputils jq \
libc6-compat nodejs && \
mkdir /data && \
ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2 && \
chown -R app:app /data

COPY --from=builder /usr/local/bundle /usr/local/bundle
COPY --from=builder --chown=app:app /app /app

ENV LC_ALL=en_US.UTF-8 \
RAILS_ENV=production \
USE_GRAPHVIZ_DOT=dot \
RAILS_LOG_TO_STDOUT=true \
RAILS_SERVE_STATIC_FILES=true \
IP="0.0.0.0" PORT=3000 \
DATABASE_URL=sqlite3:/data/huginn.db \
APP_SECRET_TOKEN=changeme

USER app

EXPOSE 3000
VOLUME /data

HEALTHCHECK --interval=30s --timeout=3s CMD curl -f http://localhost:3000/ || exit 1

CMD ["bundle", "exec", "foreman", "start"]
26 changes: 4 additions & 22 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ gem 'forecast_io', '~> 2.0.0' # WeatherAgent
gem 'rturk', '~> 2.12.1' # HumanTaskAgent
gem 'erector', github: 'dsander/erector', branch: 'rails6'
gem 'hipchat', '~> 1.2.0' # HipchatAgent
gem 'mini_racer', '~> 0.2.4' # JavaScriptAgent
# gem 'mini_racer', '~> 0.2.4' # JavaScriptAgent
gem 'xmpp4r', '~> 0.5.6' # JabberAgent
gem 'mqtt' # MQTTAgent
gem 'slack-notifier', '~> 1.0.0' # SlackAgent
Expand Down Expand Up @@ -128,6 +128,9 @@ gem 'spectrum-rails'
gem 'execjs', '~> 2.7.0'
gem 'typhoeus', '~> 1.3.1'
gem 'uglifier', '~> 2.7.2'
gem 'sqlite3'
gem 'pg'
gem 'mysql2'
gem 'bootsnap', require: false

group :development do
Expand Down Expand Up @@ -184,27 +187,6 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
# BSD systems require rb-kqueue for "listen" to avoid polling for changes.
gem 'rb-kqueue', '>= 0.2', require: /bsd|dragonfly/i === RbConfig::CONFIG['target_os']


on_heroku = ENV['ON_HEROKU'] ||
ENV['HEROKU_POSTGRESQL_ROSE_URL'] ||
ENV['HEROKU_POSTGRESQL_GOLD_URL'] ||
File.read(File.join(File.dirname(__FILE__), 'Procfile')) =~ /intended for Heroku/

ENV['DATABASE_ADAPTER'] ||=
if on_heroku
'postgresql'
else
'mysql2'
end

if_true(ENV['DATABASE_ADAPTER'].strip == 'postgresql') do
gem 'pg', '~> 1.1.3'
end

if_true(ENV['DATABASE_ADAPTER'].strip == 'mysql2') do
gem 'mysql2' , "~> 0.5.2"
end

GemfileHelper.parse_each_agent_gem(ENV['ADDITIONAL_GEMS']) do |args|
gem *args
end
14 changes: 6 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ GEM
actionmailer (>= 3.2)
letter_opener (~> 1.0)
railties (>= 3.2)
libv8 (7.3.492.27.1)
liquid (4.0.3)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
Expand All @@ -447,15 +446,13 @@ GEM
mini_magick (4.11.0)
mini_mime (1.1.2)
mini_portile2 (2.6.1)
mini_racer (0.2.9)
libv8 (>= 6.9.411)
minitest (5.15.0)
mqtt (0.3.1)
msgpack (1.4.2)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
mysql2 (0.5.2)
mysql2 (0.5.3)
naught (1.1.0)
nenv (0.3.0)
net-ftp-list (3.2.8)
Expand Down Expand Up @@ -503,7 +500,7 @@ GEM
rack
orm_adapter (0.5.0)
os (1.1.4)
pg (1.1.3)
pg (1.2.3)
poltergeist (1.8.1)
capybara (~> 2.1)
cliver (~> 0.3.1)
Expand Down Expand Up @@ -661,6 +658,7 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
sshkit (1.18.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
Expand Down Expand Up @@ -777,10 +775,9 @@ DEPENDENCIES
listen (~> 3.0.5)
loofah (~> 2.0)
mini_magick (>= 4.9.4)
mini_racer (~> 0.2.4)
mqtt
multi_xml
mysql2 (~> 0.5.2)
mysql2
net-ftp-list (~> 3.2.8)
nokogiri (>= 1.10.8)
omniauth
Expand All @@ -789,7 +786,7 @@ DEPENDENCIES
omniauth-google-oauth2 (>= 0.8.0)
omniauth-tumblr
omniauth-twitter
pg (~> 1.1.3)
pg
poltergeist
pry-byebug
pry-rails
Expand All @@ -816,6 +813,7 @@ DEPENDENCIES
spring-commands-rspec (~> 1.0.4)
spring-watcher-listen (~> 2.0.1)
sprockets (~> 3.7.2)
sqlite3
tumblr_client!
twilio-ruby (~> 5.62.0)
twitter!
Expand Down
50 changes: 1 addition & 49 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,2 @@
###############################
# DEVELOPMENT #
###############################

# Procfile for development using the new threaded worker (scheduler, twitter stream and delayed job)
web: bundle exec rails server -p ${PORT-3000} -b ${IP-0.0.0.0}
web: bundle exec rake db:migrate && bundle exec rails server -p $PORT
jobs: bundle exec rails runner bin/threaded.rb

# Old version with separate processes (use this if you have issues with the threaded version)
# web: bundle exec rails server
# schedule: bundle exec rails runner bin/schedule.rb
# twitter: bundle exec rails runner bin/twitter_stream.rb
# dj: bundle exec script/delayed_job run

###############################
# PRODUCTION #
###############################

# You need to copy or link config/unicorn.rb.example to config/unicorn.rb for both production versions.
# Have a look at the deployment guides, if you want to set up huginn on your server:
# https://github.com/huginn/huginn/doc

# Using the threaded worker (consumes less RAM but can run slower)
# web: bundle exec unicorn -c config/unicorn.rb
# jobs: bundle exec rails runner bin/threaded.rb

# Old version with separate processes (use this if you have issues with the threaded version)
# web: bundle exec unicorn -c config/unicorn.rb
# schedule: bundle exec rails runner bin/schedule.rb
# twitter: bundle exec rails runner bin/twitter_stream.rb
# dj: bundle exec script/delayed_job run

###############################
# Multiple DelayedJob workers #
###############################
# Per default Huginn can just run one agent at a time. Using a lot of agents or calling slow
# external services frequently might require more DelayedJob workers (an indicator for this is
# a backlog in your 'Job Management' page).
# Every uncommented line starts an additional DelayedJob worker. This works for development, production
# and for the threaded and separate worker processes. Keep in mind one worker needs about 300MB of RAM.
#
#dj2: bundle exec script/delayed_job -i 2 run
#dj3: bundle exec script/delayed_job -i 3 run
#dj4: bundle exec script/delayed_job -i 4 run
#dj5: bundle exec script/delayed_job -i 5 run
#dj6: bundle exec script/delayed_job -i 6 run
#dj7: bundle exec script/delayed_job -i 7 run
#dj8: bundle exec script/delayed_job -i 8 run
#dj9: bundle exec script/delayed_job -i 9 run
#dj10: bundle exec script/delayed_job -i 10 run
Loading