diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..87916061 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,16 @@ +FROM mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm + +RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install 18" +RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install 20" +RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install 22" + +# [Optional] Uncomment if you want to install more global node modules +ARG NODE_MODULES="typescript" +RUN su node -c "npm install -g ${NODE_MODULES}" \ + && npm cache clean --force > /dev/null 2>&1 + +# [Optional] Uncomment if you want to install ydb cli +RUN curl -fsSL https://install.ydb.tech/cli | bash + +# [Optional] Uncomment if you want to install bun +RUN curl -fsSL https://bun.sh/install | bash diff --git a/.devcontainer/compose.yml b/.devcontainer/compose.yml new file mode 100644 index 00000000..f6c96b4b --- /dev/null +++ b/.devcontainer/compose.yml @@ -0,0 +1,55 @@ +volumes: + ydb-data: + # driver: local + # driver_opts: + # type: tmpfs + # device: tmpfs + # o: size=80g + ydb-certs: + +services: + sdk: + build: + context: . + dockerfile: Dockerfile + + volumes: + - ydb-certs:/ydb_certs + - ../:/workspaces/ydb-js-sdk:cached + + environment: + - YDB_VERSION=24.3 + - YDB_CONNECTION_STRING=grpc://ydb:2136/local + - YDB_CONNECTION_STRING_SECURE=grpcs://ydb:2135/local + - YDB_ANONYMOUS_CREDENTIALS=1 + - YDB_SSL_ROOT_CERTIFICATES_FILE=/ydb_certs/ca.pem + + # 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:ydb + + # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + + ydb: + image: ghcr.io/ydb-platform/local-ydb:24.3 + restart: unless-stopped + hostname: ydb + platform: linux/amd64 + + volumes: + - ydb-data:/ydb_data + - ydb-certs:/ydb_certs + + environment: + - YDB_USE_IN_MEMORY_PDISKS=true + - GRPC_TLS_PORT=2135 + - GRPC_PORT=2136 + - MON_PORT=8765 + + network_mode: bridge + + # Add "forwardPorts": [2135, 8765] to **devcontainer.json** to forward YDB locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) diff --git a/.devcontainer/configure.sh b/.devcontainer/configure.sh new file mode 100755 index 00000000..5af34436 --- /dev/null +++ b/.devcontainer/configure.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +source /usr/local/share/nvm/nvm.sh && nvm use --lts + +if which ydb > /dev/null 2>&1; then + ENDPOINT=$(echo ${YDB_CONNECTION_STRING_SECURE:-$YDB_CONNECTION_STRING} | awk -F/ '{print $3}') + DATABASE=$(echo ${YDB_CONNECTION_STRING_SECURE:-$YDB_CONNECTION_STRING} | awk -F/ '{print "/" $4}') + CA_FILE_OPTION="" + + if [ -n "$YDB_CONNECTION_STRING_SECURE" ]; then + CA_FILE_OPTION="--ca-file ${YDB_SSL_ROOT_CERTIFICATES_FILE}" + fi + + ydb config profile create local \ + --endpoint "$ENDPOINT" \ + --database "$DATABASE" \ + $CA_FILE_OPTION + + ydb config profile activate local +fi diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..34b71b62 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,48 @@ +// 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 +{ + "name": "JavaScript & YDB", + "service": "sdk", + "dockerComposeFile": "compose.yml", + "workspaceFolder": "/workspaces/ydb-js-sdk", + // Allows the container to use ptrace, which is useful for debugging. + "capAdd": [ + "SYS_PTRACE" + ], + // Disables seccomp, which can be necessary for some debugging tools to function correctly. + "securityOpt": [ + "seccomp=unconfined" + ], + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + "ghcr.io/devcontainers/features/git": {}, + "ghcr.io/devcontainers/features/common-utils": {}, + "ghcr.io/devcontainers/features/github-cli:1": {} + }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [ + 2135, + 2136, + 8765 + ], + // Use 'initializeCommand' to run commands before the container is created. + "initializeCommand": "git config --local user.email \"$(git config user.email)\" && git config --local user.name \"$(git config user.name)\"", + // Use 'postStartCommand' to run commands after the container is started. + "postStartCommand": ".devcontainer/configure.sh", + // Configure tool-specific properties. + "customizations": { + "vscode": { + "extensions": [ + "mikestead.dotenv", + "dbaeumer.vscode-eslint", + "VisualStudioExptTeam.vscodeintellicode", + "oxc.oxc-vscode", + "esbenp.prettier-vscode", + "vitest.explorer", + "redhat.vscode-yaml" + ] + } + }, + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + "remoteUser": "root" +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..f33a02cd --- /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