|
|
|
@ -1,4 +1,40 @@
|
|
|
|
|
FROM alpine:3.12 |
|
|
|
|
FROM golang:alpine3.14 as lt |
|
|
|
|
|
|
|
|
|
WORKDIR /usr/src/ |
|
|
|
|
|
|
|
|
|
RUN apk add --no-cache git make musl-dev gcc |
|
|
|
|
|
|
|
|
|
# build litestream |
|
|
|
|
RUN git clone https://github.com/benbjohnson/litestream.git litestream |
|
|
|
|
RUN cd litestream ; go install ./cmd/litestream |
|
|
|
|
|
|
|
|
|
RUN cp $GOPATH/bin/litestream /usr/src/lt |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FROM node:12 as builder |
|
|
|
|
WORKDIR /usr/src/app |
|
|
|
|
|
|
|
|
|
# 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 ci on every code change. |
|
|
|
|
COPY ./package*.json ./ |
|
|
|
|
COPY ./docker/main.js ./docker/main.js |
|
|
|
|
#COPY ./docker/start.sh /usr/src/appEntry/start.sh |
|
|
|
|
COPY ./docker/start-litestream.sh /usr/src/appEntry/start.sh |
|
|
|
|
# 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 |
|
|
|
|
RUN npx modclean --patterns="default:*" --ignore="nc-lib-gui/**,dayjs/**,express-status-monitor/**" --run |
|
|
|
|
RUN rm -rf ./node_modules/sqlite3/deps |
|
|
|
|
RUN tar -czf ../appEntry/app.tar.gz ./* |
|
|
|
|
RUN chmod +x /usr/src/appEntry/start.sh |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FROM alpine:3.14 |
|
|
|
|
|
|
|
|
|
#ENV AWS_ACCESS_KEY_ID= |
|
|
|
|
#ENV AWS_SECRET_ACCESS_KEY= |
|
|
|
@ -28,41 +64,29 @@ FROM alpine:3.12
|
|
|
|
|
#RUN apk --update --no-cache add paxctl \ |
|
|
|
|
# && paxctl -cm $(which node) |
|
|
|
|
|
|
|
|
|
WORKDIR /usr/src/app |
|
|
|
|
|
|
|
|
|
ENV NC_DOCKER 0.6 |
|
|
|
|
ENV PORT 8080 |
|
|
|
|
ENV NODE_ENV=dev |
|
|
|
|
#ENV TOOL_DIR=/tool |
|
|
|
|
ENV NC_VERSION=0.6 |
|
|
|
|
ENV NC_TOOL_DIR=/usr/app/data/ |
|
|
|
|
|
|
|
|
|
# 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/ |
|
|
|
|
COPY ./docker/main.js ./docker/main.js |
|
|
|
|
COPY ./package.json ./ |
|
|
|
|
COPY ./docker/start-litestream.sh /usr/src/appEntry/start.sh |
|
|
|
|
COPY ./litestream/litestream /usr/src/appEntry/litestream |
|
|
|
|
#COPY ./docker/main.js ./docker/main.js |
|
|
|
|
#COPY ./package.json ./ |
|
|
|
|
|
|
|
|
|
# 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 \ |
|
|
|
|
&& npx modclean --patterns="default:*" --ignore="xc-lib-gui/**,dayjs/**,express-status-monitor/**" --run \ |
|
|
|
|
&& rm -rf ./node_modules/sqlite3/deps \ |
|
|
|
|
&& rm -rf ./node_modules/xc-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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#COPY ./node_modules/xc-lib/ ./node_modules/xc-lib/ |
|
|
|
|
#COPY ./node_modules/xc-lib-gui/ ./node_modules/xc-lib-gui/ |
|
|
|
|
WORKDIR /usr/src/app |
|
|
|
|
nodejs \ |
|
|
|
|
tar |
|
|
|
|
|
|
|
|
|
# Copy litestream binary build |
|
|
|
|
COPY --from=lt /usr/src/lt /usr/src/appEntry/litestream |
|
|
|
|
# Copy packaged production code & main entry file |
|
|
|
|
COPY --from=builder /usr/src/appEntry/ /usr/src/appEntry/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Run the web service on container startup. |
|
|
|
|
#CMD [ "node", "docker/index.js" ] |
|
|
|
|