This repository was archived by the owner on Dec 19, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (50 loc) · 1.72 KB
/
Dockerfile
File metadata and controls
71 lines (50 loc) · 1.72 KB
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
FROM ruby:2.7.1-alpine AS builder
LABEL maintainer="Mike Rogers <me@mikerogers.io>"
RUN apk add --no-cache \
#
# required
build-base libffi-dev \
nodejs yarn tzdata \
postgresql-dev zlib-dev libxml2-dev libxslt-dev readline-dev bash \
# Nice to haves
git vim \
#
# Fixes watch file issues with things like HMR
libnotify-dev
FROM builder as development
# Add the current apps files into docker image
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install any extra dependencies via Aptfile - These are installed on Heroku
# COPY Aptfile /usr/src/app/Aptfile
# RUN apk add --update $(cat /usr/src/app/Aptfile | xargs)
ENV PATH /usr/src/app/bin:$PATH
# Install latest bundler
RUN bundle config --global silence_root_warning 1
EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0", "-p", "3000"]
FROM development AS shared-production
COPY Gemfile /usr/src/app
COPY .ruby-version /usr/src/app
COPY Gemfile.lock /usr/src/app
COPY package.json /usr/src/app
COPY yarn.lock /usr/src/app
FROM shared-production AS ci
# Install Ruby Gems
RUN bundle check || bundle install --jobs=$(nproc)
# Install Yarn Libraries
RUN yarn install --check-files
# Copy the rest of the app
COPY . /usr/src/app
CMD ["bundle", "exec", "rspec"]
FROM shared-production AS production
# Install Ruby Gems
RUN bundle config set deployment 'true'
RUN bundle config set without 'development:test'
RUN bundle check || bundle install --jobs=$(nproc)
# Install Yarn Libraries
RUN yarn install --check-files
# Copy the rest of the app
COPY . /usr/src/app
# Compile the assets
RUN RAILS_SERVE_STATIC_FILES=enabled SECRET_KEY_BASE=secret-key-base RAILS_ENV=production RACK_ENV=production NODE_ENV=production bundle exec rake assets:precompile