Compare commits

...

7 Commits

Author SHA1 Message Date
Tom Moor 1edde31ce0 0.58.0-4 2021-08-03 09:51:14 -07:00
Tom Moor 3d5cd4c8e4 Merge branch 'feat/optimize-dockerfile' of https://github.com/lolPants/outline into lolPants-feat/optimize-dockerfile 2021-08-03 09:50:43 -07:00
Jack Baron 7585b54adb revert: mark yarn-deduplicate as a required dep
no longer required as of 0b3adad751
2021-07-19 22:48:29 +01:00
Jack Baron a3dbec5091 fix: use correct ARG syntax for multistage builds 2021-07-18 00:52:17 +01:00
Jack Baron cba3382b95 fix: add sequelize required files for migrations 2021-07-17 23:57:30 +01:00
Jack Baron 2d2626d175 fix: mark yarn-deduplicate as a required dep
`yarn --production` will fail on a clean install otherwise
2021-07-17 13:49:42 +01:00
Jack Baron e017133d24 feat: optimize dockerfile
use new dockerfile syntaxes
leverage multi-stage builds
strip yarn cache from image
use stricter yarn install command
run as a non-root user
2021-07-17 13:49:09 +01:00
2 changed files with 40 additions and 14 deletions
+39 -13
View File
@@ -1,23 +1,49 @@
FROM node:14-alpine
# syntax=docker/dockerfile:1.2
ARG APP_PATH=/opt/outline
FROM node:14-alpine AS deps-common
ENV APP_PATH /opt/outline
RUN mkdir -p $APP_PATH
ARG APP_PATH
WORKDIR $APP_PATH
COPY ./package.json ./yarn.lock ./
# ---
FROM deps-common AS deps-dev
RUN yarn install --no-optional --frozen-lockfile && \
yarn cache clean
# ---
FROM deps-common AS deps-prod
RUN yarn install --production=true --frozen-lockfile && \
yarn cache clean
# ---
FROM node:14-alpine AS builder
ARG APP_PATH
WORKDIR $APP_PATH
COPY package.json ./
COPY yarn.lock ./
RUN yarn --pure-lockfile
COPY . .
COPY --from=deps-dev $APP_PATH/node_modules ./node_modules
RUN yarn build
RUN yarn build && \
yarn --production --ignore-scripts --prefer-offline && \
rm -rf shared && \
rm -rf app
# ---
FROM node:14-alpine AS runner
ARG APP_PATH
WORKDIR $APP_PATH
ENV NODE_ENV production
CMD yarn start
COPY --from=builder $APP_PATH/build ./build
COPY --from=builder $APP_PATH/server ./server
COPY --from=builder $APP_PATH/.sequelizerc ./.sequelizerc
COPY --from=deps-prod $APP_PATH/node_modules ./node_modules
COPY --from=builder $APP_PATH/package.json ./package.json
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001 && \
chown -R nodejs:nodejs $APP_PATH/build
USER nodejs
EXPOSE 3000
CMD ["yarn", "start"]
+1 -1
View File
@@ -211,5 +211,5 @@
"dot-prop": "^5.2.0",
"js-yaml": "^3.13.1"
},
"version": "0.58.0-3"
"version": "0.58.0-4"
}