Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Add a dev container supporting docs and frontend (#2054)

Dhruv Bhanushalid35aa9407127
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 000000000..91321d67c
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,44 @@
+// For format details, see https://aka.ms/devcontainer.json. For config options, see the
+// README at: https://github.com/devcontainers/templates/tree/main/src/python
+{
+ "name": "Openverse",
+
+ "image": "mcr.microsoft.com/devcontainers/base:0-debian",
+
+ // Features to add to the dev container.
+ // More info: https://containers.dev/features
+ // List of features and their default options: https://github.com/devcontainers/features/tree/main/src
+ "features": {
+ // Openverse development environment requirement matrix: https://docs.openverse.org/general/general_setup.html#requirement-matrix
+ "ghcr.io/guiyomh/features/just:0": {},
+ "ghcr.io/devcontainers/features/python:1": {
+ // Match the Python version defined in `*/Pipfile`.
+ // TODO: Automatically populate this.
+ "version": "3.11"
+ },
+ "ghcr.io/devcontainers/features/node:1": {
+ // Match the Node.js version defined in `package.json`.
+ // TODO: Automatically populate this.
+ "version": "16"
+ },
+ "ghcr.io/devcontainers/features/docker-in-docker:2": {
+ "dockerDashComposeVersion": "v2"
+ },
+ "ghcr.io/devcontainers/features/github-cli:1": {}
+ },
+
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
+ "forwardPorts": [
+ 50230, // documentation
+ 8443 // frontend
+ ],
+
+ // Use 'postCreateCommand' to run commands after the container is created.
+ "postCreateCommand": "./.devcontainer/post_create.sh"
+
+ // Configure tool-specific properties.
+ // "customizations": {},
+
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
+ // "remoteUser": "root"
+}
diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh
new file mode 100755
index 000000000..0517fa752
--- /dev/null
+++ b/.devcontainer/post_create.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+# ABOUT
+# =====
+# This Bash script runs inside the dev container when it is created for the
+# time. Use this space to prepare the dev environment.
+
+# The Node.js feature installs the latest version of pnpm, not the one we want.
+# So we enable Corepack to provision the right pnpm version.
+corepack enable
+
+# Install dependencies for projects that run outside of the Docker context. This
+# includes Node.js packages, Python automations and documentation.
+just install
+
+# Running lint installs and prepares the hook environments. This saves time when
+# the developer needs to run lint.
+just lint
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 1ec9bbb84..74a009679 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -32,6 +32,7 @@ templates/ @WordPress/openverse-maintainers
.gitattributes @WordPress/openverse-maintainers
.gitignore @WordPress/openverse-maintainers
.github/ @WordPress/openverse-maintainers
+.devcontainer/ @WordPress/openverse-maintainers
.pre-commit-config.yaml @WordPress/openverse-maintainers
CODE_OF_CONDUCT.md @WordPress/openverse-maintainers
CONTRIBUTING.md @WordPress/openverse-maintainers
diff --git a/.github/filters.yml b/.github/filters.yml
index 5ca06a04e..8608d9acb 100644
--- a/.github/filters.yml
+++ b/.github/filters.yml
@@ -44,6 +44,7 @@ lint:
- .pre-commit-config.yaml
mgmt:
- .github/**
+ - .devcontainer/**
- automations/**
ci_cd:
- .github/actions/**
diff --git a/.gitignore b/.gitignore
index 05b32997a..4663624d7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,6 +27,7 @@ __pycache__/
node_modules/
npm-debug.log*
.pnpm-debug.log
+.pnpm-store/
# Nuxt
.nuxt
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 6141039f7..b32c1ee5d 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -19,7 +19,7 @@ repos:
args: [--markdown-linebreak-ext=md]
- id: check-executables-have-shebangs
- id: check-json
- exclude: tsconfig.json # contains comments
+ exclude: tsconfig.json|.devcontainer/devcontainer.json # contains comments
- id: check-case-conflict
- id: check-toml
- id: check-merge-conflict