Skip to content

Commit 3e71c90

Browse files
authored
feature: add devcontainer for live debugging (mudler#60)
1 parent 550ae9c commit 3e71c90

5 files changed

Lines changed: 92 additions & 13 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ARG GO_VERSION=1.20
2+
FROM mcr.microsoft.com/devcontainers/go:0-$GO_VERSION-bullseye
3+
RUN apt-get update && apt-get install -y cmake

.devcontainer/devcontainer.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
3+
{
4+
"name": "Existing Docker Compose (Extend)",
5+
6+
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
7+
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
8+
"dockerComposeFile": [
9+
"../docker-compose.yaml",
10+
"docker-compose.yml"
11+
],
12+
13+
// The 'service' property is the name of the service for the container that VS Code should
14+
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
15+
"service": "api",
16+
17+
// The optional 'workspaceFolder' property is the path VS Code should open by default when
18+
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
19+
"workspaceFolder": "/workspace",
20+
21+
"features": {
22+
"ghcr.io/devcontainers/features/go:1": {},
23+
"ghcr.io/azutake/devcontainer-features/go-packages-install:0": {}
24+
},
25+
26+
// Features to add to the dev container. More info: https://containers.dev/features.
27+
// "features": {},
28+
29+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
30+
// "forwardPorts": [],
31+
32+
// Uncomment the next line if you want start specific services in your Docker Compose config.
33+
// "runServices": [],
34+
35+
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
36+
// "shutdownAction": "none",
37+
38+
// Uncomment the next line to run commands after the container is created.
39+
"postCreateCommand": "make prepare"
40+
41+
// Configure tool-specific properties.
42+
// "customizations": {},
43+
44+
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
45+
// "remoteUser": "devcontainer"
46+
}

.devcontainer/docker-compose.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '3.6'
2+
services:
3+
# Update this to the name of the service you want to work with in your docker-compose.yml file
4+
api:
5+
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
6+
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
7+
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
8+
# array). The sample below assumes your primary file is in the root of your project.
9+
#
10+
build:
11+
context: .
12+
dockerfile: .devcontainer/Dockerfile
13+
14+
volumes:
15+
# Update this to wherever you want VS Code to mount the folder of your project
16+
- .:/workspace:cached
17+
18+
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
19+
# cap_add:
20+
# - SYS_PTRACE
21+
# security_opt:
22+
# - seccomp:unconfined
23+
24+
# Overrides default command so things don't shut down after the process ends.
25+
command: /bin/sh -c "while sleep 1000; do :; done"
26+

.vscode/launch.json

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
{
22
"version": "0.2.0",
33
"configurations": [
4-
5-
{
6-
"name": "Launch Go",
7-
"type": "go",
8-
"request": "launch",
9-
"mode": "debug",
10-
"program": "${workspaceFolder}/main.go",
11-
"args": [
12-
"api"
13-
]
14-
}
4+
{
5+
"name": "Launch Go",
6+
"type": "go",
7+
"request": "launch",
8+
"mode": "debug",
9+
"program": "${workspaceFolder}/main.go",
10+
"args": [
11+
"api"
12+
],
13+
"env": {
14+
"C_INCLUDE_PATH": "/workspace/go-llama:/workspace/go-gpt4all-j:/workspace/go-gpt2",
15+
"LIBRARY_PATH": "/workspace/go-llama:/workspace/go-gpt4all-j:/workspace/go-gpt2",
16+
"DEBUG": "true"
17+
}
18+
}
1519
]
16-
}
20+
}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ WHITE := $(shell tput -Txterm setaf 7)
1212
CYAN := $(shell tput -Txterm setaf 6)
1313
RESET := $(shell tput -Txterm sgr0)
1414

15-
C_INCLUDE_PATH=$(shell pwd)/go-llama:$(shell pwd)/go-gpt4all-j:$(shell pwd)/go-gpt2
15+
C_INCLUDE_PATH=$(shell pwd)/go-llama:$(shell pwd)/go-gpt4all-j:$(shell pwd)/go-gpt2
1616
LIBRARY_PATH=$(shell pwd)/go-llama:$(shell pwd)/go-gpt4all-j:$(shell pwd)/go-gpt2
1717

1818
# Use this if you want to set the default behavior

0 commit comments

Comments
 (0)