Skip to content

Commit

Permalink
chore(build): remove corepack & fetch gitmodules on checkout (#840)
Browse files Browse the repository at this point in the history
  • Loading branch information
u1-liquid authored Dec 24, 2024
1 parent 4ecfae0 commit 303a521
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM mcr.microsoft.com/devcontainers/javascript-node:0-18
FROM mcr.microsoft.com/devcontainers/javascript-node:22
6 changes: 3 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"service": "app",
"workspaceFolder": "/workspace",
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "20"
"ghcr.io/devcontainers/features/node:latest": {
"version": "22"
},
"ghcr.io/devcontainers-contrib/features/corepack:1": {}
"ghcr.io/devcontainers-contrib/features/pnpm:latest": {}
},
"forwardPorts": [3000],
"postCreateCommand": "sudo chmod 755 .devcontainer/init.sh && .devcontainer/init.sh",
Expand Down
2 changes: 0 additions & 2 deletions .devcontainer/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ set -xe

sudo chown -R node /workspace
git submodule update --init
corepack install
corepack enable
pnpm config set store-dir /home/node/.local/share/pnpm/store
pnpm install --frozen-lockfile
cp .devcontainer/devcontainer.yml .config/default.yml
Expand Down
15 changes: 4 additions & 11 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
**/.git

.autogen
.github
.travis
Expand All @@ -7,24 +9,15 @@ Dockerfile
build/
built/
db/
compose.yml
docker-compose.yml
node_modules/
packages/*/node_modules
redis/
files/
fluent-emojis/
.pnp.*

# .yarn関連
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.pnpm-store

.idea/
packages/*/.vscode/
packages/backend/test/compose.yml
packages/backend/test/docker-compose.yml
10 changes: 8 additions & 2 deletions .github/workflows/api-misskey-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ jobs:

steps:
- name: Checkout
uses: actions/[email protected]
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- run: corepack enable
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Setup Node.js
uses: actions/[email protected]
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/check-misskey-js-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Check version
run: |
if [ "$(jq -r '.version' package.json)" != "$(jq -r '.version' packages/misskey-js/package.json)" ]; then
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/docker-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/docker-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/docker-io.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/dockle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Build an image from Dockerfile
uses: docker/build-push-action@v6
with:
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
pnpm_install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
Expand All @@ -35,7 +35,6 @@ jobs:
with:
node-version-file: '.node-version'
cache: 'pnpm'
- run: corepack enable
- run: pnpm i --frozen-lockfile

lint:
Expand All @@ -50,7 +49,7 @@ jobs:
- sw
- misskey-js
steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
Expand All @@ -61,7 +60,6 @@ jobs:
with:
node-version-file: '.node-version'
cache: 'pnpm'
- run: corepack enable
- run: pnpm i --frozen-lockfile
- run: pnpm --filter ${{ matrix.workspace }} run eslint

Expand All @@ -75,7 +73,7 @@ jobs:
- backend
- misskey-js
steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
Expand All @@ -86,7 +84,6 @@ jobs:
with:
node-version-file: '.node-version'
cache: 'pnpm'
- run: corepack enable
- run: pnpm i --frozen-lockfile
- run: pnpm -r run build:tsc
if: ${{ matrix.workspace == 'backend' }}
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/test-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- 56312:6379

steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
Expand All @@ -63,7 +63,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: corepack enable
- run: pnpm i --frozen-lockfile
- name: Check pnpm-lock.yaml
run: git diff --exit-code pnpm-lock.yaml
Expand Down Expand Up @@ -110,7 +109,7 @@ jobs:
- 56312:6379

steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
Expand All @@ -123,7 +122,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: corepack enable
- run: pnpm i --frozen-lockfile
- name: Check pnpm-lock.yaml
run: git diff --exit-code pnpm-lock.yaml
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
node-version: [22.x]

steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
Expand All @@ -43,7 +43,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: corepack enable
- run: pnpm i --frozen-lockfile
- name: Check pnpm-lock.yaml
run: git diff --exit-code pnpm-lock.yaml
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/test-misskey-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@ jobs:

