Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@

USER node

# install mise
RUN curl https://mise.run | sh

ENV PATH="/home/node/.local/bin:$PATH"
RUN echo 'eval "$(mise activate bash)"' >> ~/.bashrc

Check warning on line 40 in .devcontainer/Dockerfile

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Merge this RUN instruction with the consecutive ones.

See more on https://sonarcloud.io/project/issues?id=graasp_graasp&issues=AZ5JwB2F---lh8TUabkC&open=AZ5JwB2F---lh8TUabkC&pullRequest=2136

RUN echo "source /usr/share/bash-completion/completions/git" >> ~/.bashrc
25 changes: 3 additions & 22 deletions .github/workflows/deploy-db-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 24

- name: Get yarn cache directory
id: yarn-cache-dir-path
run: |
echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: yarn install and generate docs
run: |
yarn
yarn db-doc:generate
- name: generate DB docs
run: mise run generate-db-docs

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
Expand Down
61 changes: 13 additions & 48 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ env:
APPS_PUBLISHER_ID: 9c9cea73-f3b7-48a3-aa6e-ead82c0685e7 # mock uuid
GRAASPER_CREATOR_ID: bbbf7cac-6139-45e4-8fbf-4cf767b50b29 # mock uuid
COOKIE_DOMAIN: localhost
CLIENT_HOST: http://localhost:3114
DB_PASSWORD: docker
DB_USERNAME: docker
DB_NAME: docker
Expand Down Expand Up @@ -92,41 +91,25 @@ jobs:
--health-retries 5

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 24

- name: Get yarn cache directory
id: yarn-cache-dir-path
run: |
echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Mise
uses: jdx/mise-action@v3

- name: yarn install and build
run: |
yarn
yarn build
run: mise run build

- name: yarn check
run: yarn check
run: mise run check

- name: apply migrations on empty database
run: yarn migration:run
run: mise run migrate

- name: check migrations are up to date
run: yarn migration:check
run: mise run migration-check

- name: vitest tests
run: yarn vitest
run: mise run vitest

test-node:
strategy:
Expand Down Expand Up @@ -171,24 +154,10 @@ jobs:
--health-retries 5

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 24

- name: Get yarn cache directory
id: yarn-cache-dir-path
run: |
echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install Mise
uses: jdx/mise-action@v3

- uses: actions/cache@v4
with:
Expand All @@ -197,12 +166,8 @@ jobs:
restore-keys: |
${{ runner.os }}-jest-

- name: yarn install
run: |
yarn

- name: apply migrations on empty database
run: yarn migration:run
run: mise run migrate

- name: yarn test
run: yarn test:ci --shard=${{ matrix.shard }}
run: mise run e2e --shard=${{ matrix.shard }}
16 changes: 0 additions & 16 deletions .yarnrc.yml

This file was deleted.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ GRAASPER_CREATOR_ID=<id>
# REDIS_CONNECTION=

# Client hosts
CLIENT_HOST=http://localhost:3114
LIBRARY_CLIENT_HOST=http://localhost:3005

# Base url used to redirect shortlink aliases
Expand Down
43 changes: 24 additions & 19 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
FROM node:24.12-bookworm AS base
RUN apt-get update \
&& apt-get -y --no-install-recommends install \
sudo curl git ca-certificates build-essential dumb-init \
&& rm -rf /var/lib/apt/lists/*

SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV MISE_INSTALL_PATH="/usr/local/bin/mise"

# Install mise
RUN curl https://mise.run | sh


##############################
### Build Application Step ###
##############################
# This step will build the application
FROM base AS tools

# update packages and install the minimal init system "dumb-init"
RUN apt-get update && apt-get install -y --no-install-recommends dumb-init
# FROM base AS tools

# # update packages and install the minimal init system "dumb-init"
# RUN apt-get update \
# && apt-get install -y --no-install-recommends dumb-init \
# && rm -rf /var/lib/apt/lists/*

# -------------------------------------------------------
FROM base AS build

WORKDIR /app
COPY package.json yarn.lock .yarnrc.yml ./
# We need a specific command because we need to copy the folder with it, not just the content.
COPY .yarn/releases ./.yarn/releases/
RUN yarn set version berry && yarn install --immutable
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml mise.toml ./

ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
RUN mise trust && mise install && corepack enable && pnpm install --frozen-lockfile

ENV NODE_ENV=production
COPY . .
RUN yarn build-ts
RUN pnpm build-ts

# -------------------------------------------------------
FROM base AS deps

WORKDIR /app
COPY package.json yarn.lock .yarnrc.yml ./
# We need a specific command because we need to copy the folder with it, not just the content.
COPY .yarn/releases ./.yarn/releases/
RUN yarn set version berry && yarn workspaces focus --all --production
# removes non prod dependencies
RUN pnpm install --prod --frozen-lockfile

############################
### Run Application Step ###
Expand All @@ -54,10 +59,10 @@ EXPOSE 3000
WORKDIR /app

# Copy the installed dumb-init system from build image
COPY --from=tools /usr/bin/dumb-init /usr/bin/dumb-init
COPY --from=base /usr/bin/dumb-init /usr/bin/dumb-init

# Copy the dependencies and compiled server code
COPY --chown=node:node --from=deps ./app/node_modules ./node_modules
COPY --chown=node:node --from=build ./app/node_modules ./node_modules
COPY --chown=node:node --from=build ./app/dist ./dist

# Set user to be non-root node
Expand Down
75 changes: 75 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[tools]
node = "24"

[hooks]
# Enabling corepack will install the `pnpm` package manager specified in your package.json
# alternatively, you can also install `pnpm` with mise
postinstall = 'npx corepack enable'

[settings]
# This must be enabled to make the hooks work
experimental = true

[env]
_.path = ['{{config_root}}/node_modules/.bin']

[tasks.pnpm-install]
description = 'Installs dependencies with pnpm'
run = 'pnpm install'
sources = ['package.json', 'pnpm-lock.yaml', 'mise.toml']
outputs = ['node_modules/.pnpm/lock.yaml']

[tasks.dev]
depends = ["pnpm-install"]
description = "Run the development server"
run = "pnpm watch"

[tasks.lint]
depends = ["pnpm-install"]
description = "Lint the files with eslint"
run = "eslint '**/*.{js,ts}'"

