forked from CircuitVerse/CircuitVerse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.production
66 lines (47 loc) · 1.87 KB
/
Dockerfile.production
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
FROM --platform=$BUILDPLATFORM ruby:3.2.1 as builder
ARG BUILDPLATFORM
ENV NODE_ENV=production
RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get update -qq && apt-get install -y --no-install-recommends --auto-remove nodejs imagemagick libvips
RUN npm install --global yarn
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --network-timeout 1000000 && yarn cache clean
COPY Gemfile* ./
ENV BUNDLE_DEPLOYMENT=true
# ENV BUNDLE_JOBS=4
ENV BUNDLE_WITHOUT=development:test
RUN bundle install \
&& rm -rf vendor/bundle/ruby/3.1.0/cache/*
COPY . .
RUN RAILS_ENV=production \
SECRET_KEY_BASE=1 \
DATABASE_URL=postgres://nulldb \
DISABLE_FLIPPER=true \
bundle exec rails assets:precompile && \
yarn cache clean
RUN rm -rf node_modules spec
RUN bundle exec bootsnap precompile --gemfile app/ lib/
FROM --platform=$BUILDPLATFORM ruby:3.2.1-slim as app
COPY --from=builder /usr/src/app /usr/src/app
ENV RAILS_ENV=production
ENV NODE_ENV=production
ENV BUNDLE_PATH='vendor/bundle'
ENV RAILS_LOG_TO_STDOUT=true
ENV BUNDLE_DEPLOYMENT=true
ENV BUNDLE_WITHOUT="development:test"
ENV RAILS_SERVE_STATIC_FILES="true"
# ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
ARG REDIS_URL="redis://localhost:6379"
RUN apt-get update -qq && apt upgrade -y && apt-get install -y --no-install-recommends --auto-remove curl \
&& curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get update -qq && apt-get install -y --no-install-recommends --auto-remove nodejs imagemagick libpq5 libcurl4 libjemalloc2 \
&& apt-get clean \
&& rm -rf /var/cache/apt/archives/* \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& truncate -s 0 /var/log/*log
WORKDIR /usr/src/app
EXPOSE 3000
CMD rm -f tmp/pids/server.pid \
&& bundle exec rails db:migrate \
&& bundle exec rails s -b 0.0.0.0 -p 3000