-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
57 lines (42 loc) · 1.57 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
# See https://intercityup.com/blog/how-i-build-a-docker-image-for-my-rails-app.html
# See https://intercityup.com/blog/deploy-rails-app-including-database-configuration-env-vars-assets-using-docker.html
FROM phusion/passenger-full
# Set correct environment variables.
ENV HOME /root
ENV RAILS_ENV production
RUN apt update
RUN apt install -y sudo
RUN apt-get install -y tzdata
RUN sudo apt-get install -y build-essential libcurl4-openssl-dev
RUN apt install -y redis-server
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]
# Start Nginx / Passenger
ARG RAILS_VER
ARG GIT_URL
COPY rubyenv /root/
RUN bash /root/rubyenv
RUN rm -f /etc/service/nginx/down
# Remove the default site
RUN rm /etc/nginx/sites-enabled/default
# Add the nginx info
ADD nginx.conf /etc/nginx/sites-enabled/webapp.conf
# Add the rails-env configuration file so Nginx preserves the environment variables listed
ADD rails-env.conf /etc/nginx/main.d/rails-env.conf
# Prepare folders
RUN mkdir /home/app/webapp
# Add startup script to run during container startup
RUN mkdir -p /etc/my_init.d
ADD startup.sh /etc/my_init.d/startup.sh
RUN chmod +x /etc/my_init.d/*.sh
RUN apt-get install git
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
copy script.sh /home/app/
RUN bash /home/app/script.sh
WORKDIR /home/app/webapp/
COPY ./database.yml /home/app/webapp/config
RUN chown -R app:app /home/app/webapp
RUN sudo -u app bundle install --deployment --without development test
RUN sudo -u app RAILS_ENV=production bundle exec rake assets:precompile
RUN gem install tzinfo-data