-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile
68 lines (52 loc) · 2.01 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
FROM ruby:2.4.4 as base
WORKDIR /usr/src/app
RUN /bin/echo -e "deb http://archive.debian.org/debian stretch main\ndeb http://archive.debian.org/debian-security stretch/updates main\n" > /etc/apt/sources.list
# Install non-ruby dependencies
RUN apt update && apt install -y nodejs curl libcurl3 libcurl3-openssl-dev openjdk-8-jdk
# Copy source code to container
COPY . .
############################
# Development Build Stage
############################
FROM base as development
# Set the RAILS_ENV to production. This affects several things in Rails.
ENV RAILS_ENV=development
# Update the bundle from Gemfile to pull in any newer versions not committed to
# Gemfile.lock yet.
RUN bundle update
# Install fresh jetty instance
RUN bundle exec rake jetty:clean
EXPOSE 3000
# Run several commmands to start the development server:
# 1. bundle exec rake jetty:config
# Copies jetty configuration from config/jetty.yml to jetty instance,
# which is installed in the 'base' build stage.
# 2. bundle exec rake jetty:start
# Starts jetty server
# 3. bundle exec rake db:migrate
# Runs databae migrations, if any need to be run.
# 4. bundle exec rails s -b 0.0.0.0
# Starts the Rails server.
CMD bundle exec rake jetty:config \
bundle exec rake jetty:start && \
bundle exec rake db:migrate && \
bundle exec rails s -b 0.0.0.0
############################
# Production Build Stage
############################
FROM base as production
# Set the RAILS_ENV to production. This affects several things in Rails.
ENV RAILS_ENV=production
# TODO: is this needed?
RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Update the bundle from Gemfile.lock (don't update the Bundle in production)
RUN bundle install
# Run commands atomically to start production AAPB web application:
# 1. bundle exec rake jetty:start
# Starts the jetty server
# 2. bundle exec rails s -b 0.0.0.0
# Starts the Rails server.
CMD bundle exec rake jetty:start && \
bundle exec rails s -b 0.0.0.0