Skip to content

Commit 93295ce

Browse files
Copilotmattfarina
andauthored
Add devcontainer for VCS development without host system dependencies (#112)
Created via AI (GitHub Copilot Coding Agent) Signed-off-by: Matt Farina <matt.farina@suse.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Matt Farina <matt.farina@suse.com>
1 parent a54ec74 commit 93295ce

File tree

3 files changed

+78
-1
lines changed

3 files changed

+78
-1
lines changed

.devcontainer/Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Use SUSE BCI Golang as the base image
2+
FROM registry.suse.com/bci/golang:1.25
3+
4+
# Install VCS tools and other dependencies
5+
RUN zypper --non-interactive refresh && \
6+
zypper --non-interactive install -y \
7+
git \
8+
mercurial \
9+
subversion \
10+
bzr \
11+
make \
12+
curl \
13+
sudo \
14+
shadow && \
15+
zypper clean --all
16+
17+
# Create a non-root user for development
18+
ARG USERNAME=vscode
19+
ARG USER_UID=1000
20+
ARG USER_GID=$USER_UID
21+
22+
RUN groupadd --gid $USER_GID $USERNAME && \
23+
useradd --uid $USER_UID --gid $USER_GID -m $USERNAME && \
24+
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \
25+
chmod 0440 /etc/sudoers.d/$USERNAME
26+
27+
# Set up Go workspace
28+
ENV GOPATH=/go
29+
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
30+
31+
# Create Go workspace directories with correct permissions
32+
RUN mkdir -p /go/src /go/bin /go/pkg && \
33+
chown -R $USERNAME:$USERNAME /go
34+
35+
# Switch to the non-root user
36+
USER $USERNAME
37+
38+
# Set working directory
39+
WORKDIR /workspace

.devcontainer/devcontainer.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "VCS Development Container",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"customizations": {
7+
"vscode": {
8+
"settings": {
9+
"go.toolsManagement.checkForUpdates": "local",
10+
"go.useLanguageServer": true
11+
},
12+
"extensions": [
13+
"golang.go"
14+
]
15+
}
16+
},
17+
"postCreateCommand": "go mod download",
18+
"remoteUser": "vscode"
19+
}

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface.
1313
Quick usage:
1414

1515
remote := "https://github.com/Masterminds/vcs"
16-
local, _ := ioutil.TempDir("", "go-vcs")
16+
local, _ := os.TempDir("", "go-vcs")
1717
repo, err := NewRepo(remote, local)
1818

1919
In this case `NewRepo` will detect the VCS is Git and return a `GitRepo`. All of
@@ -39,6 +39,25 @@ The constructors have the same signature as `NewRepo`.
3939

4040
For more details see [the documentation](https://godoc.org/github.com/Masterminds/vcs).
4141

42+
## Development
43+
44+
### Using Dev Container
45+
46+
This project includes a [development container](https://containers.dev/) configuration that provides a complete development environment with all required version control tools (Git, Mercurial, Subversion, and Bazaar) pre-installed.
47+
48+
To use the dev container:
49+
50+
1. Install [Docker](https://www.docker.com/products/docker-desktop) and [Visual Studio Code](https://code.visualstudio.com/)
51+
2. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) for VS Code
52+
3. Open this repository in VS Code
53+
4. When prompted, click "Reopen in Container" (or use the command palette: "Dev Containers: Reopen in Container")
54+
55+
The dev container is based on the SUSE BCI Golang image and includes:
56+
- Go development environment
57+
- Git, Mercurial (hg), Subversion (svn), and Bazaar (bzr)
58+
- Go language server and tools
59+
- All dependencies needed to run tests
60+
4261
## Motivation
4362

4463
The package `golang.org/x/tools/go/vcs` provides some valuable functionality

0 commit comments

Comments
 (0)