steps:
- name: Checkout
uses: actions/[email protected]
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

- run: corepack enable
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
node-version: [22.x]

steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
Expand All @@ -33,7 +33,6 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: corepack enable
- run: pnpm i --frozen-lockfile
- name: Check pnpm-lock.yaml
run: git diff --exit-code pnpm-lock.yaml
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/validate-api-json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
node-version: [22.x]

steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
Expand All @@ -36,7 +36,6 @@ jobs:
cache: 'pnpm'
- name: Install Redocly CLI
run: npm i -g @redocly/cli
- run: corepack enable
- run: pnpm i --frozen-lockfile
- name: Check pnpm-lock.yaml
run: git diff --exit-code pnpm-lock.yaml
Expand Down
14 changes: 3 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@
node_modules
report.*.json

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
packages/frontend/.yarn/cache
packages/backend/.yarn/cache
packages/sw/.yarn/cache

# pnpm
.pnpm-store

Expand All @@ -35,8 +24,11 @@ coverage
!/.config/example.yml
!/.config/docker_example.yml
!/.config/docker_example.env
compose.yml
docker-compose.yml
!/.devcontainer/compose.yml
!/.devcontainer/docker-compose.yml
!/packages/backend/test/compose.yml
!/packages/backend/test/docker-compose.yml

# misskey
Expand Down
24 changes: 8 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
&& apt-get install -yqq --no-install-recommends \
build-essential

RUN corepack enable

WORKDIR /misskey

COPY --link pnpm-lock.yaml ./
RUN npm install -g pnpm
RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \
pnpm fetch --ignore-scripts

Expand All @@ -36,11 +35,7 @@ RUN pnpm i --frozen-lockfile --aggregate-output --offline \

COPY --link . ./

ARG NODE_ENV=production

RUN git submodule update --init
RUN pnpm build
RUN rm -rf .git/
RUN NODE_ENV=production pnpm build

# build native dependencies for target platform

Expand All @@ -50,11 +45,10 @@ RUN apt-get update \
&& apt-get install -yqq --no-install-recommends \
build-essential

RUN corepack enable

WORKDIR /misskey

COPY --link pnpm-lock.yaml ./
RUN npm install -g pnpm
RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \
pnpm fetch --ignore-scripts

Expand All @@ -75,19 +69,20 @@ ARG GID="991"

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl ffmpeg libjemalloc-dev libjemalloc2 tini \
curl ffmpeg libjemalloc-dev libjemalloc2 tini \
&& ln -s /usr/lib/$(uname -m)-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so \
&& corepack enable \
&& groupadd -g "${GID}" misskey \
&& useradd -l -u "${UID}" -g "${GID}" -m -d /misskey misskey \
&& 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 misskey
WORKDIR /misskey

COPY --chown=misskey:misskey pnpm-lock.yaml ./
RUN npm install -g pnpm

COPY --chown=misskey:misskey --from=target-builder /misskey/node_modules ./node_modules
COPY --chown=misskey:misskey --from=target-builder /misskey/packages/backend/node_modules ./packages/backend/node_modules
COPY --chown=misskey:misskey --from=target-builder /misskey/packages/misskey-js/node_modules ./packages/misskey-js/node_modules
Expand All @@ -101,13 +96,10 @@ COPY --chown=misskey:misskey --from=native-builder /misskey/packages/backend/bui
COPY --chown=misskey:misskey --from=native-builder /misskey/fluent-emojis /misskey/fluent-emojis
COPY --chown=misskey:misskey . ./

RUN corepack install \
&& corepack pack

USER misskey
ENV LD_PRELOAD=/usr/local/lib/libjemalloc.so
ENV MALLOC_CONF=background_thread:true,metadata_thp:auto,dirty_decay_ms:30000,muzzy_decay_ms:30000
ENV NODE_ENV=production
ENV COREPACK_ENABLE_NETWORK=0
HEALTHCHECK --interval=5s --retries=20 CMD ["/bin/bash", "/misskey/healthcheck.sh"]
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["pnpm", "run", "migrateandstart:docker"]

0 comments on commit 303a521

Please sign in to comment.