Slimming build down from 4GB to 1.8GB for single image.
This commit is contained in:
parent
a3607842ef
commit
3cefc016c5
|
@ -1,5 +1,28 @@
|
||||||
|
FROM node:14-slim as build
|
||||||
|
|
||||||
|
# install node-gyp dependencies
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends g++ make python
|
||||||
|
|
||||||
|
# add pin script
|
||||||
|
WORKDIR /
|
||||||
|
ADD scripts/pinVersions.js scripts/cleanup.sh ./
|
||||||
|
RUN chmod +x /cleanup.sh
|
||||||
|
|
||||||
|
# build server
|
||||||
|
WORKDIR /app
|
||||||
|
ADD packages/server .
|
||||||
|
RUN node /pinVersions.js && yarn && yarn build && /cleanup.sh
|
||||||
|
|
||||||
|
# build worker
|
||||||
|
WORKDIR /worker
|
||||||
|
ADD packages/worker .
|
||||||
|
RUN node /pinVersions.js && yarn && yarn build && /cleanup.sh
|
||||||
|
|
||||||
FROM couchdb:3.2.1
|
FROM couchdb:3.2.1
|
||||||
|
|
||||||
|
COPY --from=build /app /app
|
||||||
|
COPY --from=build /worker /worker
|
||||||
|
|
||||||
ENV DEPLOYMENT_ENVIRONMENT=docker \
|
ENV DEPLOYMENT_ENVIRONMENT=docker \
|
||||||
POSTHOG_TOKEN=phc_fg5I3nDOf6oJVMHSaycEhpPdlgS8rzXG2r6F2IpxCHS \
|
POSTHOG_TOKEN=phc_fg5I3nDOf6oJVMHSaycEhpPdlgS8rzXG2r6F2IpxCHS \
|
||||||
COUCHDB_PASSWORD=budibase \
|
COUCHDB_PASSWORD=budibase \
|
||||||
|
@ -40,20 +63,10 @@ RUN mkdir /etc/nginx/logs && \
|
||||||
touch /etc/nginx/logs/error.log && \
|
touch /etc/nginx/logs/error.log && \
|
||||||
touch /etc/nginx/logs/nginx.pid
|
touch /etc/nginx/logs/nginx.pid
|
||||||
|
|
||||||
# add pin script
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
ADD scripts/pinVersions.js .
|
RUN mkdir -p scripts/integrations/oracle
|
||||||
|
ADD packages/server/scripts/integrations/oracle scripts/integrations/oracle
|
||||||
# setup server and install client for oracle datasource
|
RUN /bin/bash -e ./scripts/integrations/oracle/instantclient/linux/x86-64/install.sh
|
||||||
WORKDIR /app
|
|
||||||
ADD packages/server .
|
|
||||||
RUN node /pinVersions.js && yarn && yarn build && \
|
|
||||||
/bin/bash -e scripts/integrations/oracle/instantclient/linux/x86-64/install.sh
|
|
||||||
|
|
||||||
# setup worker
|
|
||||||
WORKDIR /worker
|
|
||||||
ADD packages/worker .
|
|
||||||
RUN node /pinVersions.js && yarn && yarn build
|
|
||||||
|
|
||||||
# setup clouseau
|
# setup clouseau
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
|
@ -81,10 +94,15 @@ WORKDIR /
|
||||||
ADD hosting/single/runner.sh .
|
ADD hosting/single/runner.sh .
|
||||||
RUN chmod +x ./runner.sh
|
RUN chmod +x ./runner.sh
|
||||||
|
|
||||||
|
# cleanup cache
|
||||||
|
RUN yarn cache clean -f
|
||||||
|
|
||||||
EXPOSE 10000
|
EXPOSE 10000
|
||||||
VOLUME /opt/couchdb/data
|
VOLUME /opt/couchdb/data
|
||||||
VOLUME /minio
|
VOLUME /minio
|
||||||
|
|
||||||
# must set this just before running
|
# must set this just before running
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
WORKDIR /
|
||||||
|
|
||||||
CMD ["./runner.sh"]
|
CMD ["./runner.sh"]
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
dir=$(pwd)
|
||||||
|
mv dist /
|
||||||
|
mv package.json /
|
||||||
|
cd /
|
||||||
|
rm -r $dir
|
||||||
|
mkdir $dir
|
||||||
|
mv /dist $dir
|
||||||
|
mv /package.json $dir
|
||||||
|
cd $dir
|
||||||
|
NODE_ENV=production yarn
|
Loading…
Reference in New Issue