-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDockerfile
76 lines (56 loc) · 1.45 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
FROM ubuntu:14.04
# Set ruby version.
ENV RUBY_VERSION 2.1.5
# Set app's location.
ENV APP /grounds
# Add user dev.
RUN useradd dev
# Install dependencies.
RUN apt-get update -qq && \
apt-get install -qy \
git \
curl \
build-essential \
libxslt1-dev \
libxml2-dev \
libcurl4-openssl-dev \
libsqlite3-dev \
nodejs \
phantomjs
# Install ruby.
RUN curl -sL http://s3.amazonaws.com/pkgr-buildpack-ruby/current/ubuntu-14.04/ruby-$RUBY_VERSION.tgz -o - | \
tar xzf - -C /usr/local
# Configure home and gem path for user dev.
ENV HOME /home/dev
ENV GEM_HOME $HOME/.gem/ruby
ENV GEM_PATH $GEM_HOME
ENV PATH $PATH:$GEM_PATH/bin
# Create home and gem path.
RUN mkdir -p $GEM_PATH/cache
# Default configuration for gem installation.
RUN echo "gem: --no-document" > $HOME/.gemrc
# Configure pry.
COPY pry/.pryrc $HOME/.pryrc
# Change home and dev path owner.
RUN chown -R dev:dev $HOME
# Set user as dev.
USER dev
# Install bundler.
RUN gem install bundler
# Copy the Gemfile and Gemfile.lock into the image.
COPY Gemfile $APP/
COPY Gemfile.lock $APP/
# Install ruby gems.
RUN cd $APP && bundle install
# Everything up to here was cached. This includes
# the bundle install, unless the Gemfiles changed.
# Now copy the app into the image.
COPY . $APP
# Set user as root.
USER root
# Changes app's files owner.
RUN chown -R dev:dev $APP
# Set user as dev.
USER dev
# Set the final working dir to the Rails app's location.
WORKDIR $APP