Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
76 lines (54 loc) · 2.63 KB
/
Copy pathDockerfile
File metadata and controls
76 lines (54 loc) · 2.63 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
66
67
68
69
70
71
72
73
74
75
76
# syntax=docker/dockerfile:1
# check=error=true
# Production image for the web pool backend (web/). Built from the repo root
# because the Rails app loads ../lib and ../assets, and the compiler shells
# out to mrbc built from the vendored (patched) mruby source.
ARG RUBY_VERSION=3.4.2
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
WORKDIR /rails/web
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y curl libjemalloc2 sqlite3 python3 python3-pip && \
pip3 install --no-cache-dir --break-system-packages openpyxl pillow && \
ln -s /usr/lib/$(uname -m)-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
ENV RAILS_ENV="production" \
BUNDLE_DEPLOYMENT="1" \
BUNDLE_PATH="/usr/local/bundle" \
BUNDLE_WITHOUT="development" \
LD_PRELOAD="/usr/local/lib/libjemalloc.so"
# Build mrbc from the vendored mruby source (bin/vendor-mruby refreshes it).
# BytecodeParser expects it at <repo>/../mruby/bin/mrbc, i.e. /mruby/bin/mrbc.
FROM base AS mruby
RUN apt-get update -qq && \
apt-get install --no-install-recommends -y build-essential git && \
rm -rf /var/lib/apt/lists /var/cache/apt/archives
ADD vendor/mruby-src.tar.gz /
RUN cd /mruby && rake && install -D build/host/bin/mrbc /mruby-dist/bin/mrbc
# Throw-away build stage for gems and assets
FROM base AS build
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
COPY web/Gemfile web/Gemfile.lock ./
RUN bundle install && \
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \
bundle exec bootsnap precompile -j 1 --gemfile
COPY lib /rails/lib
COPY assets /rails/assets
COPY web /rails/web
RUN bundle exec bootsnap precompile -j 1 app/ lib/
RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
# Final stage for app image
FROM base
RUN groupadd --system --gid 1000 rails && \
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash
COPY --chown=rails:rails --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
COPY --chown=rails:rails --from=build /rails /rails
COPY --from=mruby /mruby-dist/bin/mrbc /mruby/bin/mrbc
# Volume mount points: sqlite databases and the OneDrive graph token.
RUN mkdir -p /rails/web/storage /rails/web/tmp /rails/web/log /home/rails/.config/human-ruby && \
chown -R rails:rails /rails/web/storage /rails/web/tmp /rails/web/log /home/rails/.config
USER 1000:1000
ENTRYPOINT ["/rails/web/bin/docker-entrypoint"]
EXPOSE 80
CMD ["./bin/thrust", "./bin/rails", "server"]