-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
76 lines (57 loc) · 1.73 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
74
75
76
FROM harbor.k8s.libraries.psu.edu/library/ruby-3.1.6-node-16:20241218 AS base
ARG UID=2000
USER root
RUN apt-get update && \
apt-get install --no-install-recommends -y \
default-libmysqlclient-dev \
shared-mime-info && \
rm -rf /var/lib/apt/lists*
RUN useradd -u $UID app -d /app
RUN mkdir /app/tmp
RUN chown -R app /app
USER app
COPY Gemfile Gemfile.lock /app/
RUN gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"
RUN bundle config set path 'vendor/bundle'
RUN bundle install --deployment --without development test && \
rm -rf /app/.bundle/cache && \
rm -rf /app/vendor/bundle/ruby/*/cache
COPY package.json yarn.lock /app/
RUN yarn --frozen-lockfile && \
rm -rf /app/.cache && \
rm -rf /app/tmp
CMD ["/app/bin/startup"]
# Final Target
FROM base as production
USER app
COPY --chown=app . /app
RUN RAILS_ENV=production \
SECRET_KEY_BASE=rails_bogus_key \
MYSQL_USER=mysql \
MYSQL_PASSWORD=mysql \
MYSQL_HOST=mysql \
MYSQL_DATABASE=mysql \
bundle exec rails assets:precompile && \
rm -rf /app/.cache/ && \
rm -rf /app/node_modules/.cache/ && \
rm -rf /app/tmp/
CMD ["/app/bin/startup"]
# dev stage installs chrome, and all the deps needed to run rspec
FROM base as dev
USER root
RUN wget -q -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.list
RUN apt-get update && apt-get install -y x11vnc \
xvfb \
fluxbox \
wget \
sqlite3 \
rsync \
libsqlite3-dev \
libnss3 \
wmctrl \
google-chrome-stable
USER app
RUN bundle config set path 'vendor/bundle'
RUN bundle install --with development test
CMD ["sleep", "99999999"]