-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (41 loc) · 1.64 KB
/
Dockerfile
File metadata and controls
54 lines (41 loc) · 1.64 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
FROM ruby:2.7.2
RUN apt-get update -yqq
RUN apt-get install -yqq --no-install-recommends less vim postgresql-client rsync
# Install NodeJS, the default version for Debian 9 is NodeJS 4.8.x, which is not supported by Webpacker.
# RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
# RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get install -yqq nodejs
RUN npm install yarn -g
ARG rails_env="production"
ARG bundle_without="development:test"
ENV RAILS_ENV=${rails_env}
ENV BUNDLE_WITHOUT=${bundle_without}
ENV BUNDLER_VERSION=2.1.4
RUN gem install bundler -v 2.1.4
# COPY Gemfile* /usr/src/app/
COPY . /usr/src/app
WORKDIR /usr/src/app
RUN bundle install --jobs=4
# TODO: Document the specific scenario why this is necessary
# See https://nickjanetakis.com/blog/dealing-with-lock-files-when-using-ruby-node-and-elixir-with-docker
# RUN mkdir -p /tmp/generated
# RUN cp Gemfile.lock /tmp/generated
# COPY . /usr/src/app
RUN if [ "$RAILS_ENV" = "production" ]; \
then bundle exec rake assets:precompile; \
else yarn install; \
fi
# Make sure the generated files are owned by the original user so that when we copy them back,
# they will be synced back to the OS under the same user.
ARG uid=1000
ARG gid=1000
USER ${uid}:${gid}
# See https://nickjanetakis.com/blog/dealing-with-lock-files-when-using-ruby-node-and-elixir-with-docker
RUN mkdir -p /tmp/generated
RUN cp Gemfile.lock /tmp/generated
RUN cp yarn.lock /tmp/generated
RUN cp -Rp node_modules /tmp/generated
USER root:root
ENTRYPOINT ["/usr/src/app/docker-container-entry.sh"]
# CMD ["unicorn", "-c", "./config/unicorn.rb"]