Last active
March 12, 2024 06:33
-
-
Save akkuman/158ba7775b4f1e4ef684540dafc95b81 to your computer and use it in GitHub Desktop.
go+docker-compose 开发容器样例
This file contains hidden or 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
Show hidden characters
{ | |
"name": "expgo", | |
// Update the 'dockerComposeFile' list if you have more compose files or use different names. | |
"dockerComposeFile": "docker-compose.yml", | |
// The 'service' property is the name of the service for the container that VS Code should | |
// use. Update this value and .devcontainer/docker-compose.yml to the real service name. | |
"service": "app", | |
// The 'workspaceFolder' property is the path VS Code should open by default when | |
// connected. Corresponds to a volume mount in .devcontainer/docker-compose.yml | |
"workspaceFolder": "/workspace", | |
// 👇 Features to add to the Dev Container. More info: https://containers.dev/implementors/features. | |
"features": { | |
"ghcr.io/devcontainers/features/git-lfs:1": {} | |
}, | |
"customizations": { | |
// Configure properties specific to VS Code. | |
"vscode": { | |
"extensions": [ | |
"golang.Go", | |
"eamodio.gitlens", | |
"mhutchie.git-graph", | |
] | |
} | |
}, | |
"postCreateCommand": "bash .devcontainer/postCreateCommand.sh", | |
"postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}" | |
} |
This file contains hidden or 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
version: '3' | |
services: | |
app: | |
build: | |
context: . | |
dockerfile: Dockerfile | |
volumes: | |
- ..:/workspace:cached | |
network_mode: service:redis | |
command: sleep infinity | |
redis: | |
image: redis:7 | |
restart: unless-stopped |
This file contains hidden or 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
FROM mcr.dockerproxy.com/devcontainers/go:1-1.22-bullseye | |
# 如果在国外 | |
# FROM mcr.microsoft.com/devcontainers/go:1-1.22-bullseye | |
ARG DEBIAN_FRONTEND=noninteractive | |
ARG USER=vscode | |
RUN sed -i "s|http://deb.debian.org/debian|http://mirror.sjtu.edu.cn/debian|g" /etc/apt/sources.list && \ | |
apt-get update && \ | |
apt-get install -y bash-completion direnv | |
USER $USER | |
ARG HOME="/home/$USER" | |
ENV LANG=C.UTF-8 \ | |
TZ=Asia/Shanghai \ | |
PATH="${HOME}/.local/bin:$PATH" | |
RUN go env -w GO111MODULE=on && \ | |
go env -w GOPROXY=https://goproxy.cn,direct | |
# # 基础开发工具 | |
# go install github.com/cweill/gotests/gotests@latest && \ | |
# go install github.com/fatih/gomodifytags@latest && \ | |
# go install github.com/josharian/impl@latest && \ | |
# go install github.com/haya14busa/goplay/cmd/goplay@latest && \ | |
# go install github.com/go-delve/delve/cmd/dlv@latest && \ | |
# go install honnef.co/go/tools/cmd/staticcheck@latest && \ | |
# go install golang.org/x/tools/gopls@latest |
This file contains hidden or 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
#!/usr/bin/env bash | |
# 将 direnv hook 上 bash | |
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc | |
# 将 git 补全加入 .bashrc | |
echo 'source /usr/share/bash-completion/completions/git' >> ~/.bashrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment