-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile
73 lines (58 loc) · 2.01 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
65
66
67
68
69
70
71
72
73
FROM ruby:3.0.7-slim
ENV LANG C.UTF-8
ARG BUNDLE_GITHUB__COM
# Install curl
RUN apt-get update -qq && \
apt-get install -y curl && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install alternate NodeJS and Chrome apt sources
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
# Install dependencies
RUN apt-get update -qq && apt-get install -y \
build-essential \
dumb-init \
git \
google-chrome-stable \
libgconf-2-4 \
libnss3 \
libpq-dev \
nodejs \
postgresql-client && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Disable Chrome sandbox
RUN sed -i 's|HERE/chrome"|HERE/chrome" --disable-setuid-sandbox --no-sandbox|g' "/opt/google/chrome/google-chrome"
RUN gem install bundler -v 2.4.22
RUN npm install -g yarn
# Set up deploy user, working directory and shared folders for Puma / Nginx
RUN adduser --disabled-password --gecos '' deploy && \
mkdir -p /app && \
chown deploy:deploy /app && \
mkdir /shared && \
mkdir /shared/config && \
mkdir /shared/pids && \
mkdir /shared/sockets && \
chown -R deploy:deploy /shared
# Throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
# Set up gems
WORKDIR /tmp
ADD Gemfile Gemfile
ADD Gemfile.lock Gemfile.lock
RUN bundle install -j4 && \
rm -rf /usr/local/bundle/cache
# Switch to deploy user
USER deploy
ENV USER deploy
ENV HOME /home/deploy
# Finally, add the rest of our app's code
# (this is done at the end so that changes to our app's code
# don't bust Docker's cache)
ADD --chown=deploy:deploy . /app
WORKDIR /app
RUN yarn install && yarn cache clean
# Precompile Rails assets
RUN bundle exec rake assets:precompile
ENTRYPOINT ["/usr/bin/dumb-init", "./scripts/load_secrets_and_run.sh"]
CMD ["bundle", "exec", "puma", "-C", "config/puma.config"]