This repository has been archived by the owner on May 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDockerfile.prod
85 lines (61 loc) · 2.14 KB
/
Dockerfile.prod
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
77
78
79
80
81
82
83
84
85
FROM ruby:3.0-alpine AS ruby
WORKDIR /app/
# Install system dependencies
RUN apk add --no-cache build-base curl-dev git postgresql-dev cmake
# Install Bundler
RUN gem update --system && gem install bundler
# Install Gem dependencies
ADD Gemfile /app/
ADD Gemfile.lock /app/
RUN bundle config set --local without "development test" && \
bundle config set --local jobs 4 && \
bundle config set --local deployment true && \
bundle install
FROM ruby AS node
# Install Yarn
RUN apk add --no-cache nodejs yarn
# Install NPM dependencies
ADD package.json /app/
ADD yarn.lock /app/
RUN yarn install
FROM node AS assets
# Only add files that affect the assets:precompile task
ADD Rakefile /app/Rakefile
ADD postcss.config.js /app/postcss.config.js
ADD config/application.rb /app/config/application.rb
ADD config/boot.rb /app/config/boot.rb
ADD config/environment.rb /app/config/environment.rb
ADD config/environments/production.rb /app/config/environments/production.rb
ADD config/initializers/assets.rb /app/config/initializers/assets.rb
ADD config/locales /app/config/locales
ADD config/webpacker.yml /app/config/webpacker.yml
ADD config/webpack /app/config/webpack
ADD app/assets /app/app/assets
ADD app/javascript /app/app/javascript
ADD bin/webpack /app/bin/webpack
ARG SECRET_KEY_BASE=secret_key_base
ARG RAILS_ENV=production
ARG NODE_ENV=production
RUN rake webpacker:compile
FROM ruby
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
WORKDIR /app/
# Add user
ARG USER=docker
ARG UID=1000
ARG GID=1000
RUN addgroup -g $GID $USER
RUN adduser -D -u $UID -G $USER -h /app/ $USER
# Install system dependencies
RUN apk add --no-cache postgresql
# Add application
ADD . /app/
# Copy assets
COPY --from=assets /app/public/ /app/public/
RUN mkdir -p /app/tmp/pids/
RUN chown -R $UID:$GID /app/
# Change user
USER $USER
EXPOSE 3000
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]