-
Notifications
You must be signed in to change notification settings - Fork 247
/
Dockerfile
64 lines (50 loc) · 2.3 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
# Use the official Ruby image from Docker Hub
# https://hub.docker.com/_/ruby
# [START cloudrun_rails_base_image]
# Pinning the OS to buster because the nodejs install script is buster-specific.
# Be sure to update the nodejs install command if the base image OS is updated.
FROM ruby:3.2.1 as base
# [END cloudrun_rails_base_image]
RUN (curl -sS https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | apt-key add -) && \
echo "deb https://deb.nodesource.com/node_14.x buster main" > /etc/apt/sources.list.d/nodesource.list && \
apt-get update && apt-get install -y nodejs lsb-release
RUN (curl -sS 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 && \
apt-get update && apt-get install -y yarn
RUN apt-get update -qq && apt-get install -y dos2unix postgresql-client
RUN mkdir /WebsiteOne
WORKDIR /WebsiteOne
COPY Gemfile /WebsiteOne/Gemfile
COPY Gemfile.lock /WebsiteOne/Gemfile.lock
#Production or staging, use middle 2 config lines below when bundling
RUN gem install bundler && \
# bundle config set --local deployment 'true' && \
# bundle config set --local without 'development test' && \
bundle install
COPY package.json /WebsiteOne/package.json
COPY scripts /WebsiteOne/scripts
COPY vendor/assets/javascripts /WebsiteOne/assets/javascripts
FROM base
# To execute tests, install chromium
RUN apt install -y xvfb chromium chromium-driver
RUN dos2unix scripts/copy_javascript_dependencies.cjs
RUN yarn install
COPY . /WebsiteOne
RUN bundle exec rake assets:precompile
#Production or staging, take out 'bundle' line above and use the following
# ENV RAILS_ENV=production
# ENV RAILS_SERVE_STATIC_FILES=true
# # Redirect Rails log to STDOUT for Cloud Run to capture
# ENV RAILS_LOG_TO_STDOUT=true
# # [START cloudrun_rails_dockerfile_key]
# ARG MASTER_KEY
# ENV RAILS_MASTER_KEY=${MASTER_KEY}
# # [END cloudrun_rails_dockerfile_key]
# # pre-compile Rails assets with master key
# RUN bundle exec rake assets:precompile
# EXPOSE 8080
# CMD ["bin/rails", "server", "-b", "0.0.0.0", "-p", "8080"]
# Also add lines below to database.yml under 'production:'
# username: av
# password: <%= Rails.application.credentials.gcp[:db_password] %>
# host: /cloudsql/av-wso:us-central1:postgres