2023-12-21 06:25:35 +00:00
FROM node:18.18.2-buster as builder
2021-08-26 15:04:30 +00:00
2021-08-01 09:28:48 +00:00
# Fix for JS heap limit allocation issue
2021-11-20 01:25:54 +00:00
ENV NODE_OPTIONS="--max-old-space-size=4096"
2021-08-01 09:28:48 +00:00
2023-12-21 06:25:35 +00:00
RUN npm i -g npm@9.8.1
2021-08-26 15:04:30 +00:00
RUN npm install -g @nestjs/cli
2021-08-01 09:28:48 +00:00
RUN mkdir -p /app
WORKDIR /app
2022-01-17 07:08:17 +00:00
COPY ./package.json ./package.json
# Building ToolJet plugins
COPY ./plugins/package.json ./plugins/package-lock.json ./plugins/
RUN npm --prefix plugins install
COPY ./plugins/ ./plugins/
ENV NODE_ENV=production
2022-05-20 14:02:46 +00:00
RUN npm --prefix plugins run build
RUN npm --prefix plugins prune --production
2021-08-01 09:28:48 +00:00
# Building ToolJet server
2022-01-17 07:08:17 +00:00
COPY ./server/package.json ./server/package-lock.json ./server/
RUN npm --prefix server install --only=production
COPY ./server/ ./server/
RUN npm --prefix server run build
2023-01-25 09:40:53 +00:00
FROM debian:11
RUN apt-get update -yq \
&& apt-get install curl gnupg zip -yq \
2023-02-16 16:05:16 +00:00
&& apt-get install -yq build-essential \
2023-01-25 09:40:53 +00:00
&& apt-get clean -y
2022-01-17 07:08:17 +00:00
2023-12-21 06:25:35 +00:00
RUN curl -O https://nodejs.org/dist/v18.18.2/node-v18.18.2-linux-x64.tar.xz \
&& tar -xf node-v18.18.2-linux-x64.tar.xz \
&& mv node-v18.18.2-linux-x64 /usr/local/lib/nodejs \
2023-02-16 16:05:16 +00:00
&& echo 'export PATH="/usr/local/lib/nodejs/bin:$PATH"' >> /etc/profile.d/nodejs.sh \
&& /bin/bash -c "source /etc/profile.d/nodejs.sh" \
2023-12-21 06:25:35 +00:00
&& rm node-v18.18.2-linux-x64.tar.xz
2023-02-16 16:05:16 +00:00
ENV PATH=/usr/local/lib/nodejs/bin:$PATH
2022-01-17 07:08:17 +00:00
ENV NODE_ENV=production
ENV NODE_OPTIONS="--max-old-space-size=4096"
2022-03-24 12:00:14 +00:00
RUN apt-get update && apt-get install -y postgresql-client freetds-dev libaio1 wget
2022-01-17 07:08:17 +00:00
2022-03-15 02:30:02 +00:00
# Install Instantclient Basic Light Oracle and Dependencies
2022-03-24 12:00:14 +00:00
WORKDIR /opt/oracle
2023-07-21 11:56:13 +00:00
RUN wget https://tooljet-plugins-production.s3.us-east-2.amazonaws.com/marketplace-assets/oracledb/instantclients/instantclient-basiclite-linuxx64.zip && \
2023-06-21 06:09:30 +00:00
wget https://tooljet-plugins-production.s3.us-east-2.amazonaws.com/marketplace-assets/oracledb/instantclients/instantclient-basiclite-linux.x64-11.2.0.4.0.zip && \
2022-03-24 12:00:14 +00:00
unzip instantclient-basiclite-linuxx64.zip && rm -f instantclient-basiclite-linuxx64.zip && \
2023-06-21 06:09:30 +00:00
unzip instantclient-basiclite-linux.x64-11.2.0.4.0.zip && rm -f instantclient-basiclite-linux.x64-11.2.0.4.0.zip && \
cd /opt/oracle/instantclient_21_10 && rm -f *jdbc* *occi* *mysql* *mql1* *ipc1* *jar uidrvci genezi adrci && \
cd /opt/oracle/instantclient_11_2 && rm -f *jdbc* *occi* *mysql* *mql1* *ipc1* *jar uidrvci genezi adrci && \
2022-03-24 12:00:14 +00:00
echo /opt/oracle/instantclient* > /etc/ld.so.conf.d/oracle-instantclient.conf && ldconfig
2023-06-21 06:09:30 +00:00
# Set the Instant Client library paths
ENV LD_LIBRARY_PATH="/opt/oracle/instantclient_11_2:/opt/oracle/instantclient_21_10:${LD_LIBRARY_PATH}"
2022-03-24 12:00:14 +00:00
WORKDIR /
2022-03-15 02:30:02 +00:00
2022-01-17 07:08:17 +00:00
RUN mkdir -p /app
2022-02-06 19:04:48 +00:00
# copy npm scripts
COPY --from=builder /app/package.json ./app/package.json
2022-01-17 07:08:17 +00:00
# copy plugins dependencies
COPY --from=builder /app/plugins/dist ./app/plugins/dist
COPY --from=builder /app/plugins/client.js ./app/plugins/client.js
COPY --from=builder /app/plugins/node_modules ./app/plugins/node_modules
COPY --from=builder /app/plugins/packages/common ./app/plugins/packages/common
COPY --from=builder /app/plugins/package.json ./app/plugins/package.json
2022-08-03 11:36:11 +00:00
2022-01-17 07:08:17 +00:00
# copy server build
2022-08-03 11:36:11 +00:00
COPY --from=builder /app/server/package.json ./app/server/package.json
COPY --from=builder /app/server/.version ./app/server/.version
COPY --from=builder /app/server/entrypoint.sh ./app/server/entrypoint.sh
COPY --from=builder /app/server/node_modules ./app/server/node_modules
COPY --from=builder /app/server/templates ./app/server/templates
2022-08-18 07:28:30 +00:00
COPY --from=builder /app/server/scripts ./app/server/scripts
2022-08-03 11:36:11 +00:00
COPY --from=builder /app/server/dist ./app/server/dist
2022-01-17 07:08:17 +00:00
2023-03-03 06:25:19 +00:00
# Define non-sudo user
2023-07-03 12:53:49 +00:00
RUN useradd --create-home --home-dir /home/appuser appuser \
&& chown -R appuser:0 /app \
&& chown -R appuser:0 /home/appuser \
&& chmod u+x /app \
&& chmod -R g=u /app
2023-07-11 06:10:20 +00:00
# Set npm cache directory
ENV npm_config_cache /home/appuser/.npm
2023-07-03 12:53:49 +00:00
ENV HOME=/home/appuser
2023-03-03 06:25:19 +00:00
USER appuser
2022-01-17 07:08:17 +00:00
WORKDIR /app
2022-08-03 11:36:11 +00:00
# Dependencies for scripts outside nestjs
RUN npm install dotenv@10.0.0 joi@17.4.1
2021-08-01 09:28:48 +00:00
2022-08-03 11:36:11 +00:00
ENTRYPOINT ["./server/entrypoint.sh"]