Skip to content

Commit a4444db

Browse files
committed
Initial commit
0 parents  commit a4444db

8 files changed

+64
-0
lines changed

.env.db

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MYSQL_ALLOW_EMPTY_PASSWORD=yes

.env.web

Whitespace-only changes.

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM ruby:2.3.1
2+
MAINTAINER Joao Costa <[email protected]>
3+
4+
RUN apt-get update -qq && apt-get install -y build-essential nodejs mysql-client vim
5+
6+
RUN mkdir /myapp
7+
WORKDIR /myapp
8+
9+
COPY Gemfile Gemfile
10+
COPY Gemfile.lock Gemfile.lock
11+
12+
RUN bundle install
13+
14+
ADD . /myapp

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source 'https://rubygems.org'
2+
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'

Gemfile.lock

Whitespace-only changes.

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Sample implementation of running a rails app + db in docker
2+
3+
## Initialize rails app
4+
docker-compose run web rails new . --force --database=mysql --skip-bundle
5+
6+
## Configure database
7+
sed -i.bak s/localhost/db/g config/database.yml
8+
9+
## Edit Gemfile and update any required gems
10+
vi Gemfile
11+
12+
## Install the bundle in a reusable docker image
13+
docker-compose build
14+
15+
## Run application
16+
docker-compose up -d

docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: '2'
2+
services:
3+
web:
4+
build: .
5+
volumes:
6+
- .:/myapp
7+
ports:
8+
- "3000:3000"
9+
links:
10+
- db
11+
env_file:
12+
- '.env.web'
13+
entrypoint: /myapp/rails-entrypoint.sh
14+
command: rails s -p 3000 -b '0.0.0.0'
15+
db:
16+
image: mariadb
17+
ports:
18+
- "13306:3306"
19+
env_file:
20+
- '.env.db'
21+
volumes:
22+
- /root/mysql_alertsapi:/var/lib/mysql

rails-entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
if [ -f tmp/pids/server.pid ]; then
6+
rm tmp/pids/server.pid
7+
fi
8+
9+
exec bundle exec "$@"

0 commit comments

Comments
 (0)