Răsfoiți Sursa

WIP: multi stage for nocdn

Yuki Takei 6 ani în urmă
părinte
comite
3b1c3a9d05
2 a modificat fișierele cu 45 adăugiri și 3 ștergeri
  1. 39 3
      docker/Dockerfile
  2. 6 0
      docker/nocdn/env.prod.js

+ 39 - 3
docker/Dockerfile

@@ -1,7 +1,9 @@
+# syntax = docker/dockerfile:experimental
+
 ##
 ##
-## STAGE 1
+## setupper-default
 ##
 ##
-FROM node:12-slim AS builder
+FROM node:12-slim AS setupper
 LABEL maintainer Yuki Takei <yuki@weseek.co.jp>
 LABEL maintainer Yuki Takei <yuki@weseek.co.jp>
 
 
 ENV APP_VERSION v3.5.13
 ENV APP_VERSION v3.5.13
@@ -23,13 +25,45 @@ RUN yarn
 RUN yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs
 RUN yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs
 # install peerDependencies
 # install peerDependencies
 RUN yarn add -D react-images react-motion
 RUN yarn add -D react-images react-motion
+
+
+##
+## setupper-nocdn
+##
+FROM node:12-slim AS setupper-nocdn
+
+ENV APP_DIR /opt/growi
+
+COPY --from=setupper ${APP_DIR} ${APP_DIR}
+
+WORKDIR ${APP_DIR}
+
+# replace env.prod.js for NO_CDN
+COPY nocdn/env.prod.js config
+
+
+##
+## builder
+##
+FROM node:12-slim AS builder
+LABEL maintainer Yuki Takei <yuki@weseek.co.jp>
+
+ENV APP_DIR /opt/growi
+ARG FLAVOR=default
+
+COPY --from=setupper-${FLAVOR} ${APP_DIR} ${APP_DIR}
+
+WORKDIR ${APP_DIR}
+
 # build
 # build
 RUN npm run build:prod
 RUN npm run build:prod
 # shrink dependencies for production
 # shrink dependencies for production
 RUN yarn install --production
 RUN yarn install --production
 
 
+
+
 ##
 ##
-## STAGE 2
+## release
 ##
 ##
 FROM node:12-alpine
 FROM node:12-alpine
 LABEL maintainer Yuki Takei <yuki@weseek.co.jp>
 LABEL maintainer Yuki Takei <yuki@weseek.co.jp>
@@ -45,6 +79,8 @@ COPY --from=builder ${APP_DIR} ${APP_DIR}
 
 
 WORKDIR ${APP_DIR}
 WORKDIR ${APP_DIR}
 
 
+RUN --mount=target=. sh bin/symlink-for-uploading-to-local.sh
+
 VOLUME /data
 VOLUME /data
 EXPOSE 3000
 EXPOSE 3000
 
 

+ 6 - 0
docker/nocdn/env.prod.js

@@ -0,0 +1,6 @@
+module.exports = {
+    NODE_ENV: 'production',
+    NO_CDN: true,
+    // FORMAT_NODE_LOG: false,
+  };
+