-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (32 loc) · 1.3 KB
/
Dockerfile
File metadata and controls
42 lines (32 loc) · 1.3 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
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
ARG RUBY_VERSION=3.3.6
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
# UID and GID that will be used to run the app
# This should match the UID and GID of the user's that will run the container
ARG UID
ARG GID
# Rails app lives here
WORKDIR /rails
# Install base packages
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libjemalloc2 libvips sqlite3 && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
# Set production environment
ENV RAILS_ENV="development" \
BUNDLE_PATH="/usr/local/bundle"
# Install packages needed to build gems
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git libyaml-dev pkg-config && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
# Install application gems
COPY Gemfile Gemfile.lock ./
RUN bundle install
# Run and own only the runtime files as a non-root user for security
RUN groupadd --system --gid $GID rails && \
useradd rails --uid $UID --gid $GID --create-home --shell /bin/bash
USER $UID:$GID
# Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
EXPOSE 3000
# Start server via Thruster by default, this can be overwritten at runtime
CMD ["./bin/rails", "server", "-b", "0.0.0.0"]