-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathplain_ruby_no_assets.Dockerfile
More file actions
43 lines (31 loc) · 1.21 KB
/
plain_ruby_no_assets.Dockerfile
File metadata and controls
43 lines (31 loc) · 1.21 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
# Start from a small, trusted base image with the version pinned down
FROM ruby:2.7.1-alpine AS base
# Install system dependencies required both at runtime and build time
# The image uses Postgres but you can swap it with mariadb-dev (for MySQL) or sqlite-dev
RUN apk add --update \
postgresql-dev \
tzdata
# This stage will be responsible for installing gems
FROM base AS dependencies
# Install system dependencies required to build some Ruby gems (pg)
RUN apk add --update build-base
COPY Gemfile Gemfile.lock ./
# Install gems (excluding development/test dependencies)
RUN bundle config set without "development test" && \
bundle install --jobs=3 --retry=3
# We're back at the base stage
FROM base
# Create a non-root user to run the app and own app-specific files
RUN adduser -D app
# Switch to this user
USER app
# We'll install the app in this directory
WORKDIR /home/app
# Copy over gems from the dependencies stage
COPY --from=dependencies /usr/local/bundle/ /usr/local/bundle/
# Finally, copy over the code
# This is where the .dockerignore file comes into play
# Note that we have to use `--chown` here
COPY --chown=app . ./
# Launch the server (or run some other Ruby command)
CMD ["bundle", "exec", "rackup"]