Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

build: Add devcontainer (#3429)

Ivan Starkov2e236917a7e5
diff --git a/.devcontainer/.gitignore b/.devcontainer/.gitignore
new file mode 100644
index 0000000000..565b35d8a4
--- /dev/null
+++ b/.devcontainer/.gitignore
@@ -0,0 +1 @@
+.local
\ No newline at end of file
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
new file mode 100644
index 0000000000..7be99e5fa8
--- /dev/null
+++ b/.devcontainer/Dockerfile
@@ -0,0 +1,17 @@
+FROM mcr.microsoft.com/devcontainers/javascript-node:1-20-bookworm
+
+ENV PATH=/usr/local/bin:${PATH}
+# Install latest pnpm
+# RUN npm install -g [email protected]
+
+# [Optional] Uncomment this section to install additional OS packages.
+# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
+# && apt-get -y install --no-install-recommends <your-package-list-here>
+
+# [Optional] Uncomment if you want to install an additional version of node using nvm
+# ARG EXTRA_NODE_VERSION=10
+# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
+
+# [Optional] Uncomment if you want to install more global node modules
+# RUN su node -c "npm install -g <your-package-list-here>"
+
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 0000000000..6df057e477
--- /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/javascript-node-postgres
+{
+ "name": "Node.js & PostgreSQL",
+ "dockerComposeFile": "docker-compose.yml",
+ "service": "app",
+ "workspaceFolder": "/workspaces/webstudio",
+ "features": {
+ "ghcr.io/robbert229/devcontainer-features/postgresql-client:1": {
+ "version": "15"
+ },
+ "ghcr.io/devcontainers-contrib/features/fzf:1": {}
+ },
+
+ // Features to add to the dev container. More info: https://containers.dev/features.
+ // "features": {},
+
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
+ // This can be used to network with other containers or with the host.
+ // "forwardPorts": [3000, 5432],
+ "forwardPorts": [5173, "db:5432"],
+
+ // Use 'postCreateCommand' to run commands after the container is created.
+
+ "postCreateCommand": ".devcontainer/postinstall.sh",
+ // "postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
+ "customizations": {
+ "vscode": {
+ "extensions": [
+ "esbenp.prettier-vscode",
+ "redhat.vscode-yaml",
+ "me-dutour-mathieu.vscode-github-actions",
+ "eamodio.gitlens",
+ "bradymholt.pgformatter"
+ ]
+ }
+ }
+
+ // 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/docker-compose.yml b/.devcontainer/docker-compose.yml
new file mode 100644
index 0000000000..0b4adf5d59
--- /dev/null
+++ b/.devcontainer/docker-compose.yml
@@ -0,0 +1,48 @@
+version: "3.8"
+
+services:
+ app:
+ build:
+ context: .
+ dockerfile: Dockerfile
+
+ volumes:
+ - ..:/workspaces/webstudio:cached
+ # preserve history
+ - ./.local:/home/node/.local
+
+ # Overrides default command so things don't shut down after the process ends.
+ command: sleep infinity
+
+ # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
+ network_mode: service:db
+
+ depends_on:
+ db:
+ condition: service_healthy
+
+ db:
+ image: ghcr.io/supabase/postgres:15.1.1.55
+ # Uncomment to log all queries
+ # command: ["postgres", "-c", "log_statement=all"]
+ restart: unless-stopped
+ volumes:
+ - postgres-data:/var/lib/postgresql/data
+ environment:
+ POSTGRES_PASSWORD: pass
+ POSTGRES_DB: webstudio
+
+ ports:
+ - ${PGPORT:-5432}:5432
+
+ healthcheck:
+ test: ["CMD-SHELL", "pg_isready -U postgres -d webstudio"]
+ interval: 10s
+ timeout: 5s
+ retries: 25
+
+ # Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
+ # (Adding the "ports" property to this file will not forward from a Codespace.)
+
+volumes:
+ postgres-data:
diff --git a/.devcontainer/postinstall.sh b/.devcontainer/postinstall.sh
new file mode 100755
index 0000000000..ffc3f8b1d0
--- /dev/null
+++ b/.devcontainer/postinstall.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+echo 'eval "$(fzf --bash)"' >> /home/node/.bashrc
+
+mkdir -p /home/node/.local/fzf
+
+touch /home/node/.local/fzf/.bash_history
+
+echo 'export HISTFILE=/home/node/.local/fzf/.bash_history' >> "/home/node/.bashrc"
+
+cd /workspaces/webstudio
+sudo corepack enable
+corepack install
+
+pnpm config set store-dir $HOME/.pnpm-store
+
+
+find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
+find . -name 'lib' -type d -prune -exec rm -rf '{}' +
+find . -name 'build' -type d -prune -exec rm -rf '{}' +
+find . -name 'dist' -type d -prune -exec rm -rf '{}' +
+find . -name '.cache' -type d -prune -exec rm -rf '{}' +
+find . -name '.pnpm-store' -type d -prune -exec rm -rf '{}' +
+
+pnpm install
+pnpm run build
+pnpm migrations migrate
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000000..f33a02cd16
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,12 @@
+# To get started with Dependabot version updates, you'll need to specify which
+# package ecosystems to update and where the package manifests are located.
+# Please see the documentation for more information:
+# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
+# https://containers.dev/guide/dependabot
+
+version: 2
+updates:
+ - package-ecosystem: "devcontainers"
+ directory: "/"
+ schedule:
+ interval: weekly
diff --git a/.gitignore b/.gitignore
index 729fb8c0ba..1138347c48 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,7 +29,8 @@ yarn-error.log*
.pnpm-debug.log*
# local env files
-.env
+# .env
+.env.development
.env.local
.env.development.local
.env.test.local
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 0000000000..082bc94c02
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,3 @@
+{
+ "recommendations": ["ms-vscode-remote.remote-containers"]
+}
diff --git a/apps/builder/.env.example b/apps/builder/.env
similarity index 75%
rename from apps/builder/.env.example
rename to apps/builder/.env
index 78c0d45541..b30741c7c3 100644
--- a/apps/builder/.env.example
+++ b/apps/builder/.env
@@ -1,9 +1,11 @@
-BUILDER_HOST=webstudio.is
-DATABASE_URL=postgresql://user:pass@localhost/webstudio
-DIRECT_URL=postgresql://user:pass@localhost/webstudio
+# To override environment variables, add a .env.development file in the same directory.
+# For more details, visit: https://vitejs.dev/guide/env-and-mode#env-files
+DATABASE_URL=postgresql://postgres:pass@db/webstudio?pgbouncer=true
+DIRECT_URL=postgresql://postgres:pass@db/webstudio
+
AUTH_SECRET="# Linux: $(openssl rand -hex 32) or go to https://generate-secret.now.sh/64"
-GH_CLIENT_SECRET=
-GH_CLIENT_ID=
+# GH_CLIENT_SECRET=
+# GH_CLIENT_ID=
DEV_LOGIN=true
# Restrictions
@@ -46,9 +48,11 @@ ASSET_BASE_URL=/s/uploads/
FEATURES=*
# TRCP server url and API token. If empty local TRPC server is used
-TRPC_SERVER_URL=
-TRPC_SERVER_API_TOKEN=
+# TRPC_SERVER_URL=
+# TRPC_SERVER_API_TOKEN=
# AI Features
-OPENAI_KEY=
-OPENAI_ORG=
+# OPENAI_KEY=
+# OPENAI_ORG=
+
+
diff --git a/apps/builder/.gitignore b/apps/builder/.gitignore
index f56a416128..10caebc821 100644
--- a/apps/builder/.gitignore
+++ b/apps/builder/.gitignore
@@ -1,6 +1,4 @@
.cache
-.env
-.env.*
.vercel
.output
diff --git a/packages/prisma-client/migrations-cli/commands.ts b/packages/prisma-client/migrations-cli/commands.ts
index 4f6637e19a..48876f32a3 100644
--- a/packages/prisma-client/migrations-cli/commands.ts
+++ b/packages/prisma-client/migrations-cli/commands.ts
@@ -291,16 +291,6 @@ export const migrate = async () => {
process.exit(0);
}
- if (args.values.dev) {
- logger.info("You're about to apply the following migration(s):");
- logger.info("");
- for (const migration of status.pending) {
- logger.info(` - ${migration.name}`);
- }
- logger.info("");
- await ensureUserWantsToContinue(true);
- }
-
await up();
};