forked from chatwoot/chatwoot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.enterprise.old
More file actions
182 lines (140 loc) 路 5.54 KB
/
Copy pathDockerfile.enterprise.old
File metadata and controls
182 lines (140 loc) 路 5.54 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Dockerfile Enterprise - Chatwit
# Baseado no Dockerfile original do Chatwoot com configura莽玫es Enterprise
# pre-build stage
FROM node:23-alpine as node
FROM ruby:3.4.4-alpine3.21 AS pre-builder
ARG NODE_VERSION="23.7.0"
ARG PNPM_VERSION="10.2.0"
ENV NODE_VERSION=${NODE_VERSION}
ENV PNPM_VERSION=${PNPM_VERSION}
# ARG default to production settings
ARG BUNDLE_WITHOUT="development:test"
ENV BUNDLE_WITHOUT ${BUNDLE_WITHOUT}
ENV BUNDLER_VERSION=2.5.16
ARG RAILS_SERVE_STATIC_FILES=true
ENV RAILS_SERVE_STATIC_FILES ${RAILS_SERVE_STATIC_FILES}
ARG RAILS_ENV=production
ENV RAILS_ENV ${RAILS_ENV}
ARG NODE_OPTIONS="--max-old-space-size=4096 --openssl-legacy-provider"
ENV NODE_OPTIONS ${NODE_OPTIONS}
ENV BUNDLE_PATH="/gems"
# Enterprise Configuration Environment Variables
ENV INSTALLATION_PRICING_PLAN=enterprise
ENV INSTALLATION_PRICING_PLAN_QUANTITY=100
RUN apk update && apk add --no-cache \
openssl \
tar \
build-base \
tzdata \
postgresql-dev \
postgresql-client \
git \
curl \
xz \
&& mkdir -p /var/app \
&& gem install bundler
COPY --from=node /usr/local/bin/node /usr/local/bin/
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
RUN ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
&& ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx
RUN npm install -g pnpm@${PNPM_VERSION}
RUN echo 'export PNPM_HOME="/root/.local/share/pnpm"' >> /root/.shrc \
&& echo 'export PATH="$PNPM_HOME:$PATH"' >> /root/.shrc \
&& export PNPM_HOME="/root/.local/share/pnpm" \
&& export PATH="$PNPM_HOME:$PATH" \
&& pnpm --version
# Persist the environment variables in Docker
ENV PNPM_HOME="/root/.local/share/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
WORKDIR /app
COPY Gemfile Gemfile.lock ./
# natively compile grpc and protobuf to support alpine musl (dialogflow-docker workflow)
# https://github.com/googleapis/google-cloud-ruby/issues/13306
# adding xz as nokogiri was failing to build libxml
# https://github.com/chatwoot/chatwoot/issues/4045
RUN apk update && apk add --no-cache build-base musl ruby-full ruby-dev gcc make musl-dev openssl openssl-dev g++ linux-headers xz vips yaml-dev
RUN bundle config set --local force_ruby_platform true
# Do not install development or test gems in production
RUN if [ "$RAILS_ENV" = "production" ]; then \
bundle config set without 'development test'; bundle install -j 4 -r 3; \
else bundle install -j 4 -r 3; \
fi
COPY package.json pnpm-lock.yaml ./
RUN pnpm i
COPY . /app
# Copy migration scripts
COPY migrate-chatwoot-v3-to-v4.rb /app/
COPY lib/tasks/chatwit_migrate.rake /app/lib/tasks/
# creating a log directory so that image wont fail when RAILS_LOG_TO_STDOUT is false
# https://github.com/chatwoot/chatwoot/issues/701
RUN mkdir -p /app/log
# generate production assets if production environment
RUN if [ "$RAILS_ENV" = "production" ]; then \
SECRET_KEY_BASE=precompile_placeholder RAILS_LOG_TO_STDOUT=enabled SKIP_SOCIALWISE_CACHE=true bundle exec rake assets:precompile \
&& rm -rf spec node_modules tmp/cache; \
fi
# Ensure all static assets are preserved in public folder
# Fix for missing assets in /assets/images/ after precompile
RUN mkdir -p /app/public/assets/images
COPY public/assets/images/ /app/public/assets/images/
# Also copy administrate assets (avatars, etc)
RUN mkdir -p /app/public/assets/administrate
COPY public/assets/administrate/ /app/public/assets/administrate/
# Generate .git_sha file with current commit hash
RUN git rev-parse HEAD > /app/.git_sha
# Remove unnecessary files
RUN rm -rf /gems/ruby/3.4.0/cache/*.gem \
&& find /gems/ruby/3.4.0/gems/ \( -name "*.c" -o -name "*.o" \) -delete \
&& rm -rf .git \
&& rm -f .gitignore
# final build stage
FROM ruby:3.4.4-alpine3.21
ARG NODE_VERSION="23.7.0"
ARG PNPM_VERSION="10.2.0"
ENV NODE_VERSION=${NODE_VERSION}
ENV PNPM_VERSION=${PNPM_VERSION}
ARG BUNDLE_WITHOUT="development:test"
ENV BUNDLE_WITHOUT ${BUNDLE_WITHOUT}
ENV BUNDLER_VERSION=2.5.16
ARG EXECJS_RUNTIME="Disabled"
ENV EXECJS_RUNTIME ${EXECJS_RUNTIME}
ARG RAILS_SERVE_STATIC_FILES=true
ENV RAILS_SERVE_STATIC_FILES ${RAILS_SERVE_STATIC_FILES}
ARG BUNDLE_FORCE_RUBY_PLATFORM=1
ENV BUNDLE_FORCE_RUBY_PLATFORM ${BUNDLE_FORCE_RUBY_PLATFORM}
ARG RAILS_ENV=production
ENV RAILS_ENV ${RAILS_ENV}
ENV BUNDLE_PATH="/gems"
# Enterprise Configuration Environment Variables
ENV INSTALLATION_PRICING_PLAN=enterprise
ENV INSTALLATION_PRICING_PLAN_QUANTITY=100
RUN apk update && apk add --no-cache \
build-base \
openssl \
tzdata \
postgresql-client \
imagemagick \
git \
vips \
&& gem install bundler
COPY --from=node /usr/local/bin/node /usr/local/bin/
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
RUN if [ "$RAILS_ENV" != "production" ]; then \
apk add --no-cache curl \
&& ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
&& ln -s /usr/local/lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \
&& npm install -g pnpm@${PNPM_VERSION} \
&& pnpm --version; \
fi
COPY --from=pre-builder /gems/ /gems/
COPY --from=pre-builder /app /app
# Copy .git_sha file from pre-builder stage
COPY --from=pre-builder /app/.git_sha /app/.git_sha
WORKDIR /app
# Ensure entrypoint scripts are executable and have Unix line endings
RUN chmod +x /app/docker/entrypoints/rails-enterprise.sh \
&& chmod +x /app/docker/entrypoints/rails.sh \
&& chmod +x /app/docker/entrypoints/vite.sh \
&& sed -i 's/\r$//' /app/docker/entrypoints/rails-enterprise.sh /app/docker/entrypoints/rails.sh /app/docker/entrypoints/vite.sh
EXPOSE 3000
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]