|
1 | 1 | ARG APP_PATH=/opt/outline
|
2 |
| -FROM outlinewiki/outline-base AS base |
| 2 | +FROM node:20-slim AS builder |
3 | 3 |
|
4 | 4 | ARG APP_PATH
|
5 | 5 | WORKDIR $APP_PATH
|
| 6 | +COPY ./package.json ./yarn.lock ./ |
| 7 | +COPY ./patches ./patches |
| 8 | + |
| 9 | +RUN yarn install --no-optional --frozen-lockfile --network-timeout 1000000 && \ |
| 10 | + yarn cache clean |
| 11 | + |
| 12 | +COPY . . |
| 13 | +ARG CDN_URL |
| 14 | +RUN yarn build |
| 15 | + |
| 16 | +RUN rm -rf node_modules |
| 17 | +RUN yarn install --production=true --frozen-lockfile --network-timeout 1000000 && \ |
| 18 | + yarn cache clean |
6 | 19 |
|
7 |
| -# --- |
8 | 20 | FROM node:20-slim AS runner
|
9 | 21 |
|
10 |
| -LABEL org.opencontainers.image.source="https://github.com/outline/outline" |
| 22 | +LABEL org.opencontainers.image.source="https://github.com/eagletrt/outline" |
11 | 23 |
|
12 | 24 | ARG APP_PATH
|
13 | 25 | WORKDIR $APP_PATH
|
14 | 26 | ENV NODE_ENV=production
|
| 27 | +ENV PORT=3000 |
| 28 | +ENV FILE_STORAGE_LOCAL_ROOT_DIR=/var/lib/outline/data |
15 | 29 |
|
16 |
| -COPY --from=base $APP_PATH/build ./build |
17 |
| -COPY --from=base $APP_PATH/server ./server |
18 |
| -COPY --from=base $APP_PATH/public ./public |
19 |
| -COPY --from=base $APP_PATH/.sequelizerc ./.sequelizerc |
20 |
| -COPY --from=base $APP_PATH/node_modules ./node_modules |
21 |
| -COPY --from=base $APP_PATH/package.json ./package.json |
22 |
| - |
23 |
| -# Install wget to healthcheck the server |
24 |
| -RUN apt-get update \ |
25 |
| - && apt-get install -y wget \ |
26 |
| - && rm -rf /var/lib/apt/lists/* |
| 30 | +COPY --from=builder $APP_PATH/build ./build |
| 31 | +COPY --from=builder $APP_PATH/server ./server |
| 32 | +COPY --from=builder $APP_PATH/public ./public |
| 33 | +COPY --from=builder $APP_PATH/.sequelizerc ./.sequelizerc |
| 34 | +COPY --from=builder $APP_PATH/node_modules ./node_modules |
| 35 | +COPY --from=builder $APP_PATH/package.json ./package.json |
27 | 36 |
|
28 |
| -# Create a non-root user compatible with Debian and BusyBox based images |
| 37 | +# Create a non-root user for better security |
29 | 38 | RUN addgroup --gid 1001 nodejs && \
|
30 | 39 | adduser --uid 1001 --ingroup nodejs nodejs && \
|
31 |
| - chown -R nodejs:nodejs $APP_PATH/build && \ |
32 |
| - mkdir -p /var/lib/outline && \ |
33 |
| - chown -R nodejs:nodejs /var/lib/outline |
34 |
| - |
35 |
| -ENV FILE_STORAGE_LOCAL_ROOT_DIR=/var/lib/outline/data |
36 |
| -RUN mkdir -p "$FILE_STORAGE_LOCAL_ROOT_DIR" && \ |
37 |
| - chown -R nodejs:nodejs "$FILE_STORAGE_LOCAL_ROOT_DIR" && \ |
38 |
| - chmod 1777 "$FILE_STORAGE_LOCAL_ROOT_DIR" |
| 40 | + mkdir -p $FILE_STORAGE_LOCAL_ROOT_DIR && \ |
| 41 | + chown -R nodejs:nodejs $APP_PATH && \ |
| 42 | + chown -R nodejs:nodejs $FILE_STORAGE_LOCAL_ROOT_DIR && \ |
| 43 | + chmod 1777 $FILE_STORAGE_LOCAL_ROOT_DIR |
39 | 44 |
|
40 | 45 | VOLUME /var/lib/outline/data
|
41 | 46 |
|
42 | 47 | USER nodejs
|
43 |
| - |
44 |
| -HEALTHCHECK --interval=1m CMD wget -qO- "http://localhost:${PORT:-3000}/_health" | grep -q "OK" || exit 1 |
45 |
| - |
46 | 48 | EXPOSE 3000
|
47 | 49 | CMD ["yarn", "start"]
|
0 commit comments