mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 01:53:08 +02:00
Update 3 files
- /package.json - /Dockerfile - /.gitlab-ci.yml
This commit is contained in:
parent
eab7d5bd27
commit
a7f026d480
3 changed files with 93 additions and 85 deletions
|
@ -1,36 +1,5 @@
|
||||||
stages:
|
stages:
|
||||||
- test
|
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
testCommit:
|
|
||||||
stage: test
|
|
||||||
image: node:latest
|
|
||||||
services:
|
|
||||||
- postgres:15
|
|
||||||
- redis
|
|
||||||
variables:
|
|
||||||
POSTGRES_PASSWORD: ci
|
|
||||||
script:
|
|
||||||
- apt-get update && apt-get install -y git wget curl build-essential python3
|
|
||||||
- cp .config/ci.yml .config/default.yml
|
|
||||||
- corepack enable
|
|
||||||
- corepack prepare pnpm@latest --activate
|
|
||||||
- git submodule update --init
|
|
||||||
- pnpm install --frozen-lockfile
|
|
||||||
- pnpm run build
|
|
||||||
- pnpm run migrate
|
|
||||||
cache:
|
|
||||||
key: test
|
|
||||||
policy: pull-push
|
|
||||||
when: on_success
|
|
||||||
paths:
|
|
||||||
- node_modules/
|
|
||||||
- packages/*/node_modules/
|
|
||||||
only:
|
|
||||||
- develop
|
|
||||||
- merge_requests
|
|
||||||
- stable
|
|
||||||
|
|
||||||
getImageTag:
|
getImageTag:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
image: ubuntu:latest
|
image: ubuntu:latest
|
||||||
|
@ -41,8 +10,8 @@ getImageTag:
|
||||||
tag="$CI_COMMIT_TAG"
|
tag="$CI_COMMIT_TAG"
|
||||||
elif test "$CI_COMMIT_BRANCH" == "stable"; then
|
elif test "$CI_COMMIT_BRANCH" == "stable"; then
|
||||||
tag="latest"
|
tag="latest"
|
||||||
elif test "$CI_COMMIT_BRANCH" == "develop"; then
|
elif test "$CI_COMMIT_BRANCH" == "docker-debug"; then
|
||||||
tag="develop"
|
tag="docker-debug"
|
||||||
else
|
else
|
||||||
tag="$CI_COMMIT_BRANCH"
|
tag="$CI_COMMIT_BRANCH"
|
||||||
fi
|
fi
|
||||||
|
@ -55,6 +24,8 @@ getImageTag:
|
||||||
only:
|
only:
|
||||||
- stable
|
- stable
|
||||||
- develop
|
- develop
|
||||||
|
- docker-debug
|
||||||
|
|
||||||
buildDocker:
|
buildDocker:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
needs:
|
needs:
|
||||||
|
@ -77,7 +48,7 @@ buildDocker:
|
||||||
--destination "${CI_REGISTRY_IMAGE}:${REGISTRY_PUSH_VERSION}-${ARCH}"
|
--destination "${CI_REGISTRY_IMAGE}:${REGISTRY_PUSH_VERSION}-${ARCH}"
|
||||||
only:
|
only:
|
||||||
- stable
|
- stable
|
||||||
- develop
|
- docker-debug
|
||||||
mergeManifests:
|
mergeManifests:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
needs:
|
needs:
|
||||||
|
@ -102,4 +73,4 @@ mergeManifests:
|
||||||
--target ${CI_REGISTRY_IMAGE}:${REGISTRY_PUSH_TAG}
|
--target ${CI_REGISTRY_IMAGE}:${REGISTRY_PUSH_TAG}
|
||||||
only:
|
only:
|
||||||
- stable
|
- stable
|
||||||
- develop
|
- docker-debug
|
||||||
|
|
133
Dockerfile
133
Dockerfile
|
@ -1,69 +1,106 @@
|
||||||
# syntax = docker/dockerfile:1.4
|
# syntax = docker/dockerfile:1.4
|
||||||
|
|
||||||
ARG NODE_VERSION=20.10.0-alpine3.18
|
ARG NODE_VERSION=20.10.0-bullseye
|
||||||
|
|
||||||
FROM node:${NODE_VERSION} as build
|
# build assets & compile TypeScript
|
||||||
|
|
||||||
|
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION} AS native-builder
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||||
|
--mount=type=cache,target=/var/lib/apt,sharing=locked \
|
||||||
|
rm -f /etc/apt/apt.conf.d/docker-clean \
|
||||||
|
; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache \
|
||||||
|
&& apt-get update \
|
||||||
|
&& apt-get install -yqq --no-install-recommends \
|
||||||
|
build-essential
|
||||||
|
|
||||||
RUN corepack enable
|
RUN corepack enable
|
||||||
|
|
||||||
WORKDIR /sharkey
|
WORKDIR /sharkey
|
||||||
|
|
||||||
RUN apk add git linux-headers build-base
|
COPY --link ["pnpm-lock.yaml", "pnpm-workspace.yaml", "package.json", "./"]
|
||||||
|
COPY --link ["scripts", "./scripts"]
|
||||||
|
COPY --link ["packages/backend/package.json", "./packages/backend/"]
|
||||||
|
COPY --link ["packages/frontend/package.json", "./packages/frontend/"]
|
||||||
|
COPY --link ["packages/sw/package.json", "./packages/sw/"]
|
||||||
|
COPY --link ["packages/misskey-js/package.json", "./packages/misskey-js/"]
|
||||||
|
COPY --link ["packages/misskey-reversi/package.json", "./packages/misskey-reversi/"]
|
||||||
|
COPY --link ["packages/misskey-bubble-game/package.json", "./packages/misskey-bubble-game/"]
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED=1
|
ARG NODE_ENV=production
|
||||||
RUN apk add --update python3 && ln -sf python3 /usr/bin/python
|
|
||||||
RUN python3 -m ensurepip
|
|
||||||
RUN pip3 install --no-cache --upgrade pip setuptools
|
|
||||||
|
|
||||||
COPY . ./
|
|
||||||
|
|
||||||
RUN git submodule update --init --recursive
|
|
||||||
RUN pnpm config set fetch-retries 5
|
|
||||||
RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \
|
RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \
|
||||||
pnpm i
|
pnpm i --frozen-lockfile --aggregate-output
|
||||||
|
|
||||||
|
COPY --link . ./
|
||||||
|
|
||||||
|
RUN git submodule update --init
|
||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
RUN node scripts/trim-deps.mjs
|
RUN rm -rf .git/
|
||||||
RUN mv packages/frontend/assets sharkey-assets
|
|
||||||
RUN rm -r node_modules packages/frontend packages/sw
|
|
||||||
RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \
|
|
||||||
pnpm i --prod
|
|
||||||
RUN rm -rf .git
|
|
||||||
|
|
||||||
FROM node:${NODE_VERSION}
|
# build native dependencies for target platform
|
||||||
|
|
||||||
|
FROM --platform=$TARGETPLATFORM node:${NODE_VERSION} AS target-builder
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -yqq --no-install-recommends \
|
||||||
|
build-essential
|
||||||
|
|
||||||
|
RUN corepack enable
|
||||||
|
|
||||||
WORKDIR /sharkey
|
WORKDIR /sharkey
|
||||||
|
|
||||||
RUN apk add ffmpeg tini
|
COPY --link ["pnpm-lock.yaml", "pnpm-workspace.yaml", "package.json", "./"]
|
||||||
|
COPY --link ["scripts", "./scripts"]
|
||||||
|
COPY --link ["packages/backend/package.json", "./packages/backend/"]
|
||||||
|
COPY --link ["packages/misskey-js/package.json", "./packages/misskey-js/"]
|
||||||
|
COPY --link ["packages/misskey-reversi/package.json", "./packages/misskey-reversi/"]
|
||||||
|
COPY --link ["packages/misskey-bubble-game/package.json", "./packages/misskey-bubble-game/"]
|
||||||
|
|
||||||
COPY --from=build /sharkey/built ./built
|
ARG NODE_ENV=production
|
||||||
COPY --from=build /sharkey/node_modules ./node_modules
|
|
||||||
COPY --from=build /sharkey/packages/backend/built ./packages/backend/built
|
|
||||||
COPY --from=build /sharkey/packages/backend/node_modules ./packages/backend/node_modules
|
|
||||||
COPY --from=build /sharkey/packages/megalodon/lib ./packages/megalodon/lib
|
|
||||||
COPY --from=build /sharkey/packages/megalodon/node_modules ./packages/megalodon/node_modules
|
|
||||||
COPY --from=build /sharkey/packages/misskey-js/built ./packages/misskey-js/built
|
|
||||||
COPY --from=build /sharkey/packages/misskey-js/node_modules ./packages/misskey-js/node_modules
|
|
||||||
COPY --from=build /sharkey/packages/misskey-reversi/built ./packages/misskey-reversi/built
|
|
||||||
COPY --from=build /sharkey/packages/misskey-reversi/node_modules ./packages/misskey-reversi/node_modules
|
|
||||||
COPY --from=build /sharkey/packages/misskey-bubble-game/built ./packages/misskey-bubble-game/built
|
|
||||||
COPY --from=build /sharkey/packages/misskey-bubble-game/node_modules ./packages/misskey-bubble-game/node_modules
|
|
||||||
COPY --from=build /sharkey/fluent-emojis ./fluent-emojis
|
|
||||||
COPY --from=build /sharkey/tossface-emojis/dist ./tossface-emojis/dist
|
|
||||||
COPY --from=build /sharkey/sharkey-assets ./packages/frontend/assets
|
|
||||||
|
|
||||||
COPY package.json ./package.json
|
RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \
|
||||||
COPY pnpm-workspace.yaml ./pnpm-workspace.yaml
|
pnpm i --frozen-lockfile --aggregate-output
|
||||||
COPY packages/backend/package.json ./packages/backend/package.json
|
|
||||||
COPY packages/backend/check_connect.js ./packages/backend/check_connect.js
|
|
||||||
COPY packages/backend/ormconfig.js ./packages/backend/ormconfig.js
|
|
||||||
COPY packages/backend/migration ./packages/backend/migration
|
|
||||||
COPY packages/backend/assets ./packages/backend/assets
|
|
||||||
COPY packages/megalodon/package.json ./packages/megalodon/package.json
|
|
||||||
COPY packages/misskey-js/package.json ./packages/misskey-js/package.json
|
|
||||||
COPY packages/misskey-reversi/package.json ./packages/misskey-reversi/package.json
|
|
||||||
COPY packages/misskey-bubble-game/package.json ./packages/misskey-bubble-game/package.json
|
|
||||||
|
|
||||||
|
FROM --platform=$TARGETPLATFORM node:${NODE_VERSION}-slim AS runner
|
||||||
|
|
||||||
|
ARG UID="991"
|
||||||
|
ARG GID="991"
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
ffmpeg tini curl libjemalloc-dev libjemalloc2 \
|
||||||
|
&& ln -s /usr/lib/$(uname -m)-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so \
|
||||||
|
&& corepack enable \
|
||||||
|
&& groupadd -g "${GID}" sharkey \
|
||||||
|
&& useradd -l -u "${UID}" -g "${GID}" -m -d /sharkey sharkey \
|
||||||
|
&& find / -type d -path /sys -prune -o -type d -path /proc -prune -o -type f -perm /u+s -ignore_readdir_race -exec chmod u-s {} \; \
|
||||||
|
&& find / -type d -path /sys -prune -o -type d -path /proc -prune -o -type f -perm /g+s -ignore_readdir_race -exec chmod g-s {} \; \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists
|
||||||
|
|
||||||
|
USER sharkey
|
||||||
|
WORKDIR /sharkey
|
||||||
|
|
||||||
|
COPY --chown=sharkey:sharkey --from=target-builder /sharkey/node_modules ./node_modules
|
||||||
|
COPY --chown=sharkey:sharkey --from=target-builder /sharkey/packages/backend/node_modules ./packages/backend/node_modules
|
||||||
|
COPY --chown=sharkey:sharkey --from=target-builder /sharkey/packages/misskey-js/node_modules ./packages/misskey-js/node_modules
|
||||||
|
COPY --chown=sharkey:sharkey --from=target-builder /sharkey/packages/misskey-reversi/node_modules ./packages/misskey-reversi/node_modules
|
||||||
|
COPY --chown=sharkey:sharkey --from=target-builder /sharkey/packages/misskey-bubble-game/node_modules ./packages/misskey-bubble-game/node_modules
|
||||||
|
COPY --chown=sharkey:sharkey --from=native-builder /sharkey/built ./built
|
||||||
|
COPY --chown=sharkey:sharkey --from=native-builder /sharkey/packages/misskey-js/built ./packages/misskey-js/built
|
||||||
|
COPY --chown=sharkey:sharkey --from=native-builder /sharkey/packages/misskey-reversi/built ./packages/misskey-reversi/built
|
||||||
|
COPY --chown=sharkey:sharkey --from=native-builder /sharkey/packages/misskey-bubble-game/built ./packages/misskey-bubble-game/built
|
||||||
|
COPY --chown=sharkey:sharkey --from=native-builder /sharkey/packages/backend/built ./packages/backend/built
|
||||||
|
COPY --chown=sharkey:sharkey --from=native-builder /sharkey/fluent-emojis /misskey/fluent-emojis
|
||||||
|
COPY --chown=sharkey:sharkey --from=native-builder /sharkey/packages/megalodon/node_modules ./packages/megalodon/node_modules
|
||||||
|
COPY --chown=sharkey:sharkey --from=native-builder /sharkey/packages/misskey-js/built ./packages/misskey-js/built
|
||||||
|
COPY --chown=sharkey:sharkey --from=native-builder /sharkey/tossface-emojis/dist ./tossface-emojis/dist
|
||||||
|
|
||||||
|
COPY --chown=sharkey:sharkey . ./
|
||||||
|
|
||||||
|
ENV LD_PRELOAD=/usr/local/lib/libjemalloc.so
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
RUN corepack enable
|
HEALTHCHECK --interval=5s --retries=20 CMD ["/bin/bash", "/sharkey/healthcheck.sh"]
|
||||||
ENTRYPOINT ["/sbin/tini", "--"]
|
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||||
CMD ["pnpm", "run", "migrateandstart"]
|
CMD ["pnpm", "run", "migrateandstart"]
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "sharkey",
|
"name": "sharkey",
|
||||||
"version": "2024.2.0-beta.12",
|
"version": "2024.2.0-beta.12-docker-debug",
|
||||||
"codename": "shonk",
|
"codename": "shonk",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
Loading…
Reference in a new issue