-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (52 loc) · 1.41 KB
/
Dockerfile
File metadata and controls
65 lines (52 loc) · 1.41 KB
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
# =============================================
# Builder stage
FROM ruby:4.0.1-alpine AS builder
ENV APP_ROOT=/usr/src/app
WORKDIR $APP_ROOT
# Install build dependencies
RUN apk add --no-cache \
build-base \
git \
nodejs \
postgresql-dev \
tzdata \
curl-dev \
yaml-dev
# Copy Gemfile and install gems
COPY Gemfile Gemfile.lock $APP_ROOT/
RUN gem update --system \
&& gem install bundler foreman \
&& bundle config --global frozen 1 \
&& bundle config set without 'test' \
&& bundle install --jobs 2
# Copy application code
COPY . $APP_ROOT
# Precompile bootsnap cache and assets
RUN bundle exec bootsnap precompile --gemfile app/ lib/ \
&& RAILS_ENV=production bundle exec rake assets:precompile
# =============================================
# Final stage
FROM ruby:4.0.1-alpine
ENV APP_ROOT=/usr/src/app
ENV DATABASE_PORT=5432
ENV LD_PRELOAD=/usr/lib/libjemalloc.so.2
ENV RUBY_YJIT_ENABLE=1
WORKDIR $APP_ROOT
# Install runtime dependencies
RUN apk add --no-cache \
bash \
nodejs \
postgresql-libs \
tzdata \
curl \
yaml \
jemalloc
# Copy installed gems from builder
COPY --from=builder /usr/local/bundle /usr/local/bundle
# Copy application code
COPY . $APP_ROOT
# Copy precompiled bootsnap cache and assets from builder
COPY --from=builder $APP_ROOT/tmp/cache/bootsnap* $APP_ROOT/tmp/cache/
COPY --from=builder $APP_ROOT/public/assets $APP_ROOT/public/assets
# Startup
CMD ["bin/docker-start"]