-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
54 lines (41 loc) · 1.44 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
# =============================================================================
# Target: base
FROM ruby:3.0.2-alpine AS base
RUN apk --no-cache --update upgrade && \
apk --no-cache add \
bash \
ca-certificates \
git \
libc6-compat \
openssl \
tzdata \
xz-libs \
&& rm -rf /var/cache/apk/*
WORKDIR /opt/app
# =============================================================================
# Target: development
#
FROM base AS development
# Install system packages needed to build gems with C extensions.
RUN apk --update --no-cache add \
build-base \
coreutils \
git \
&& rm -rf /var/cache/apk/*
# Copy codebase to WORKDIR. Unlike application projects, for a gem project
# we need to do this before running `bundle install`, in order for the gem
# we're building to be able to "install" itself.
COPY . .
# Install gems.
RUN bundle install --path=/usr/local/bundle
# =============================================================================
# Target: production
FROM base AS production
# Copy the built codebase from the dev stage
COPY --from=development /opt/app /opt/app
COPY --from=development /usr/local/bundle /usr/local/bundle
# Sanity-check that everything was installed correctly and still runs in the
# slimmed-down production image.
RUN bundle config set deployment 'true'
RUN bundle install --local --path=/usr/local/bundle
CMD ["bundle", "exec", "rake"]