From 5fea0102fb468b00c38d92f8ac1b6c0dd4f996d3 Mon Sep 17 00:00:00 2001 From: EYHN Date: Fri, 17 Nov 2023 17:54:19 +0800 Subject: [PATCH] chore: add devcontainer config (#4974) Co-authored-by: Reese <3253971+figadore@users.noreply.github.com> --- .devcontainer/Dockerfile | 9 +++++++++ .devcontainer/build.sh | 12 ++++++++++++ .devcontainer/devcontainer.json | 25 +++++++++++++++++++++++++ .devcontainer/docker-compose.yml | 26 ++++++++++++++++++++++++++ .devcontainer/setup-user.sh | 7 +++++++ README.md | 7 +++++++ 6 files changed, 86 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/build.sh create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml create mode 100755 .devcontainer/setup-user.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..cc8665505 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,9 @@ +FROM mcr.microsoft.com/devcontainers/base:bookworm + +# Install Homebrew For Linux +RUN /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" && \ + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" && \ + echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> /home/vscode/.zshrc && \ + echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> /home/vscode/.bashrc && \ + # Install Graphite + brew install withgraphite/tap/graphite && gt --version \ No newline at end of file diff --git a/.devcontainer/build.sh b/.devcontainer/build.sh new file mode 100644 index 000000000..10000e663 --- /dev/null +++ b/.devcontainer/build.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# This is a script used by the devcontainer to build the project + +#Enable yarn +corepack enable +corepack prepare yarn@stable --activate + +# install dependencies +yarn install + +# Create database +yarn workspace @affine/server prisma db push \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..191a02c0e --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,25 @@ +// For format details, see https://aka.ms/devcontainer.json. +{ + "name": "Debian", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "18" + }, + "ghcr.io/devcontainers/features/rust:1": {} + }, + // Configure tool-specific properties. + "customizations": { + "vscode": { + "extensions": [ + "ms-playwright.playwright", + "esbenp.prettier-vscode", + "streetsidesoftware.code-spell-checker" + ] + } + }, + "updateContentCommand": "bash ./.devcontainer/build.sh", + "postCreateCommand": "bash ./.devcontainer/setup-user.sh" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 000000000..0263548fc --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,26 @@ +version: '3.8' + +services: + app: + build: + context: . + dockerfile: Dockerfile + volumes: + - ../..:/workspaces:cached + command: sleep infinity + network_mode: service:db + environment: + DATABASE_URL: postgresql://affine:affine@db:5432/affine + + db: + image: postgres:latest + restart: unless-stopped + volumes: + - postgres-data:/var/lib/postgresql/data + environment: + POSTGRES_PASSWORD: affine + POSTGRES_USER: affine + POSTGRES_DB: affine + +volumes: + postgres-data: diff --git a/.devcontainer/setup-user.sh b/.devcontainer/setup-user.sh new file mode 100755 index 000000000..1171f79d4 --- /dev/null +++ b/.devcontainer/setup-user.sh @@ -0,0 +1,7 @@ +if [ -v GRAPHITE_TOKEN ];then + gt auth --token $GRAPHITE_TOKEN +fi + +git fetch +git branch canary -t origin/canary +gt init --trunk canary diff --git a/README.md b/README.md index 73caf09e8..10562298e 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,13 @@ For feature request, please see [community.affine.pro](https://community.affine. ## Building +### Codespaces + +From the GitHub repo main page, click the green "Code" button and select "Create codespace on master". This will open a new Codespace with the (supposedly auto-forked +AFFiNE repo cloned, built, and ready to go. + +### Local + See [BUILDING.md] for instructions on how to build AFFiNE from source code. ## Contributing