-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
60 lines (49 loc) · 2.24 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
FROM ruby:3.0.0-slim as ruby-base
# Default env vars (applies to containers made from this image)
# Can be overriden at run-time with -e
ENV APP_DIR=/app
# Sets the path to allow running bundler binstubs
ENV PATH="${PATH}:${APP_DIR}/bin"
ENV BUNDLE_PATH=/bundle/vendor
ENV GEM_PATH=/bundle/vendor
ENV GEM_HOME=/bundle/vendor
ENV NODE_VERSION 14.15.4
ENV YARN_VERSION 1.22.5
# Build args - shell variables assigned at build time.
# can be overridden at build time with --build-arg
ARG BUNDLER_VERSION=2.2.15
ARG RAILS_ENV=development
ARG BUNDLE_PATH=/bundle/vendor
# Here are the dependencies we need to build our app (and install Rails)
# This example installs the PostgreSQL and SQLite libraries (two commonly used databases in Rails apps).
#
# We're also installing the latest nodejs and yarn packages here for webpacker.
RUN apt-get update -qq && apt-get install -yq curl gnupg2 lsb-release \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash \
&& curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt-get update -qq && apt-get install -yq build-essential git ruby-dev libpq-dev \
libsqlite3-dev postgresql-client nodejs shared-mime-info \
&& apt-get install -yq yarn \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN gem install bundler -v $BUNDLER_VERSION
# This creates the APP_DIR that we defined earler
# and sets it as the default directory in the container created from this image
RUN mkdir ${APP_DIR}
WORKDIR ${APP_DIR}
#
# Here, we copy our gem and npm dependency files into our image.
# We do this here so that when we change dependencies and a rebuild is needed, we can
# leverage the build cache (everything above this point will not be rebuilt).
#
COPY Gemfile Gemfile.lock ./
RUN bundle check || bundle install
COPY package.json yarn.lock ./
RUN yarn install
# Copy all of our app in to the image (use .dockerignore to omit patterns)
COPY . ./
# Declares that we intend to listen on port 3000. This is a declarative documentation instruction
# that doesn't actually publish or open a port.
EXPOSE 3000
# This gets executed when we run a container made from this image
CMD ["bin/rails", "server", "-b", "0.0.0.0"