Sharkey/Dockerfile

87 lines
4.3 KiB
Text
Raw Normal View History

2023-12-08 00:34:37 +00:00
# syntax = docker/dockerfile:1.4
ARG NODE_VERSION=20.16.0-alpine3.20
2023-12-08 00:34:37 +00:00
FROM node:${NODE_VERSION} as build
2023-12-08 01:08:26 +00:00
RUN apk add git linux-headers build-base
2023-12-08 00:34:37 +00:00
2023-12-08 01:01:40 +00:00
ENV PYTHONUNBUFFERED=1
RUN apk add --update python3 && ln -sf python3 /usr/bin/python
RUN apk add py3-pip py3-setuptools
2023-12-08 01:01:40 +00:00
2024-03-08 16:13:47 +00:00
RUN corepack enable
WORKDIR /sharkey
COPY --link . ./
2023-12-08 00:34:37 +00:00
2023-12-08 00:54:09 +00:00
RUN git submodule update --init --recursive
2023-12-08 00:34:37 +00:00
RUN pnpm config set fetch-retries 5
RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \
2024-03-08 16:13:47 +00:00
pnpm i --frozen-lockfile --aggregate-output
2023-12-08 00:34:37 +00:00
RUN pnpm build
RUN node scripts/trim-deps.mjs
RUN mv packages/frontend/assets sharkey-assets
RUN mv packages/frontend-embed/assets sharkey-embed-assets
2024-03-08 16:13:47 +00:00
RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \
pnpm prune
RUN rm -r node_modules packages/frontend packages/frontend-shared packages/frontend-embed packages/sw
2023-12-08 00:34:37 +00:00
RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \
2024-03-08 16:13:47 +00:00
pnpm i --prod --frozen-lockfile --aggregate-output
2023-12-08 00:34:37 +00:00
RUN rm -rf .git
FROM node:${NODE_VERSION}
2024-03-08 16:13:47 +00:00
ARG UID="991"
ARG GID="991"
2023-12-08 00:34:37 +00:00
2024-03-08 16:13:47 +00:00
RUN apk add ffmpeg tini jemalloc \
&& corepack enable \
&& addgroup -g "${GID}" sharkey \
&& adduser -D -u "${UID}" -G sharkey -h /sharkey sharkey \
2024-11-07 20:09:01 +00:00
&& mkdir /sharkey/files \
&& chown sharkey:sharkey /sharkey/files \
2024-03-08 16:13:47 +00:00
&& find / -type d -path /sys -prune -o -type d -path /proc -prune -o -type f -perm /u+s -exec chmod u-s {} \; \
&& find / -type d -path /sys -prune -o -type d -path /proc -prune -o -type f -perm /g+s -exec chmod g-s {} \;
2023-12-08 00:34:37 +00:00
2024-03-08 16:13:47 +00:00
USER sharkey
WORKDIR /sharkey
# add package.json to add pnpm
COPY --chown=sharkey:sharkey ./package.json ./package.json
RUN corepack install
2024-03-08 16:13:47 +00:00
COPY --chown=sharkey:sharkey --from=build /sharkey/node_modules ./node_modules
COPY --chown=sharkey:sharkey --from=build /sharkey/packages/backend/node_modules ./packages/backend/node_modules
COPY --chown=sharkey:sharkey --from=build /sharkey/packages/misskey-js/node_modules ./packages/misskey-js/node_modules
COPY --chown=sharkey:sharkey --from=build /sharkey/packages/misskey-reversi/node_modules ./packages/misskey-reversi/node_modules
COPY --chown=sharkey:sharkey --from=build /sharkey/packages/misskey-bubble-game/node_modules ./packages/misskey-bubble-game/node_modules
COPY --chown=sharkey:sharkey --from=build /sharkey/packages/megalodon/node_modules ./packages/megalodon/node_modules
COPY --chown=sharkey:sharkey --from=build /sharkey/built ./built
COPY --chown=sharkey:sharkey --from=build /sharkey/packages/misskey-js/built ./packages/misskey-js/built
COPY --chown=sharkey:sharkey --from=build /sharkey/packages/misskey-reversi/built ./packages/misskey-reversi/built
COPY --chown=sharkey:sharkey --from=build /sharkey/packages/misskey-bubble-game/built ./packages/misskey-bubble-game/built
COPY --chown=sharkey:sharkey --from=build /sharkey/packages/backend/built ./packages/backend/built
COPY --chown=sharkey:sharkey --from=build /sharkey/packages/megalodon/lib ./packages/megalodon/lib
COPY --chown=sharkey:sharkey --from=build /sharkey/fluent-emojis ./fluent-emojis
COPY --chown=sharkey:sharkey --from=build /sharkey/tossface-emojis/dist ./tossface-emojis/dist
COPY --chown=sharkey:sharkey --from=build /sharkey/sharkey-assets ./packages/frontend/assets
COPY --chown=sharkey:sharkey --from=build /sharkey/sharkey-embed-assets ./packages/frontend-embed/assets
2023-12-08 00:34:37 +00:00
2024-03-08 16:13:47 +00:00
COPY --chown=sharkey:sharkey pnpm-workspace.yaml ./pnpm-workspace.yaml
COPY --chown=sharkey:sharkey packages/backend/package.json ./packages/backend/package.json
COPY --chown=sharkey:sharkey packages/backend/scripts/check_connect.js ./packages/backend/scripts/check_connect.js
2024-03-08 16:13:47 +00:00
COPY --chown=sharkey:sharkey packages/backend/ormconfig.js ./packages/backend/ormconfig.js
COPY --chown=sharkey:sharkey packages/backend/migration ./packages/backend/migration
COPY --chown=sharkey:sharkey packages/backend/assets ./packages/backend/assets
COPY --chown=sharkey:sharkey packages/megalodon/package.json ./packages/megalodon/package.json
COPY --chown=sharkey:sharkey packages/misskey-js/package.json ./packages/misskey-js/package.json
COPY --chown=sharkey:sharkey packages/misskey-reversi/package.json ./packages/misskey-reversi/package.json
COPY --chown=sharkey:sharkey packages/misskey-bubble-game/package.json ./packages/misskey-bubble-game/package.json
2023-12-08 00:34:37 +00:00
2024-03-08 16:13:47 +00:00
ENV LD_PRELOAD=/usr/lib/libjemalloc.so.2
2023-12-08 00:34:37 +00:00
ENV NODE_ENV=production
2023-12-08 01:44:53 +00:00
ENTRYPOINT ["/sbin/tini", "--"]
2023-12-08 00:34:37 +00:00
CMD ["pnpm", "run", "migrateandstart"]