-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add devcontainer setup with YDB
- Loading branch information
Showing
6 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM mcr.microsoft.com/devcontainers/go:1-1.21-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 <your-pkg> | ||
|
||
# Install golangci from GitHub. Binary will be $(go env GOPATH)/bin/golangci-lint | ||
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.2 | ||
|
||
# Install ydb cli from GitHub. | ||
# COPY ./ydb /usr/local/bin/ydb | ||
# RUN chmod +x /usr/local/bin/ydb | ||
|
||
# [Optional] Uncomment the next lines to use go get to install anything else you need | ||
# USER vscode | ||
# RUN go get ... | ||
# USER root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
version: '3.8' | ||
|
||
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-go-sdk:cached | ||
|
||
environment: | ||
- YDB_VERSION=24.3 | ||
- YDB_CONNECTION_STRING=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 | ||
- MON_PORT=8765 | ||
|
||
# Add "forwardPorts": [2135, 8765] to **devcontainer.json** to forward YDB locally. | ||
# (Adding the "ports" property to this file will not forward from a Codespace.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
|
||
if which ydb > /dev/null 2>&1; then | ||
ydb config profile create local \ | ||
--endpoint $(echo $YDB_CONNECTION_STRING | awk -F/ '{print $3}') \ | ||
--database $(echo $YDB_CONNECTION_STRING | awk -F/ '{print "/" $4}') \ | ||
--ca-file ${YDB_SSL_ROOT_CERTIFICATES_FILE} | ||
|
||
ydb config profile activate local | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the | ||
// README at: https://github.com/devcontainers/templates/tree/main/src/go-postgres | ||
{ | ||
"name": "Go & YDB", | ||
"service": "sdk", | ||
"dockerComposeFile": "compose.yml", | ||
"workspaceFolder": "/workspaces/ydb-go-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/github-cli:1": {} | ||
}, | ||
// Configure tool-specific properties. | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"golang.go", | ||
"zxh404.vscode-proto3", | ||
"VisualStudioExptTeam.vscodeintellicode" | ||
] | ||
} | ||
}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
"forwardPorts": [2135, 8765], | ||
// Use 'initializeCommand' to run commands before the container is created. | ||
"initializeCommand": "cd \"${localWorkspaceFolder}\" && git config --local user.email \"$(git config user.email)\" && git config --local user.name \"$(git config user.name)\"", | ||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "go version && golangci-lint --version && go mod download", | ||
// Use 'postStartCommand' to run commands after the container is started. | ||
"postStartCommand": ".devcontainer/configure.sh" | ||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. | ||
// "remoteUser": "root" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
*.code-workspace | ||
.vscode/* | ||
.history/ | ||
.devcontainer | ||
*.vsix | ||
*.swp | ||
*.exe | ||
|