diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000000..35075d7b5ec3 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,12 @@ +FROM mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm + +# [Optional] Uncomment this section to install additional OS packages. +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get -y install --no-install-recommends postgresql-client + +# [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 " diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000000..c8aea8158bef --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,24 @@ +// 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/${localWorkspaceFolderBasename}" + + // 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], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "yarn install", + + // 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 000000000000..b2aada42f3f3 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,45 @@ +version: '3.8' + +services: + app: + build: + context: . + dockerfile: Dockerfile + + volumes: + - ../..:/workspaces:cached + + # 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 + + environment: + PGHOST: db + PGUSER: postgres + PGPASSWORD: postgres + PGDATABASE: postgres + # browse the twenty-front at http://localhost:3001/ outside the container + VITE_HOST: 0.0.0.0 + + # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + + db: + # image: postgres:latest + image: twentycrm/twenty-postgres:latest + + restart: unless-stopped + volumes: + - postgres-data:/var/lib/postgresql/data + environment: + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + POSTGRES_DB: postgres + + # 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/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000000..f33a02cd16e4 --- /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/Makefile b/Makefile index 764dbd1531d4..830b7e6bcf2d 100644 --- a/Makefile +++ b/Makefile @@ -24,3 +24,6 @@ postgres-on-macos-intel: postgres-on-linux: make -C packages/twenty-postgres provision-on-linux + +postgres-on-devcontainer: + make -C packages/twenty-postgres provision-on-devcontainer diff --git a/packages/twenty-front/vite.config.ts b/packages/twenty-front/vite.config.ts index 282f9d6dd202..2bb2c0ae54b1 100644 --- a/packages/twenty-front/vite.config.ts +++ b/packages/twenty-front/vite.config.ts @@ -62,7 +62,7 @@ export default defineConfig(({ command, mode }) => { server: { port: 3001, - host: 'localhost', + host: process.env.VITE_HOST || 'localhost', fs: { allow: [ searchForWorkspaceRoot(process.cwd()), diff --git a/packages/twenty-postgres/Makefile b/packages/twenty-postgres/Makefile index 9e56adb19a03..606ac68e36f8 100644 --- a/packages/twenty-postgres/Makefile +++ b/packages/twenty-postgres/Makefile @@ -10,3 +10,5 @@ provision-on-macos-intel: provision-on-linux: sh ./linux/provision-postgres-linux.sh +provision-on-devcontainer: + psql -f ./init.sql