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"
gem "activerecord", "3.2.13"
gem "activerecord"
gem "mysql2"
gem "serialport"
gem "state_pattern"

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
class CreatesReadings < ActiveRecord::Migration
class CreatesReadings < ActiveRecord::Migration[4.2]
def change
create_table :readings do |t|
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