Browse Source

modify Dockerfile to use multi-stage builds

Signed-off-by: Azri Kahar <azrikahar@outlook.com>
pull/293/head
azrikahar 3 years ago committed by Azri Kahar
parent
commit
d665c4149e
  1. 64
      packages/nocodb/Dockerfile

64
packages/nocodb/Dockerfile

@ -1,52 +1,44 @@
FROM alpine:3.12
# Bug fix for segfault ( Convert PT_GNU_STACK program header into PT_PAX_FLAGS )
#RUN apk --update --no-cache add paxctl \
# && paxctl -cm $(which node)
###########
# Builder
###########
FROM node:12 as builder
WORKDIR /usr/src/app
ENV NODE_ENV production
ENV NC_VERSION 0.6
ENV NC_DOCKER 0.6
ENV PORT 8080
ENV NODE_ENV=dev
#ENV TOOL_DIR=/tool
ENV NC_VERSION=0.6
ENV NC_DOCKER=0.6
# Create and change to the app directory.
WORKDIR /usr/src/appTemp
# Copy application dependency manifests to the container image.
# A wildcard is used to ensure both package.json AND package-lock.json are copied.
# Copying this separately prevents re-running npm install on every code change.
#COPY ./build/ ./build/
# Copying this separately prevents re-running npm ci on every code change.
COPY ./package*.json ./
COPY ./docker/main.js ./docker/main.js
COPY ./package.json ./
COPY ./docker/start.sh /usr/src/appEntry/start.sh
# Install production dependencies.
#RUN npm i ../xc-lib-gui/ && npm install --cache=/usr/src/app/cache --production && npx modclean --patterns="default:*" --run && rm -rf /usr/src/app/cache && rm -rf /root/.npm
RUN apk --update --no-cache add \
nodejs \
nodejs-npm \
tar\
&& npm install --cache=/usr/src/app/cache --production \
# install production dependencies,
# reduce node_module size with modclean & removing sqlite deps,
# package built code into app.tar.gz & add execute permission to start.sh
RUN npm ci --production --quiet \
&& npx modclean --patterns="default:*" --ignore="nc-lib-gui/**,dayjs/**,express-status-monitor/**" --run \
&& rm -rf ./node_modules/sqlite3/deps \
# && rm -rf ./node_modules/nc-lib-gui/lib/dist/_nuxt \
&& rm -rf /usr/src/app/cache && rm -rf /root/.npm \
&& apk del nodejs-npm \
&& tar -czf ../appEntry/app.tar.gz ./* ; rm -rf ./* && chmod +x /usr/src/appEntry/start.sh
&& tar -czf ../appEntry/app.tar.gz ./* \
&& chmod +x /usr/src/appEntry/start.sh
#COPY ./node_modules/xc-lib/ ./node_modules/xc-lib/
#COPY ./node_modules/xc-lib-gui/ ./node_modules/xc-lib-gui/
##########
# Runner
##########
FROM alpine:3.12
WORKDIR /usr/src/app
# Run the web service on container startup.
#CMD [ "node", "docker/index.js" ]
ENTRYPOINT ["sh", "/usr/src/appEntry/start.sh"]
RUN apk --update --no-cache add \
nodejs \
tar
# Copy packaged production code & main entry file
COPY --from=builder /usr/src/appEntry/ /usr/src/appEntry/
EXPOSE 8080
# Start Nocodb
ENTRYPOINT ["sh", "/usr/src/appEntry/start.sh"]
Loading…
Cancel
Save