Skip to content

Commit 6f827bc

Browse files
committed
Introduce DevContainers
Development containers allow to develop projects in a virtualised environment, e.g. with Docker on desktop, or remotely with providers like GitHub Codespaces. This makes it extremely easy for people to contribute to the project, since the environment is already set up for them. The following development containers are introduced with this commit: - `app` - for remote app development in the cloud. It includes a lightweight desktop environment and a VNC client to connect to the desktop remotely and interact with the running app. - `app-local` - for local app development on Linux desktops. Unlike `app`, it does not include desktop environment and relies on desktop forwarding provided by Visual Studio Code. This is only suitable for Linux hosts. - `backend` - for backend development. Features pre-configured database and other components required by Labrinth. - `frontend` - for frontend development. Everything you need to work with Modrinth frontend - Vue, Nuxt and other niceties included. Some Visual Studio Code settings were also revised to remove unmaintained or broken extension recommendations, recommend different useful extensions, as well as declutter the explorer.
1 parent b9d90aa commit 6f827bc

12 files changed

+305
-3
lines changed

.devcontainer/app-local/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM mcr.microsoft.com/devcontainers/base:1-bookworm
2+
3+
RUN apt-get update && \
4+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libwebkit2gtk-4.1-dev \
5+
build-essential \
6+
curl \
7+
wget \
8+
file \
9+
libxdo-dev \
10+
libssl-dev \
11+
libayatana-appindicator3-dev \
12+
librsvg2-dev \
13+
luakit \
14+
xdg-utils
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "Modrinth (app, local)",
3+
4+
"build": {
5+
"dockerfile": "Dockerfile"
6+
},
7+
8+
"hostRequirements": {
9+
"memory": "12gb"
10+
},
11+
12+
"features": {
13+
"ghcr.io/devcontainers/features/node": {
14+
"version": "20",
15+
"installYarnUsingApt": false,
16+
"pnpmVersion": "none"
17+
},
18+
"ghcr.io/devcontainers/features/rust:1": {}
19+
},
20+
21+
"containerEnv": {
22+
"BROWSER_BASE_URL": "https://api.modrinth.com/v2/"
23+
},
24+
25+
"onCreateCommand": "npm i -g corepack && corepack enable && COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack install",
26+
"updateContentCommand": "pnpm install --ignore-scripts && (cd apps/app && cargo fetch) && (cd apps/app-playground && cargo fetch)",
27+
28+
"customizations": {
29+
"vscode": {
30+
"extensions": [
31+
"Vue.volar",
32+
"dbaeumer.vscode-eslint",
33+
"esbenp.prettier-vscode",
34+
"EditorConfig.EditorConfig",
35+
"tauri-apps.tauri-vscode",
36+
"-tamasfe.even-better-toml"
37+
]
38+
}
39+
},
40+
41+
"mounts": [
42+
{
43+
"source": "devcontainer-cargo-cache-modrinth",
44+
"target": "/usr/local/cargo",
45+
"type": "volume"
46+
}
47+
]
48+
}

.devcontainer/app/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM mcr.microsoft.com/devcontainers/base:1-bookworm
2+
3+
RUN apt-get update && \
4+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends libwebkit2gtk-4.1-dev \
5+
build-essential \
6+
curl \
7+
wget \
8+
file \
9+
libxdo-dev \
10+
libssl-dev \
11+
libayatana-appindicator3-dev \
12+
librsvg2-dev \
13+
luakit \
14+
xdg-utils

