-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
104 lines (74 loc) · 2.48 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# syntax = docker/dockerfile:experimental
ARG RUBY_VERSION=2.7.3
ARG VARIANT=jemalloc-slim
# base image
FROM quay.io/evl.ms/fullstaq-ruby:${RUBY_VERSION}-${VARIANT} as base
ARG NODE_VERSION=16
ARG BUNDLER_VERSION=2.3.9
ARG RAILS_ENV=production
ENV RAILS_ENV=${RAILS_ENV}
ENV RAILS_SERVE_STATIC_FILES true
ENV RAILS_LOG_TO_STDOUT true
ARG BUNDLE_WITHOUT=development:test
ARG BUNDLE_PATH=/usr/bundle
ENV BUNDLE_PATH ${BUNDLE_PATH}
ENV BUNDLE_WITHOUT ${BUNDLE_WITHOUT}
RUN mkdir /app
WORKDIR /app
RUN mkdir -p tmp/pids
SHELL ["/bin/bash", "-c"]
RUN curl https://get.volta.sh | bash
ENV BASH_ENV ~/.bashrc
ENV VOLTA_HOME /root/.volta
ENV PATH $VOLTA_HOME/bin:/usr/local/bin:$PATH
RUN volta install node@${NODE_VERSION} && volta install yarn
# build_deps image
FROM base as build_deps
ARG DEV_PACKAGES="git build-essential libpq-dev wget vim curl gzip xz-utils libsqlite3-dev"
ENV DEV_PACKAGES ${DEV_PACKAGES}
RUN --mount=type=cache,id=dev-apt-cache,sharing=locked,target=/var/cache/apt \
--mount=type=cache,id=dev-apt-lib,sharing=locked,target=/var/lib/apt \
apt-get update -qq && \
apt-get install --no-install-recommends -y ${DEV_PACKAGES} \
&& rm -rf /var/lib/apt/lists /var/cache/apt/archives
# gems image
FROM build_deps as gems
RUN gem install -N bundler -v ${BUNDLER_VERSION}
COPY Gemfile* ./
RUN bundle install && rm -rf /usr/bundle/ruby/*/cache
# docs image
FROM gems as docs
WORKDIR /app/docs
COPY docs/ ./
RUN bundle install
RUN bundle exec jekyll build
# node_modules image
FROM build_deps as node_modules
COPY package*json ./
COPY yarn.* ./
RUN if [ -f "yarn.lock" ]; then \
yarn install; \
elif [ -f "package-lock.json" ]; then \
npm install; \
else \
mkdir node_modules; \
fi
FROM base
ARG PROD_PACKAGES="postgresql-client file vim curl gzip libsqlite3-0"
ENV PROD_PACKAGES=${PROD_PACKAGES}
RUN --mount=type=cache,id=prod-apt-cache,sharing=locked,target=/var/cache/apt \
--mount=type=cache,id=prod-apt-lib,sharing=locked,target=/var/lib/apt \
apt-get update -qq && \
apt-get install --no-install-recommends -y \
${PROD_PACKAGES} \
&& rm -rf /var/lib/apt/lists /var/cache/apt/archives
COPY --from=gems /usr/bundle /usr/bundle
COPY --from=node_modules /app/node_modules /app/node_modules
COPY --from=docs /app/docs/_site /app/public/docs
ENV SECRET_KEY_BASE 1
COPY . .
RUN bundle exec rails assets:precompile
ENV PORT 8080
ARG SERVER_COMMAND="bundle exec puma -C config/puma.rb"
ENV SERVER_COMMAND ${SERVER_COMMAND}
CMD ${SERVER_COMMAND}