forked from seven1m/onebody
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
70 lines (56 loc) · 2.08 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
FROM ubuntu:14.04
# install build tools
RUN apt-get update
RUN apt-get install -y -q wget vim build-essential curl libreadline-dev libcurl4-openssl-dev nodejs git libmysqlclient-dev imagemagick mysql-client
RUN apt-get clean
# install Ruby
RUN apt-get install -y software-properties-common
RUN apt-add-repository -y ppa:brightbox/ruby-ng
RUN apt-get update
RUN apt-get install -y ruby2.1 ruby2.1-dev
# manual compile way, leaving this just in case...
#WORKDIR /tmp
#RUN wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz && tar xzvf ruby-2.1.2.tar.gz
#WORKDIR /tmp/ruby-2.1.2
#RUN ./configure --disable-install-doc && make install
#RUN rm -rf /tmp/ruby-2.1.2*
RUN gem install bundler --no-rdoc --no-ri
# set up user
RUN adduser --gecos "" --disabled-password --home=/home/onebody onebody
USER onebody
ENV HOME /home/onebody
ENV GEM_HOME /home/onebody/.gems
# set default rails env
ENV RAILS_ENV production
# add Gemfile first, then bundle install; this will make our builds cleaner
ADD .ruby-version /var/www/onebody/.ruby-version
ADD Gemfile /var/www/onebody/Gemfile
ADD Gemfile.lock /var/www/onebody/Gemfile.lock
USER root
RUN chown -R onebody /var/www/onebody
# install gems
USER onebody
WORKDIR /var/www/onebody
RUN bundle install
RUN gem install thin --no-rdoc --no-ri
# add rest of source
USER root
ADD . /var/www/onebody
RUN chown -R onebody /var/www/onebody
# allow onebody user to run special 'chown_data' script as root
# workaround for volumes readonly to non-root users
RUN echo "ALL ALL=NOPASSWD: /var/www/onebody/script/docker/chown_data" > /etc/sudoers.d/chown_data
# copy scripts
RUN echo "#!/bin/bash\n\n/var/www/onebody/script/docker/server \$@" > /server && chmod +x /server
RUN echo "#!/bin/bash\n\n/var/www/onebody/script/docker/console \$@" > /console && chmod +x /console
RUN echo "#!/bin/bash\n\n/var/www/onebody/script/docker/worker \$@" > /worker && chmod +x /worker
# set up shared directories
USER onebody
# compile assets
WORKDIR /var/www/onebody
RUN bundle exec rake assets:precompile
# share port
EXPOSE 3000
# serve assets with rack
ENV SERVE_ASSETS true
CMD /server