.devcontainer/app/devcontainer.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "Modrinth (app, remote)",
3+
4+
"build": {
5+
"dockerfile": "Dockerfile"
6+
},
7+
8+
"hostRequirements": {
9+
"memory": "12gb"
10+
},
11+
12+
"features": {
13+
"ghcr.io/devcontainers/features/desktop-lite:1": {},
14+
"ghcr.io/devcontainers/features/node": {
15+
"version": "20",
16+
"installYarnUsingApt": false,
17+
"pnpmVersion": "none"
18+
},
19+
"ghcr.io/devcontainers/features/rust:1": {}
20+
},
21+
22+
"containerEnv": {
23+
"VNC_RESOLUTION": "1600x1000",
24+
"BROWSER_BASE_URL": "https://api.modrinth.com/v2/"
25+
},
26+
27+
"onCreateCommand": "npm i -g corepack && corepack enable && COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack install",
28+
"updateContentCommand": "pnpm install --ignore-scripts && (cd apps/app && cargo fetch) && (cd apps/app-playground && cargo fetch)",
29+
30+
"forwardPorts": [6080, 5901],
31+
"portsAttributes": {
32+
"6080": {
33+
"label": "desktop"
34+
},
35+
"5901": {
36+
"label": "vnc"
37+
}
38+
},
39+
40+
"customizations": {
41+
"vscode": {
42+
"extensions": [
43+
"Vue.volar",
44+
"dbaeumer.vscode-eslint",
45+
"esbenp.prettier-vscode",
46+
"EditorConfig.EditorConfig",
47+
"tauri-apps.tauri-vscode",
48+
"-tamasfe.even-better-toml"
49+
]
50+
}
51+
},
52+
53+
"mounts": [
54+
{
55+
"source": "devcontainer-cargo-cache-modrinth",
56+
"target": "/usr/local/cargo",
57+
"type": "volume"
58+
}
59+
]
60+
}

.devcontainer/backend/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM mcr.microsoft.com/devcontainers/base:1-bookworm
2+
3+
RUN apt-get update && \
4+
apt-get install --no-install-recommends -y \
5+
postgresql-client \
6+
libssl-dev \
7+
pkg-config \
8+
liblzma-dev
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "Modrinth (backend)",
3+
4+
"dockerComposeFile": ["../../docker-compose.yml", "docker-compose.yml"],
5+
"service": "labrinth",
6+
"workspaceFolder": "/workspace",
7+
8+
"hostRequirements": {
9+
"memory": "12gb"
10+
},
11+
12+
"features": {
13+
"ghcr.io/devcontainers/features/rust:1": {}
14+
},
15+
16+
"onCreateCommand": "${containerWorkspaceFolder}/.devcontainer/backend/setup.sh",
17+
"updateContentCommand": "(cd apps/labrinth && cargo fetch)",
18+
19+
"customizations": {
20+
"vscode": {
21+
"extensions": ["-tamasfe.even-better-toml"]
22+
}
23+
},
24+
25+
"mounts": [
26+
{
27+
"source": "devcontainer-cargo-cache-modrinth",
28+
"target": "/usr/local/cargo",
29+
"type": "volume"
30+
}
31+
]
32+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
services:
2+
labrinth:
3+
build:
4+
dockerfile: ./.devcontainer/backend/Dockerfile
5+
command: sleep infinity
6+
volumes:
7+
- .:/workspace:cached
8+
depends_on:
9+
- postgres_db
10+
- meilisearch
11+
- redis
12+
- clickhouse
13+
environment:
14+
DATABASE_URL: postgresql://labrinth:labrinth@postgres_db/labrinth
15+
MEILISEARCH_ADDR: http://meilisearch:7700
16+
REDIS_URL: redis://redis
17+
CLICKHOUSE_URL: http://clickhouse:8123
18+
clickhouse:
19+
environment:
20+
- CLICKHOUSE_SKIP_USER_SETUP=1

