Yuki Takei 6 лет назад
Родитель
Сommit
81ce59b13a
2 измененных файлов с 46 добавлено и 24 удалено
  1. 37 24
      docker/Dockerfile
  2. 9 0
      docker/bin/symlink-for-uploading-to-local.sh

+ 37 - 24
docker/Dockerfile

@@ -1,4 +1,7 @@
-FROM node:12-slim
+##
+## STAGE 1
+##
+FROM node:12-slim AS builder
 LABEL maintainer Yuki Takei <yuki@weseek.co.jp>
 
 ENV APP_VERSION v3.5.13
@@ -6,36 +9,46 @@ ENV APP_DIR /opt/growi
 ARG ARCHIVE_NAME=${APP_VERSION}
 
 # update tar for '--strip-components' option
-RUN apk add --no-cache --update tar
+# RUN apk add --no-cache --update tar
 # download GROWI archive from Github
-RUN apk add --no-cache --virtual .dl-deps curl \
-    && mkdir -p ${APP_DIR} \
-    && curl -SL https://github.com/weseek/growi/archive/${ARCHIVE_NAME}.tar.gz \
-        | tar -xz -C ${APP_DIR} --strip-components 1 \
-    && apk del .dl-deps
+# RUN apk add --no-cache --virtual .dl-deps curl \
+RUN mkdir -p ${APP_DIR}
+RUN curl -SL https://github.com/weseek/growi/archive/${ARCHIVE_NAME}.tar.gz \
+    | tar -xz -C ${APP_DIR} --strip-components 1
 
 WORKDIR ${APP_DIR}
 
 # setup
-RUN apk add --no-cache --virtual .build-deps git \
-    && yarn config set network-timeout 300000 \
-    && yarn \
-    # install official plugins
-    && yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs \
-    # install peerDependencies
-    && yarn add -D react-images react-motion \
-    # build
-    && npm run build:prod \
-    # shrink dependencies for production
-    && yarn install --production \
-    && yarn cache clean \
-    && apk del .build-deps
-
-COPY docker-entrypoint.sh /
-RUN chmod +x /docker-entrypoint.sh
+RUN yarn config set network-timeout 300000
+RUN yarn
+# install official plugins
+RUN yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs
+# install peerDependencies
+RUN yarn add -D react-images react-motion
+# build
+RUN npm run build:prod
+# shrink dependencies for production
+RUN yarn install --production
+
+##
+## STAGE 2
+##
+FROM node:12-alpine
+LABEL maintainer Yuki Takei <yuki@weseek.co.jp>
+
+ENV APP_DIR /opt/growi
+
+# install tini
+RUN apk add --no-cache tini
+
+USER node
+
+COPY --from=builder ${APP_DIR} ${APP_DIR}
+
+WORKDIR ${APP_DIR}
 
 VOLUME /data
 EXPOSE 3000
 
-ENTRYPOINT ["/docker-entrypoint.sh"]
+ENTRYPOINT ["/sbin/tini", "-e", "143", "--"]
 CMD ["npm", "run", "server:prod"]

+ 9 - 0
docker/bin/symlink-for-uploading-to-local.sh

@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -e
+
+# Corresponds to `FILE_UPLOAD=local`
+mkdir -p /data/uploads
+if [ ! -e "$APP_DIR/public/uploads" ]; then
+  ln -s /data/uploads $APP_DIR/public/uploads
+fi