forked from CircuitVerse/CircuitVerse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.production
90 lines (64 loc) · 2.68 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Use a multi stage build for the builder
FROM --platform=$BUILDPLATFORM ruby:3.2.1 as builder
# Set production environment
ARG BUILDPLATFORM
ENV NODE_ENV=production
ENV RAILS_ENV=production
RUN curl -fsSL https://deb.nodesource.com/setup_16.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 . .
# Remove the Vue simulator directory (since it's being handled separately in another stage)
RUN rm -rf cv-frontend-vue
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
# Precompile the Bootsnap cache for the specified directories to optimize boot time in production.
RUN bundle exec bootsnap precompile --gemfile app/ lib/
# Build stage for the Vue simualtor
FROM --platform=$BUILDPLATFORM node:18.11-slim as simulator_vue_build
RUN mkdir -p /public/
WORKDIR /app
# Copy package files and install Vue simulator dependecies
COPY cv-frontend-vue/package.json cv-frontend-vue/package-lock.json ./
RUN npm install --ignore-scripts
COPY cv-frontend-vue/ ./
# Build Vue simualtor
RUN npm run build
FROM --platform=$BUILDPLATFORM ruby:3.2.1-slim as app
# Copy compiled assets and application from builder and Vue simulator build stages
COPY --from=builder /usr/src/app /usr/src/app
COPY --from=simulator_vue_build /public/simulatorvue /usr/src/app/public/simulatorvue
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"
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_16.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
ENV LD_PRELOAD="libjemalloc.so.2"
ENV MALLOC_CONF="dirty_decay_ms:1000,narenas:2,background_thread:true"
WORKDIR /usr/src/app
ENTRYPOINT ["/usr/src/app/bin/docker-entrypoint"]
EXPOSE 3000