.devcontainer/backend/setup.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
cargo install --git https://github.com/launchbadge/sqlx sqlx-cli --no-default-features --features postgres,rustls
5+
6+
(cd apps/labrinth && sqlx database setup)
7+
8+
psql "$DATABASE_URL" <<EOF
9+
INSERT INTO loaders VALUES (0, 'placeholder_loader');
10+
INSERT INTO loaders_project_types VALUES (0, 1); -- modloader id, supported type id
11+
INSERT INTO categories VALUES (0, 'placeholder_category', 1); -- category id, category, project type id
12+
EOF
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "Modrinth (frontend)",
3+
4+
"image": "mcr.microsoft.com/devcontainers/base:1-bookworm",
5+
6+
"features": {
7+
"ghcr.io/devcontainers/features/node": {
8+
"version": "20",
9+
"installYarnUsingApt": false,
10+
"pnpmVersion": "none"
11+
}
12+
},
13+
14+
"containerEnv": {
15+
"BROWSER_BASE_URL": "https://api.modrinth.com/v2/"
16+
},
17+
18+
"onCreateCommand": "npm i -g corepack && corepack enable && COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack install",
19+
"updateContentCommand": "pnpm install --ignore-scripts && pnpm --filter=@modrinth/frontend postinstall",
20+
21+
"customizations": {
22+
"vscode": {
23+
"extensions": [
24+
"Vue.volar",
25+
"dbaeumer.vscode-eslint",
26+
"esbenp.prettier-vscode",
27+
"EditorConfig.EditorConfig",
28+
"Nuxtr.nuxtr-vscode",
29+
"antfu.goto-alias"
30+
]
31+
}
32+
},
33+
34+
"appPort": [3000]
35+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,5 @@ app-playground-data/*
6161
apps/frontend/.env
6262

6363
.astro
64+
65+
.pnpm-store

.vscode/extensions.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
{
2-
"recommendations": ["esbenp.prettier-vscode", "Vue.volar", "rust-lang.rust-analyzer"]
2+
"recommendations": [
3+
"esbenp.prettier-vscode",
4+
"rust-lang.rust-analyzer",
5+
"Vue.volar",
6+
"vscode.typescript-language-features",
7+
"dbaeumer.vscode-eslint",
8+
"EditorConfig.EditorConfig",
9+
"tauri-apps.tauri-vscode",
10+
"vunguyentuan.vscode-css-variables",
11+
"usernamehw.errorlens",
12+
"yoavbls.pretty-ts-errors"
13+
]
314
}

.vscode/settings.json

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,54 @@
11
{
2-
"prettier.endOfLine": "lf",
32
"editor.formatOnSave": true,
4-
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
53
"editor.codeActionsOnSave": {
64
"source.fixAll.eslint": "explicit"
5+
},
6+
7+
"rust-analyzer.cargo.features": ["default", "offline"],
8+
9+
"files.exclude": {
10+
"**/.git": true,
11+
"**/.svn": true,
12+
"**/.hg": true,
13+
"**/.DS_Store": true,
14+
"**/Thumbs.db": true,
15+
"**/.idea": true,
16+
"**/.pnpm-store": true,
17+
"**/.turbo": true,
18+
"**/node_modules": true,
19+
"**/target": true
20+
},
21+
22+
"explorer.fileNesting.enabled": true,
23+
"explorer.fileNesting.patterns": {
24+
"*.ts": "${capture}.js",
25+
"*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts",
26+
"*.jsx": "${capture}.js",
27+
"*.tsx": "${capture}.ts",
28+
"tsconfig.json": "tsconfig.*.json",
29+
"package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb, bun.lock, pnpm-workspace.yaml",
30+
"Cargo.toml": "Cargo.lock",
31+
"README.md": "COPYING.md, LICENSE"
32+
},
33+
34+
"prettier.endOfLine": "lf",
35+
36+
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
37+
"eslint.run": "onSave",
38+
39+
"[json]": {
40+
"editor.defaultFormatter": "esbenp.prettier-vscode"
41+
},
42+
"[jsonc]": {
43+
"editor.defaultFormatter": "esbenp.prettier-vscode"
44+
},
45+
"[typescript]": {
46+
"editor.defaultFormatter": "esbenp.prettier-vscode"
47+
},
48+
"[javascript]": {
49+
"editor.defaultFormatter": "esbenp.prettier-vscode"
50+
},
51+
"[vue]": {
52+
"editor.defaultFormatter": "esbenp.prettier-vscode"
753
}
854
}

0 commit comments

Comments
 (0)