-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
59 lines (46 loc) · 1.46 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
55
56
57
58
59
# syntax = docker/dockerfile:1
ARG RUBY_VERSION=3.3.4
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim AS base
WORKDIR /rails
ENV SECRET_KEY_BASE_DUMMY=1
# Set environment variables
ENV RAILS_ENV="production" \
BUNDLE_PATH="/usr/local/bundle" \
LANG="C.UTF-8" \
RAILS_LOG_TO_STDOUT="enabled"
# Throw-away build stage
FROM base AS build
# Install packages needed to build gems
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y \
build-essential \
git \
pkg-config \
libsecp256k1-dev \
automake \
autoconf \
libtool && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
# Install application gems
COPY Gemfile Gemfile.lock ./
RUN bundle config build.rbsecp256k1 --use-system-libraries && \
bundle install --jobs 4 --retry 3
# Copy application code and precompile bootsnap
COPY . .
ENV BOOTSNAP_COMPILE_CACHE_THREADS=4
RUN bundle exec bootsnap precompile app/ lib/
# Final stage
FROM base
# Install only runtime dependencies
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y \
libsecp256k1-dev && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
# Copy built artifacts
COPY --from=build /usr/local/bundle /usr/local/bundle
COPY --from=build /rails /rails
# Set up non-root user
RUN useradd rails --create-home --shell /bin/bash && \
chown -R rails:rails db log storage tmp
USER rails:rails
CMD ["bundle", "exec", "clockwork", "config/derive_facet_blocks.rb"]