MIT License

项目介绍

qdm12/godevcontainer 是一个托管在 GitHub 上的开源项目,主要使用 Dockerfile 编写,采用 MIT License 许可证,目前获得 288 个 Star、52 次 Fork。

仓库全名
qdm12/godevcontainer
开源许可证
MIT License
Star 数
288
Fork 数
52
未关闭 Issue
2

README 摘要

Go Dev Container Ultimate Go development container for Visual Studio Code Features Compatible with amd64, 386, arm64, armv6 and armv7 CPUs ghcr.io/qdm12/godevcontainer:alpine and ghcr.io/qdm12/godevcontainer Based on Alpine 3.24 (size of 1.21GB) ghcr.io/qdm12/godevcontainer:debian Based on Debian Trixie Slim (size of 1.37GB) Based on qmcgaw/basedevcontainer Based on either Alpine or Debian Minimal custom terminal…

完整内容见 GitHub 原始 README 或本页 。

常见问题

godevcontainer 用什么语言开发?

主要使用 Dockerfile 编写,采用 MIT License 许可证,目前有 288 个 Star。

godevcontainer 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 godevcontainer 的源码?

可以直接克隆仓库:git clone https://github.com/qdm12/godevcontainer.git,默认分支为 master;安装与运行步骤见仓库 README。

godevcontainer 最近还在维护吗?

仓库最近一次更新为 2 周前,当前有 2 个未关闭 Issue;Star 数为 288,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

Golang development container for Visual Studio Code Remote Containers Development

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
397
价值分
188
活跃状态
活跃

语言占比

Dockerfile
Shell

Release

README

Go Dev Container

Ultimate Go development container for Visual Studio Code

godevcontainer

Alpine Debian

dockeri.co

Last Docker tag Latest size

Last release Last release size GitHub last release date Commits since release

GitHub last commit GitHub commit activity GitHub closed PRs GitHub issues GitHub closed issues

Lines of code Code size GitHub repo size

Visitors count

Features

  • Compatible with amd64, 386, arm64, armv6 and armv7 CPUs
  • ghcr.io/qdm12/godevcontainer:alpine and ghcr.io/qdm12/godevcontainer
    • Based on Alpine 3.24 (size of 1.21GB)
  • ghcr.io/qdm12/godevcontainer:debian
    • Based on Debian Trixie Slim (size of 1.37GB)
  • Based on qmcgaw/basedevcontainer
    • Based on either Alpine or Debian
    • Minimal custom terminal and packages
    • See more features
  • Go 1.27 code obtained from the latest tagged Golang Docker image
  • Go tooling integrating with VS code, all cross built statically from source at the binpot:
  • Terminal Go tools
    • mockgen to generate mocks
    • mockery to generate mocks for testify/mock
  • Runs as an unprivileged user (user, uid/gid 1000 by default, configurable), see Non-root user
    • apk (Alpine) and apt-get (Debian) install packages from that user, no sudo involved
  • Cross platform
    • Easily bind mount your SSH keys to use with git
    • Manage your host Docker from within the dev container, more details at qmcgaw/basedevcontainer
  • Compatible with both the Docker and Podman engines
  • Extensible with docker-compose.yml
  • Comes with extra Go binary tools for a few extra MBs: kubectl, kubectx, kubens, stern and helm

Requirements

Setup for a project

  1. Setup your configuration files
    • With style 💯

      docker run -it --rm -v "/yourrepopath:/repository" qmcgaw/devtainr:v0.2.0 -dev go -path /repository -name projectname
      

      Or use the built binary

    • Or manually: download this repository and put the .devcontainer directory in your project. It holds a docker/ and a podman/ configuration, pick the one matching your container engine.

  2. If you have a .vscode/settings.json, eventually move the settings to .devcontainer/*/devcontainer.json in the "settings" section as .vscode/settings.json take precedence over the settings defined in .devcontainer//devcontainer.json*.
  3. Open the command palette in Visual Studio Code (CTRL+SHIFT+P) and select Dev Containers: Open Folder in Container... and choose your project directory

Non-root user

The image runs using an unprivileged account user, created by the base image.

💁 In case you need root access, see the root user section

The non root user is configurable with container build arguments, defined both in the Dockerfiles and in the devcontainer.json files:

Build argument Default Description
USERNAME user account name, home is /home/$USERNAME. Update the "remoteUser" key and mount targets in devcontainer.json to match this one if changed.
GROUP_NAME user name of the account’s primary group
USER_UID 1000 user ID of the account
USER_GID 1000 group ID of the account’s primary group ($GROUP_NAME)
DOCKER_GID create a docker group with this GID and put the account in it, to reach a rootful engine’s socket, see Container engine

The unprivileged account:

  • owns its home, /go (its GOPATH), and the state directories of the package manager, so it can install and remove packages without sudo or doas
  • can write to a directory a package may add or remove a file in (/usr/local/bin, /etc/ssl/certs, /var/log…), which all belong to $GROUP_NAME and are group-writable.
  • can only read and execute files installed in the container image and setup by the container engine
  • cannot read /root and /etc/shadow

On system package management, note:

  • it cannot replace a file the image already has installed, since those keep their root ownership
  • for the Debian container, some packages have maintainer scripts that insist on running as root, and will fail to install (i.e. dbus); the fix is to finish the job as root for example docker exec --user root <container-name> sh -c 'apt-get install -y dbus && dpkg --configure -a'

Root user

If you need to run a command as root, exec in the container using for example

docker exec --user root <container-name> command

Root has the same terminal setup as the unprivileged account, given its configuration files are symlinks into /home/user. Note however that by default the zsh history and ssh files are not symlinked or copied from the unprivileged user to root. The shell prints Running as root at startup, so you always know which account a terminal belongs to.

Customization

See the .devcontainer/README.md document in your repository.

When you extend the image in a Dockerfile, the build runs as the unprivileged account: use USER root before instructions that do need root, and USER user to give it back.

docker-compose.yml

You can create a .devcontainer/docker-compose.yml to create the devcontainer and other containers at the same time:

services:
  vscode: # configured in devcontainer.json
    build: .
  postgres: # example of a database container
    image: postgres
    restart: always
    environment:
      POSTGRES_PASSWORD: password

And change the following in your relevant devcontainer.json:

  • remove "build": { "dockerfile": "../Dockerfile" },
  • add "dockerComposeFile": "../docker-compose.yml",
  • add "overrideCommand": true,
  • add "service": "vscode",
  • add "runServices": ["vscode", "postgres"],

Finally, open the command palette in Visual Studio Code (CTRL+SHIFT+P) and select Dev-Containers: Rebuild Container

TODOs

License

This repository is under an MIT license unless indicated otherwise.

评论

暂无评论