[tasks.prettier-check]
depends = ["pnpm-install"]
description = "Check formatting with prettier"
run = "prettier --check \"{src,test}/**/*.ts\""

[tasks.type-check]
depends = ["pnpm-install"]
description = "Run typescript checking"
run = "tsc --noEmit"

[tasks.check]
depends = ["prettier-check", "lint", "type-check"]

[tasks.build]
depends = ["lint"]
description = "Build the application"
run = "tsc -p tsconfig.build.json"

[tasks.migrate]
depends = ["pnpm-install"]
run = "drizzle-kit migrate"
env = { _.file = '.env.development' }

[tasks.migration-check]
env = { _.file = '.env.development' }
depends = ["pnpm-install"]
run = "drizzle-kit generate --name=migrationtest --out=./src/drizzle --schema=./src/drizzle/schema.ts --dialect=postgresql && [ -f '$(find ./src/drizzle | grep migrationtest)' ] && exit 1 || exit 0"

[tasks.vitest]
depends = "pnpm-install"
run = "vitest"

[tasks.e2e]
depends = ["pnpm-install"]
env = { _.file = '.env.test'}
run = "jest --forceExit --verbose --coverage --silent --detectOpenHandles --maxWorkers=2"

[tasks.test]
depends = ["vitest", "e2e"]

[tasks.generate-db-docs]
depends = ["pnpm-install"]
description = "Generate documentation for the database schemas"
run = "drizzle-kit export > schema.sql && npx @liam-hq/cli erd build --input schema.sql --format postgres --output-dir db-documentation"
14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
"license": "AGPL-3.0-only",
"author": "Graasp",
"type": "commonjs",
"packageManager": "pnpm@11.2.1",
"scripts": {
"start": "yarn serve",
"build": "yarn lint && yarn build-ts",
"serve": "NODE_PATH=./dist node dist/server.js",
"start": "NODE_PATH=./dist node dist/server.js",
"build": "pnpm lint && pnpm build-ts",
"watch-node": "NODE_PATH=./dist nodemon dist/server.js",
"watch-node:worker": "NODE_PATH=./dist nodemon dist/workers/entrypoint.js",
"dev": "yarn run watch",
"watch": "concurrently -k -p \"[{name}]\" -n \"TypeScript,Server,Worker\" -c \"cyan.bold,green.bold,magenta.bold\" \"yarn watch-ts\" \"yarn watch-node\" \"yarn watch-node:worker\"",
"watch": "concurrently -k -p \"[{name}]\" -n \"TypeScript,Server\" -c \"cyan.bold,green.bold\" \"pnpm watch-ts\" \"pnpm watch-node\"",
"seed": "ts-node -e 'import seed from \"./test/mocks/index\";seed();'",
"test": "jest --forceExit --verbose --runInBand --detectOpenHandles",
"test:ci": "jest --forceExit --verbose --coverage --silent --detectOpenHandles --maxWorkers=2",
Expand All @@ -43,7 +42,7 @@
"openapi:report": "vacuum html-report ./openapi.json vacuum-report.html",
"migration:apply-test": "DB_CONNECTION=postgres://test:test@db:5432/test yarn migration:run",
"migration:generate": "yarn drizzle-kit generate",
"migration:run": "yarn drizzle-kit migrate",
"migrate": "drizzle-kit migrate",
"migration:check": "yarn drizzle-kit generate --name=migrationtest --out=./src/drizzle --schema=./src/drizzle/schema.ts --dialect=postgresql && [ -f '$(find ./src/drizzle | grep migrationtest)' ] && exit 1 || exit 0",
"db-doc:generate": "npx drizzle-kit export > schema.sql && npx @liam-hq/cli erd build --input schema.sql --format postgres --output-dir db-documentation"
},
Expand Down Expand Up @@ -183,6 +182,5 @@
"sodium-native": "4.2.0",
"fastify": "5.8.5",
"@sinclair/typebox": "0.34.49"
},
"packageManager": "yarn@4.14.1"
}
}
Loading
Loading