Dockerized

This commit is contained in:
Aart van Halteren
2018-03-19 16:18:56 +01:00
parent 619107a303
commit 625fd06a0f
6 changed files with 74 additions and 29 deletions

20
Dockerfile Normal file
View File

@@ -0,0 +1,20 @@
FROM ruby:2.4.3
ENV BUILD_PACKAGES="apt-utils build-essential curl less nodejs sudo wget zsh libmysqlclient-dev ruby-serialport libserialport-dev"
# throw errors if Gemfile has been modified since Gemfile.lock
RUN \
bundle config --global frozen 1
WORKDIR /usr/src/app
COPY Gemfile Gemfile.lock ./
RUN \
apt-get update -qq && \
apt-get install -y $BUILD_PACKAGES && \
bundle install
COPY . .
CMD ["cd /usr/src/app && ruby smartmeter.rb"]

View File

@@ -1,6 +1,6 @@
source "https://rubygems.org" source "https://rubygems.org"
gem "activerecord", "3.2.13" gem "activerecord"
gem "mysql2" gem "mysql2"
gem "serialport" gem "serialport"
gem "state_pattern" gem "state_pattern"

View File

@@ -1,40 +1,48 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
activemodel (3.2.13) activemodel (5.1.5)
activesupport (= 3.2.13) activesupport (= 5.1.5)
builder (~> 3.0.0) activerecord (5.1.5)
activerecord (3.2.13) activemodel (= 5.1.5)
activemodel (= 3.2.13) activesupport (= 5.1.5)
activesupport (= 3.2.13) arel (~> 8.0)
arel (~> 3.0.2) activesupport (5.1.5)
tzinfo (~> 0.3.29) concurrent-ruby (~> 1.0, >= 1.0.2)
activesupport (3.2.13) i18n (~> 0.7)
i18n (= 0.6.1) minitest (~> 5.1)
multi_json (~> 1.0) tzinfo (~> 1.1)
arel (3.0.2) arel (8.0.0)
builder (3.0.4) concurrent-ruby (1.0.5)
daemons (1.1.9) daemons (1.2.6)
i18n (0.6.1) et-orbi (1.0.9)
mail (2.6.1) tzinfo
mime-types (>= 1.16, < 3) i18n (0.9.5)
mime-types (2.3) concurrent-ruby (~> 1.0)
multi_json (1.7.7) mail (2.7.0)
mysql2 (0.3.11) mini_mime (>= 0.1.1)
rufus-scheduler (2.0.19) mini_mime (1.0.0)
tzinfo (>= 0.3.23) minitest (5.11.3)
serialport (1.1.0) mysql2 (0.4.10)
state_pattern (2.0.1) rufus-scheduler (3.4.2)
tzinfo (0.3.37) et-orbi (~> 1.0)
serialport (1.3.1)
state_pattern (2.0.2)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
PLATFORMS PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
activerecord (= 3.2.13) activerecord
daemons daemons
mail mail
mysql2 mysql2
rufus-scheduler rufus-scheduler
serialport serialport
state_pattern state_pattern
BUNDLED WITH
1.16.1

View File

@@ -1,5 +1,6 @@
host: 'localhost' host: 'smartmeter_db'
adapter: 'mysql2' adapter: 'mysql2'
database: 'smartmeter' database: 'smartmeter'
username: 'root' username: 'root'
password: 'rootme'
pool: 5 pool: 5

View File

@@ -1,4 +1,4 @@
class CreatesReadings < ActiveRecord::Migration class CreatesReadings < ActiveRecord::Migration[4.2]
def change def change
create_table :readings do |t| create_table :readings do |t|
t.float :total_kwh_consumed_high t.float :total_kwh_consumed_high

16
docker-compose.yml Normal file
View File

@@ -0,0 +1,16 @@
version: '3'
services:
db:
container_name: smartmeter_db
image: mysql
environment:
MYSQL_ROOT_PASSWORD: rootme
MYSQL_DATABASE: smartmeter
smartmeter:
container_name: smartmeter
build: .
command: 'ruby ./smartmeter.rb'
volumes:
- .:/usr/src/app
depends_on:
- db