-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.dev
54 lines (40 loc) · 1.69 KB
/
Dockerfile.dev
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
# NOTE:
# 1. Combine the apt-get update and apt-get install commands into a single RUN instruction
# This ensures that whenever you change the packages being installed, you get the latest
# package/repository information at the same time not cached information.
FROM ruby:3.0.0
LABEL maintainer="[email protected]"
# Allow apt to work with https-based sources e.g node & yarn
RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \
apt-transport-https
# Ensure more up to date version of node
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
# Ensure latest packages for yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
# Install system packages
RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \
nodejs \
yarn
ENV APP_HOME /usr/src/app
RUN mkdir -p $APP_HOME
WORKDIR $APP_HOME
# Remove existing running server
COPY bin/docker-entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/docker-entrypoint.sh
# Gemfile Caching Trick:
# Separate the copying of files that should trigger a rebuild of our gems from those that shouldn’t.
# This avoids rebuilding the image for these steps (and hence running bundle install) when other unrelated
# files are changed.
COPY Gemfile $APP_HOME/
COPY Gemfile.lock $APP_HOME/
RUN bundle install
# Yarn Caching Trick:
COPY package.json $APP_HOME/
COPY yarn.lock $APP_HOME/
RUN yarn install
# Copy the app repo
COPY . $APP_HOME
ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]
# Default command to run when a container is started from the image.
CMD ["bin/rails", "s", "-b", "0.0.0.0"]