2022-11-02 11:24:45 -04:00
|
|
|
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: CC-BY-SA-4.0
|
|
|
|
|
|
|
|
# BUILD
|
2023-01-06 23:11:31 -05:00
|
|
|
FROM docker.io/node:18-alpine@sha256:b3f383c13d71066a4e2380d42f4563ac14ac76b3035a5bea4db84209e14665d5 AS builder
|
2022-11-02 11:24:45 -04:00
|
|
|
ENV NODE_ENV=production
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
ARG BUILD_VERSION=CLIENT_VERSION_MISSING
|
|
|
|
|
|
|
|
ENV YARN_CACHE_FOLDER /tmp/.yarn
|
|
|
|
USER node
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
|
|
|
COPY --chown=node .yarn/plugins .yarn/plugins
|
2022-12-04 16:42:39 -05:00
|
|
|
COPY --chown=node .yarn/patches .yarn/patches
|
2022-11-02 11:24:45 -04:00
|
|
|
COPY --chown=node .yarn/releases .yarn/releases
|
|
|
|
COPY --chown=node .yarnrc.yml .yarnrc.yml
|
|
|
|
COPY --chown=node package.json package.json
|
|
|
|
COPY --chown=node yarn.lock yarn.lock
|
|
|
|
COPY --chown=node backend/package.json backend/
|
2022-12-04 16:42:39 -05:00
|
|
|
COPY --chown=node commons commons
|
2022-11-02 11:24:45 -04:00
|
|
|
COPY --chown=node frontend frontend
|
|
|
|
RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/tmp/.yarn \
|
|
|
|
yarn install --immutable && yarn workspaces focus @hedgedoc/frontend
|
|
|
|
|
2022-12-04 16:42:39 -05:00
|
|
|
WORKDIR /usr/src/app/commons
|
|
|
|
|
|
|
|
RUN yarn build
|
|
|
|
|
2022-11-02 11:24:45 -04:00
|
|
|
WORKDIR /usr/src/app/frontend
|
|
|
|
|
|
|
|
RUN rm -rf public/public && \
|
|
|
|
rm -rf src/pages/api && \
|
|
|
|
sed -i "s/CLIENT_VERSION_MISSING/${BUILD_VERSION}/" src/version.json
|
|
|
|
RUN yarn build
|
|
|
|
|
|
|
|
# RUNNER
|
2023-01-06 23:11:31 -05:00
|
|
|
FROM docker.io/node:18-alpine@sha256:b3f383c13d71066a4e2380d42f4563ac14ac76b3035a5bea4db84209e14665d5
|
2022-11-02 11:24:45 -04:00
|
|
|
ENV NODE_ENV=production
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
|
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
|
|
|
COPY --from=builder --chown=node:node /usr/src/app/frontend/.next/standalone ./
|
|
|
|
COPY --from=builder --chown=node:node /usr/src/app/frontend/.next/static ./.next/static
|
|
|
|
COPY --from=builder /usr/src/app/frontend/next.config.js next.config.js
|
|
|
|
COPY --from=builder /usr/src/app/frontend/public ./public
|
|
|
|
|
|
|
|
USER node
|
|
|
|
|
|
|
|
ENV PORT 3001
|
|
|
|
EXPOSE 3001/tcp
|
|
|
|
CMD ["node", "frontend/server.js"]
|