-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
64 lines (52 loc) · 2.06 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
# syntax = docker/dockerfile:1
FROM ruby:3.2.6
WORKDIR /gala
# environment variables
ENV BUNDLE_PATH="/usr/local/bundle" \
NVM_DIR="/usr/local/nvm" \
NODE_VERSION="12.5.0" \
RAILS_LOG_TO_STDOUT="true" \
RAILS_SERVE_STATIC_FILES="true"
# install builder dependencies
RUN apt-get update && apt-get install -y \
wget gnupg2 build-essential curl python3 wkhtmltopdf \
libvips git pkg-config libjemalloc-dev lsb-release zlib1g-dev \
libffi-dev libyaml-dev libreadline-dev libssl-dev postgresql-client libpq-dev gcc make \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives
# copy ruby and node configuration files
COPY .ruby-version Gemfile Gemfile.lock package.json yarn.lock ./
# create NVM directory and install node and js dependencies
RUN mkdir -p $NVM_DIR \
&& curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash \
&& . "$NVM_DIR/nvm.sh" \
&& nvm install "$NODE_VERSION" \
&& nvm alias default "$NODE_VERSION" \
&& nvm use default \
&& npm install -g yarn \
&& yarn install --check-files
# install gems
RUN echo "gem: --no-document" > /etc/gemrc \
&& gem update --system 3.3.22 \
&& gem install bundler:2.4.19 \
&& bundle install --jobs 20 --retry 2 \
&& rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git \
&& gem cleanup all \
&& bundle exec bootsnap precompile --gemfile
COPY . ./
ARG rails_env=development
ENV RAILS_ENV=${rails_env}
ARG secret_key_base=placeholder
ENV SECRET_KEY_BASE=${secret_key_base}
ENV NODE_PATH=$NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH=$NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
# precompile the app directory if not in development
RUN if [ "$RAILS_ENV" != "development" ]; then \
export DATABASE_URL=postgresql://placeholder/placeholder; \
bundle exec bootsnap precompile app/; \
bundle exec rails assets:precompile; \
fi
RUN chmod +x entrypoint.sh
ENTRYPOINT ["./entrypoint.sh"]
EXPOSE 3000
CMD ["bundle", "exec", "rails", "s", "-b", "0.0.0.0", "-p", "3000"]