diff --git a/.devcontainer/app-local/Dockerfile b/.devcontainer/app-local/Dockerfile new file mode 100644 index 0000000000..782153356c --- /dev/null +++ b/.devcontainer/app-local/Dockerfile @@ -0,0 +1,14 @@ +FROM mcr.microsoft.com/devcontainers/base:1-bookworm + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libwebkit2gtk-4.1-dev \ + build-essential \ + curl \ + wget \ + file \ + libxdo-dev \ + libssl-dev \ + libayatana-appindicator3-dev \ + librsvg2-dev \ + luakit \ + xdg-utils diff --git a/.devcontainer/app-local/devcontainer.json b/.devcontainer/app-local/devcontainer.json new file mode 100644 index 0000000000..5c476617d5 --- /dev/null +++ b/.devcontainer/app-local/devcontainer.json @@ -0,0 +1,54 @@ +{ + "name": "Modrinth (app, local)", + + "build": { + "dockerfile": "Dockerfile" + }, + + "hostRequirements": { + "memory": "12gb" + }, + + "features": { + "ghcr.io/devcontainers/features/node": { + "version": "20", + "installYarnUsingApt": false, + "pnpmVersion": "none" + }, + "ghcr.io/devcontainers/features/rust:1": {} + }, + + "containerEnv": { + "BROWSER_BASE_URL": "https://api.modrinth.com/v2/", + "DATABASE_URL": "sqlite://${containerWorkspaceFolder}/apps/app/.data/database.db" + }, + + "onCreateCommand": "${containerWorkspaceFolder}/.devcontainer/app-shared/setup.sh", + "updateContentCommand": "pnpm install --ignore-scripts && (cd apps/app && cargo fetch) && (cd apps/app-playground && cargo fetch)", + + "customizations": { + "vscode": { + "extensions": [ + "Vue.volar", + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + "EditorConfig.EditorConfig", + "tauri-apps.tauri-vscode", + "-tamasfe.even-better-toml", + "tombi-toml.tombi" + ], + "settings": { + "extensions.ignoreRecommendations": true, + "rust-analyzer.files.exclude": ["apps/daedalus_client", "apps/labrinth"] + } + } + }, + + "mounts": [ + { + "source": "devcontainer-cargo-cache-modrinth", + "target": "/usr/local/cargo", + "type": "volume" + } + ] +} diff --git a/.devcontainer/app-shared/setup.sh b/.devcontainer/app-shared/setup.sh new file mode 100755 index 0000000000..92db66b21a --- /dev/null +++ b/.devcontainer/app-shared/setup.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -euo pipefail + +npm i -g corepack + +corepack enable + +COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack install + +cargo install --git https://github.com/launchbadge/sqlx sqlx-cli \ + --no-default-features --features sqlite,rustls + +mkdir -p "$(dirname "${DATABASE_URL#sqlite://}")" + +(cd packages/app-lib && cargo sqlx database setup) diff --git a/.devcontainer/app/Dockerfile b/.devcontainer/app/Dockerfile new file mode 100644 index 0000000000..782153356c --- /dev/null +++ b/.devcontainer/app/Dockerfile @@ -0,0 +1,14 @@ +FROM mcr.microsoft.com/devcontainers/base:1-bookworm + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libwebkit2gtk-4.1-dev \ + build-essential \ + curl \ + wget \ + file \ + libxdo-dev \ + libssl-dev \ + libayatana-appindicator3-dev \ + librsvg2-dev \ + luakit \ + xdg-utils diff --git a/.devcontainer/app/devcontainer.json b/.devcontainer/app/devcontainer.json new file mode 100644 index 0000000000..3df877eeb0 --- /dev/null +++ b/.devcontainer/app/devcontainer.json @@ -0,0 +1,66 @@ +{ + "name": "Modrinth (app, remote)", + + "build": { + "dockerfile": "Dockerfile" + }, + + "hostRequirements": { + "memory": "12gb" + }, + + "features": { + "ghcr.io/devcontainers/features/desktop-lite:1": {}, + "ghcr.io/devcontainers/features/node": { + "version": "20", + "installYarnUsingApt": false, + "pnpmVersion": "none" + }, + "ghcr.io/devcontainers/features/rust:1": {} + }, + + "containerEnv": { + "VNC_RESOLUTION": "1600x1000", + "BROWSER_BASE_URL": "https://api.modrinth.com/v2/", + "DATABASE_URL": "sqlite://${containerWorkspaceFolder}/apps/app/.data/database.db" + }, + + "onCreateCommand": "${containerWorkspaceFolder}/.devcontainer/app-shared/setup.sh", + "updateContentCommand": "pnpm install --ignore-scripts && (cd apps/app && cargo fetch) && (cd apps/app-playground && cargo fetch)", + + "forwardPorts": [6080, 5901], + "portsAttributes": { + "6080": { + "label": "desktop" + }, + "5901": { + "label": "vnc" + } + }, + + "customizations": { + "vscode": { + "extensions": [ + "Vue.volar", + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + "EditorConfig.EditorConfig", + "tauri-apps.tauri-vscode", + "-tamasfe.even-better-toml", + "tombi-toml.tombi" + ], + "settings": { + "extensions.ignoreRecommendations": true, + "rust-analyzer.files.exclude": ["apps/daedalus_client", "apps/labrinth"] + } + } + }, + + "mounts": [ + { + "source": "devcontainer-cargo-cache-modrinth", + "target": "/usr/local/cargo", + "type": "volume" + } + ] +} diff --git a/.devcontainer/backend/Dockerfile b/.devcontainer/backend/Dockerfile new file mode 100644 index 0000000000..fb3c06beac --- /dev/null +++ b/.devcontainer/backend/Dockerfile @@ -0,0 +1,8 @@ +FROM mcr.microsoft.com/devcontainers/base:1-bookworm + +RUN apt-get update && \ + apt-get install --no-install-recommends -y \ + postgresql-client \ + libssl-dev \ + pkg-config \ + liblzma-dev diff --git a/.devcontainer/backend/devcontainer.json b/.devcontainer/backend/devcontainer.json new file mode 100644 index 0000000000..aaf6b69700 --- /dev/null +++ b/.devcontainer/backend/devcontainer.json @@ -0,0 +1,36 @@ +{ + "name": "Modrinth (backend)", + + "dockerComposeFile": ["../../docker-compose.yml", "docker-compose.yml"], + "service": "labrinth", + "workspaceFolder": "/workspace", + + "hostRequirements": { + "memory": "12gb" + }, + + "features": { + "ghcr.io/devcontainers/features/rust:1": {} + }, + + "onCreateCommand": "${containerWorkspaceFolder}/.devcontainer/backend/setup.sh", + "updateContentCommand": "(cd apps/labrinth && cargo fetch)", + + "customizations": { + "vscode": { + "extensions": ["EditorConfig.EditorConfig", "-tamasfe.even-better-toml", "tombi-toml.tombi"], + "settings": { + "extensions.ignoreRecommendations": true, + "rust-analyzer.files.exclude": ["apps/app", "apps/app-playground", "packages/app-lib"] + } + } + }, + + "mounts": [ + { + "source": "devcontainer-cargo-cache-modrinth", + "target": "/usr/local/cargo", + "type": "volume" + } + ] +} diff --git a/.devcontainer/backend/docker-compose.yml b/.devcontainer/backend/docker-compose.yml new file mode 100644 index 0000000000..9c150f10d9 --- /dev/null +++ b/.devcontainer/backend/docker-compose.yml @@ -0,0 +1,20 @@ +services: + labrinth: + build: + dockerfile: ./.devcontainer/backend/Dockerfile + command: sleep infinity + volumes: + - .:/workspace:cached + depends_on: + - postgres_db + - meilisearch + - redis + - clickhouse + environment: + DATABASE_URL: postgresql://labrinth:labrinth@postgres_db/labrinth + MEILISEARCH_ADDR: http://meilisearch:7700 + REDIS_URL: redis://redis + CLICKHOUSE_URL: http://clickhouse:8123 + clickhouse: + environment: + - CLICKHOUSE_SKIP_USER_SETUP=1 diff --git a/.devcontainer/backend/setup.sh b/.devcontainer/backend/setup.sh new file mode 100755 index 0000000000..65cb2e03c5 --- /dev/null +++ b/.devcontainer/backend/setup.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -euo pipefail + +cargo install --git https://github.com/launchbadge/sqlx sqlx-cli \ + --no-default-features --features postgres,rustls + +(cd apps/labrinth && sqlx database setup) + +psql "$DATABASE_URL" <