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

Add docker support #24

Closed
Closed
Show file tree
Hide file tree
Changes from 8 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
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.dockerignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore the dockerignore? what's this file for?

Copy link
Contributor Author

@while1malloc0 while1malloc0 Jan 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An overview of the dockerignore file is here: https://docs.docker.com/engine/reference/builder/#/dockerignore-file, but in short it matches glob patterns and excludes them from any COPY and ADD instructions. Adding the dockerignore file to itself is basically saying "don't copy the dockerignore when you copy the rest of the directory over". The actual Dockerfile should probably be here too. There's not much gained by ignoring them, it just feels a bit neater to me.

edit: added the Dockerfile to the ignore

Dockerfile
.byebug_history
/log/*
/tmp/*
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM amazonlinux

RUN yum install -y ruby23-devel git gcc gcc-c++ postgresql-devel zlib-devel

RUN gem install bundler

ENV INSTALL_PATH /test_track

RUN mkdir -p $INSTALL_PATH

WORKDIR $INSTALL_PATH

ENV BUNDLE_PATH /bundle
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ The list of requirements to configure a TestTrack server are:
1. `bundle exec rake db:setup`
1. `bundle exec rails server`

#### Option 3: Deploy with Docker
1. `cp .env.dist .env`
1. `docker-compose up`

#### Either way:

At this point, you've got a working installation and can proceed to setting up the [Rails client](https://github.com/Betterment/test_track_rails_client) in order to create your first split.
Expand Down
33 changes: 33 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '2'

services:
db:
restart: 'always'
image: 'postgres:9.5'
ports:
- '5432:5432'
volumes:
- 'db:/var/lib/postgresql/data'

app:
restart: 'always'
depends_on:
- 'db'
build: .
ports:
- '3000:3000'
volumes:
- '.:/test_track'
volumes_from:
- bundler_cache
command: ./script/serve
environment:
- DATABASE_URL=postgresql://postgres@db/test_track_development
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't block you merging, but I'm curious why we went this direction? It's now not configurable without forking the repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samandmoore can give his perspective, but basically the thinking is that if we're looking at this for local development then the user will have the repo cloned anyway, so it's not a problem to change this value. Also, this keeps all of the docker configuration in one place instead of spreading it to a .env file, which would potentially be used by a Rails project using dotenv.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so this is strictly not for actually running the containerized server in a in a non-local environment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, at the moment. I figure that if someone wants to run TT in production then they'll probably either fork the repo or just run the TT container outside of compose.


bundler_cache:
image: busybox
volumes:
- /bundle

volumes:
db:
7 changes: 7 additions & 0 deletions script/serve
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

echo "Checking for installed dependencies"
bundle check || bundle install --binstubs

echo "Starting Puma"
bin/puma -C config/puma.rb