forked from chatwoot/chatwoot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.enterprise
More file actions
192 lines (150 loc) · 6 KB
/
Copy pathDockerfile.enterprise
File metadata and controls
192 lines (150 loc) · 6 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
183
184
185
186
187
188
189
190
191
192
# Dockerfile Enterprise - Chatwit 4.10
# Baseado no Dockerfile oficial Chatwoot 4.10.1 com configurações Enterprise e SocialWise
# Mantém versões atualizadas do Chatwoot 4.10 (Node 24, Ruby 3.4.4)
# pre-build stage
FROM node:24-alpine AS node
FROM ruby:3.4.4-alpine3.21 AS pre-builder
ARG NODE_VERSION="24.13.0"
ARG PNPM_VERSION="10.2.0"
ENV NODE_VERSION=${NODE_VERSION}
ENV PNPM_VERSION=${PNPM_VERSION}
# ARG default to production settings
# For development docker-compose file overrides ARGS
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"
# ============================================
# CHATWIT ENTERPRISE CONFIGURATION
# ============================================
# Unlock Enterprise features
ENV INSTALLATION_PRICING_PLAN=enterprise
ENV INSTALLATION_PRICING_PLAN_QUANTITY=100
# Telemetry control
# DISABLE_TELEMETRY baked at build time; ANALYTICS_TOKEN and CHATWOOT_HUB_URL
# are runtime-only secrets — set them via docker-compose/env_file, never as build-arg.
ARG DISABLE_TELEMETRY=true
ENV DISABLE_TELEMETRY=${DISABLE_TELEMETRY}
# ============================================
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 -v "$BUNDLER_VERSION"
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
# yaml-dev added for psych gem compatibility
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
# 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
# SKIP_SOCIALWISE_CACHE=true prevents cache preload during build (no DB available)
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
# Generate .git_sha file with current commit hash
RUN git rev-parse HEAD > /app/.git_sha
# Remove unnecessary files (use -f to avoid error if file doesn't exist)
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="24.13.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"
# ============================================
# CHATWIT ENTERPRISE CONFIGURATION (Final Stage)
# ============================================
ENV INSTALLATION_PRICING_PLAN=enterprise
ENV INSTALLATION_PRICING_PLAN_QUANTITY=100
# Telemetry control — DISABLE_TELEMETRY inherited from build; the rest is runtime-only.
ARG DISABLE_TELEMETRY=true
ENV DISABLE_TELEMETRY=${DISABLE_TELEMETRY}
# ============================================
RUN apk update && apk add --no-cache \
build-base \
openssl \
tzdata \
postgresql-client \
imagemagick \
ffmpeg \
git \
vips \
&& gem install bundler -v "$BUNDLER_VERSION"
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
RUN chmod +x /app/docker/entrypoints/*.sh 2>/dev/null || true
EXPOSE 3000
# Default command
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]