-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from helios-ag/devcontainer
Added devcontainer
- Loading branch information
Showing
9 changed files
with
354 additions
and
0 deletions.
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,5 @@ | ||
.dockerignore | ||
devcontainer.json | ||
docker-compose.yml | ||
Dockerfile | ||
README.md |
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 @@ | ||
FROM qmcgaw/godevcontainer |
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,69 @@ | ||
# Development container | ||
|
||
Development container that can be used with VSCode. | ||
|
||
It works on Linux, Windows and OSX. | ||
|
||
## Requirements | ||
|
||
- [VS code](https://code.visualstudio.com/download) installed | ||
- [VS code remote containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed | ||
- [Docker](https://www.docker.com/products/docker-desktop) installed and running | ||
- [Docker Compose](https://docs.docker.com/compose/install/) installed | ||
|
||
## Setup | ||
|
||
1. Create the following files on your host if you don't have them: | ||
|
||
```sh | ||
touch ~/.gitconfig ~/.zsh_history | ||
``` | ||
|
||
Note that the development container will create the empty directories `~/.docker`, `~/.ssh` and `~/.kube` if you don't have them. | ||
1. **For Docker on OSX or Windows without WSL**: ensure your home directory `~` is accessible by Docker. | ||
1. Open the command palette in Visual Studio Code (CTRL+SHIFT+P). | ||
1. Select `Remote-Containers: Open Folder in Container...` and choose the project directory. | ||
## Customization | ||
### Customize the image | ||
You can make changes to the [Dockerfile](Dockerfile) and then rebuild the image. For example, your Dockerfile could be: | ||
```Dockerfile | ||
FROM qmcgaw/godevcontainer | ||
RUN apk add curl | ||
``` | ||
To rebuild the image, either: | ||
- With VSCode through the command palette, select `Remote-Containers: Rebuild and reopen in container` | ||
- With a terminal, go to this directory and `docker-compose build` | ||
### Customize VS code settings | ||
You can customize **settings** and **extensions** in the [devcontainer.json](devcontainer.json) definition file. | ||
### Entrypoint script | ||
You can bind mount a shell script to `/root/.welcome.sh` to replace the [current welcome script](https://github.com/qdm12/godevcontainer/blob/master/shell/.welcome.sh). | ||
### Publish a port | ||
To access a port from your host to your development container, publish a port in [docker-compose.yml](docker-compose.yml). You can also now do it directly with VSCode without restarting the container. | ||
### Run other services | ||
1. Modify [docker-compose.yml](docker-compose.yml) to launch other services at the same time as this development container, such as a test database: | ||
```yml | ||
database: | ||
image: postgres | ||
restart: always | ||
environment: | ||
POSTGRES_PASSWORD: password | ||
``` | ||
1. In [devcontainer.json](devcontainer.json), change the line `"runServices": ["vscode"],` to `"runServices": ["vscode", "database"],`. | ||
1. In the VS code command palette, rebuild the container. |
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,75 @@ | ||
{ | ||
"name": "tg-stat-emu", | ||
"dockerComposeFile": [ | ||
"docker-compose.yml" | ||
], | ||
"service": "vscode", | ||
"runServices": [ | ||
"vscode" | ||
], | ||
"shutdownAction": "stopCompose", | ||
"postCreateCommand": "~/.windows.sh && go mod download && go mod tidy", | ||
"workspaceFolder": "/workspace", | ||
// "overrideCommand": "", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"golang.go", | ||
"eamodio.gitlens", // IDE Git information | ||
"davidanson.vscode-markdownlint", | ||
"ms-azuretools.vscode-docker", // Docker integration and linting | ||
"shardulm94.trailing-spaces", // Show trailing spaces | ||
"Gruntfuggly.todo-tree", // Highlights TODO comments | ||
"bierner.emojisense", // Emoji sense for markdown | ||
"stkb.rewrap", // rewrap comments after n characters on one line | ||
"vscode-icons-team.vscode-icons", // Better file extension icons | ||
"github.vscode-pull-request-github", // Github interaction | ||
"redhat.vscode-yaml", // Kubernetes, Drone syntax highlighting | ||
"bajdzis.vscode-database", // Supports connections to mysql or postgres, over SSL, socked | ||
"IBM.output-colorizer", // Colorize your output/test logs | ||
"github.copilot" // AI code completion | ||
// "mohsen1.prettify-json", // Prettify JSON data | ||
// "zxh404.vscode-proto3", // Supports Proto syntax | ||
// "jrebocho.vscode-random", // Generates random values | ||
// "alefragnani.Bookmarks", // Manage bookmarks | ||
// "quicktype.quicktype", // Paste JSON as code | ||
// "spikespaz.vscode-smoothtype", // smooth cursor animation | ||
], | ||
"settings": { | ||
"files.eol": "\n", | ||
"editor.formatOnSave": true, | ||
"go.buildTags": "", | ||
"go.toolsEnvVars": { | ||
"CGO_ENABLED": "0" | ||
}, | ||
"go.useLanguageServer": true, | ||
"go.testEnvVars": { | ||
"CGO_ENABLED": "1" | ||
}, | ||
"go.testFlags": [ | ||
"-v", | ||
"-race" | ||
], | ||
"go.testTimeout": "10s", | ||
"go.coverOnSingleTest": true, | ||
"go.coverOnSingleTestFile": true, | ||
"go.coverOnTestPackage": true, | ||
"go.lintTool": "golangci-lint", | ||
"go.lintOnSave": "package", | ||
"[go]": { | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
} | ||
}, | ||
"gopls": { | ||
"usePlaceholders": false, | ||
"staticcheck": true, | ||
"vulncheck": "Imports" | ||
}, | ||
"remote.extensionKind": { | ||
"ms-azuretools.vscode-docker": "workspace" | ||
} | ||
} | ||
} | ||
} | ||
} |
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,27 @@ | ||
version: "3.7" | ||
|
||
services: | ||
vscode: | ||
build: . | ||
volumes: | ||
- ../:/workspace | ||
# Docker socket to access Docker server | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
# SSH directory for Linux, OSX and WSL | ||
# On Linux and OSX, a symlink /mnt/ssh <-> ~/.ssh is | ||
# created in the container. On Windows, files are copied | ||
# from /mnt/ssh to ~/.ssh to fix permissions. | ||
- ~/.ssh:/mnt/ssh | ||
# Shell history persistence | ||
- ~/.zsh_history:/root/.zsh_history | ||
# Git config | ||
- ~/.gitconfig:/root/.gitconfig | ||
environment: | ||
- TZ= | ||
cap_add: | ||
# For debugging with dlv | ||
- SYS_PTRACE | ||
security_opt: | ||
# For debugging with dlv | ||
- seccomp:unconfined | ||
entrypoint: [ "zsh", "-c", "while sleep 1000; do :; done" ] |
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,82 @@ | ||
ARG BASEDEV_VERSION=v0.24.0 | ||
ARG ALPINE_VERSION=3.18 | ||
ARG GO_VERSION=1.21 | ||
ARG GOMODIFYTAGS_VERSION=v1.16.0 | ||
ARG GOPLAY_VERSION=v1.0.0 | ||
ARG GOTESTS_VERSION=v1.6.0 | ||
ARG DLV_VERSION=v1.21.0 | ||
ARG MOCKERY_VERSION=v2.32.4 | ||
ARG GOMOCK_VERSION=v1.6.0 | ||
ARG MOCKGEN_VERSION=v1.6.0 | ||
ARG GOPLS_VERSION=v0.13.2 | ||
ARG GOLANGCILINT_VERSION=v1.54.1 | ||
ARG IMPL_VERSION=v1.2.0 | ||
ARG GOPKGS_VERSION=v2.1.2 | ||
ARG KUBECTL_VERSION=v1.27.4 | ||
ARG STERN_VERSION=v1.25.0 | ||
ARG KUBECTX_VERSION=v0.9.5 | ||
ARG KUBENS_VERSION=v0.9.5 | ||
ARG HELM_VERSION=v3.12.3 | ||
|
||
|
||
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS go | ||
FROM qmcgaw/binpot:gomodifytags-${GOMODIFYTAGS_VERSION} AS gomodifytags | ||
FROM qmcgaw/binpot:goplay-${GOPLAY_VERSION} AS goplay | ||
FROM qmcgaw/binpot:gotests-${GOTESTS_VERSION} AS gotests | ||
FROM qmcgaw/binpot:dlv-${DLV_VERSION} AS dlv | ||
FROM qmcgaw/binpot:mockery-${MOCKERY_VERSION} AS mockery | ||
FROM qmcgaw/binpot:gomock-${GOMOCK_VERSION} AS gomock | ||
FROM qmcgaw/binpot:mockgen-${MOCKGEN_VERSION} AS mockgen | ||
FROM qmcgaw/binpot:gopls-${GOPLS_VERSION} AS gopls | ||
FROM qmcgaw/binpot:golangci-lint-${GOLANGCILINT_VERSION} AS golangci-lint | ||
FROM qmcgaw/binpot:impl-${IMPL_VERSION} AS impl | ||
FROM qmcgaw/binpot:gopkgs-${GOPKGS_VERSION} AS gopkgs | ||
FROM qmcgaw/binpot:kubectl-${KUBECTL_VERSION} AS kubectl | ||
FROM qmcgaw/binpot:stern-${STERN_VERSION} AS stern | ||
FROM qmcgaw/binpot:kubectx-${KUBECTX_VERSION} AS kubectx | ||
FROM qmcgaw/binpot:kubens-${KUBENS_VERSION} AS kubens | ||
FROM qmcgaw/binpot:helm-${HELM_VERSION} AS helm | ||
|
||
FROM qmcgaw/basedevcontainer:${BASEDEV_VERSION}-alpine | ||
ARG CREATED | ||
ARG COMMIT | ||
ARG VERSION=local | ||
LABEL \ | ||
org.opencontainers.image.authors="[email protected]" \ | ||
org.opencontainers.image.created=$CREATED \ | ||
org.opencontainers.image.version=$VERSION \ | ||
org.opencontainers.image.revision=$COMMIT \ | ||
org.opencontainers.image.url="https://github.com/qdm12/godevcontainer" \ | ||
org.opencontainers.image.documentation="https://github.com/qdm12/godevcontainer" \ | ||
org.opencontainers.image.source="https://github.com/qdm12/godevcontainer" \ | ||
org.opencontainers.image.title="Go Dev container Alpine" \ | ||
org.opencontainers.image.description="Go development container for Visual Studio Code Remote Containers development" | ||
COPY --from=go /usr/local/go /usr/local/go | ||
ENV GOPATH=/go | ||
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH \ | ||
CGO_ENABLED=0 \ | ||
GO111MODULE=on | ||
WORKDIR $GOPATH | ||
# Install Alpine packages (g++ for race testing) | ||
RUN apk add -q --update --progress --no-cache g++ | ||
# Shell setup | ||
COPY shell/.zshrc-specific shell/.welcome.sh /root/ | ||
|
||
COPY --from=gomodifytags /bin /go/bin/gomodifytags | ||
COPY --from=goplay /bin /go/bin/goplay | ||
COPY --from=gotests /bin /go/bin/gotests | ||
COPY --from=dlv /bin /go/bin/dlv | ||
COPY --from=mockery /bin /go/bin/mockery | ||
COPY --from=gomock /bin /go/bin/gomock | ||
COPY --from=mockgen /bin /go/bin/mockgen | ||
COPY --from=gopls /bin /go/bin/gopls | ||
COPY --from=golangci-lint /bin /go/bin/golangci-lint | ||
COPY --from=impl /bin /go/bin/impl | ||
COPY --from=gopkgs /bin /go/bin/gopkgs | ||
|
||
# Extra binary tools | ||
COPY --from=kubectl /bin /usr/local/bin/kubectl | ||
COPY --from=stern /bin /usr/local/bin/stern | ||
COPY --from=kubectx /bin /usr/local/bin/kubectx | ||
COPY --from=kubens /bin /usr/local/bin/kubens | ||
COPY --from=helm /bin /usr/local/bin/helm |
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,86 @@ | ||
ARG BASEDEV_VERSION=v0.24.0 | ||
ARG DEBIAN_VERSION=bullseye | ||
ARG GO_VERSION=1.21 | ||
ARG GOMODIFYTAGS_VERSION=v1.16.0 | ||
ARG GOPLAY_VERSION=v1.0.0 | ||
ARG GOTESTS_VERSION=v1.6.0 | ||
ARG DLV_VERSION=v1.21.0 | ||
ARG MOCKERY_VERSION=v2.32.4 | ||
ARG GOMOCK_VERSION=v1.6.0 | ||
ARG MOCKGEN_VERSION=v1.6.0 | ||
ARG GOPLS_VERSION=v0.13.2 | ||
ARG GOLANGCILINT_VERSION=v1.54.1 | ||
ARG IMPL_VERSION=v1.2.0 | ||
ARG GOPKGS_VERSION=v2.1.2 | ||
ARG KUBECTL_VERSION=v1.27.4 | ||
ARG STERN_VERSION=v1.25.0 | ||
ARG KUBECTX_VERSION=v0.9.5 | ||
ARG KUBENS_VERSION=v0.9.5 | ||
ARG HELM_VERSION=v3.12.3 | ||
|
||
|
||
FROM golang:${GO_VERSION}-${DEBIAN_VERSION} AS go | ||
FROM qmcgaw/binpot:gomodifytags-${GOMODIFYTAGS_VERSION} AS gomodifytags | ||
FROM qmcgaw/binpot:goplay-${GOPLAY_VERSION} AS goplay | ||
FROM qmcgaw/binpot:gotests-${GOTESTS_VERSION} AS gotests | ||
FROM qmcgaw/binpot:dlv-${DLV_VERSION} AS dlv | ||
FROM qmcgaw/binpot:mockery-${MOCKERY_VERSION} AS mockery | ||
FROM qmcgaw/binpot:gomock-${GOMOCK_VERSION} AS gomock | ||
FROM qmcgaw/binpot:mockgen-${MOCKGEN_VERSION} AS mockgen | ||
FROM qmcgaw/binpot:gopls-${GOPLS_VERSION} AS gopls | ||
FROM qmcgaw/binpot:golangci-lint-${GOLANGCILINT_VERSION} AS golangci-lint | ||
FROM qmcgaw/binpot:impl-${IMPL_VERSION} AS impl | ||
FROM qmcgaw/binpot:gopkgs-${GOPKGS_VERSION} AS gopkgs | ||
FROM qmcgaw/binpot:kubectl-${KUBECTL_VERSION} AS kubectl | ||
FROM qmcgaw/binpot:stern-${STERN_VERSION} AS stern | ||
FROM qmcgaw/binpot:kubectx-${KUBECTX_VERSION} AS kubectx | ||
FROM qmcgaw/binpot:kubens-${KUBENS_VERSION} AS kubens | ||
FROM qmcgaw/binpot:helm-${HELM_VERSION} AS helm | ||
|
||
FROM qmcgaw/basedevcontainer:${BASEDEV_VERSION}-debian | ||
ARG CREATED | ||
ARG COMMIT | ||
ARG VERSION=local | ||
LABEL \ | ||
org.opencontainers.image.authors="[email protected]" \ | ||
org.opencontainers.image.created=$CREATED \ | ||
org.opencontainers.image.version=$VERSION \ | ||
org.opencontainers.image.revision=$COMMIT \ | ||
org.opencontainers.image.url="https://github.com/qdm12/godevcontainer" \ | ||
org.opencontainers.image.documentation="https://github.com/qdm12/godevcontainer" \ | ||
org.opencontainers.image.source="https://github.com/qdm12/godevcontainer" \ | ||
org.opencontainers.image.title="Go Dev container Debian" \ | ||
org.opencontainers.image.description="Go development container for Visual Studio Code Remote Containers development" | ||
COPY --from=go /usr/local/go /usr/local/go | ||
ENV GOPATH=/go | ||
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH \ | ||
CGO_ENABLED=0 \ | ||
GO111MODULE=on | ||
WORKDIR $GOPATH | ||
# Install Debian packages | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends g++ wget && \ | ||
apt-get autoremove -y && \ | ||
apt-get clean -y && \ | ||
rm -r /var/cache/* /var/lib/apt/lists/* | ||
# Shell setup | ||
COPY shell/.zshrc-specific shell/.welcome.sh /root/ | ||
|
||
COPY --from=gomodifytags /bin /go/bin/gomodifytags | ||
COPY --from=goplay /bin /go/bin/goplay | ||
COPY --from=gotests /bin /go/bin/gotests | ||
COPY --from=dlv /bin /go/bin/dlv | ||
COPY --from=mockery /bin /go/bin/mockery | ||
COPY --from=gomock /bin /go/bin/gomock | ||
COPY --from=mockgen /bin /go/bin/mockgen | ||
COPY --from=gopls /bin /go/bin/gopls | ||
COPY --from=golangci-lint /bin /go/bin/golangci-lint | ||
COPY --from=impl /bin /go/bin/impl | ||
COPY --from=gopkgs /bin /go/bin/gopkgs | ||
|
||
# Extra binary tools | ||
COPY --from=kubectl /bin /usr/local/bin/kubectl | ||
COPY --from=stern /bin /usr/local/bin/stern | ||
COPY --from=kubectx /bin /usr/local/bin/kubectx | ||
COPY --from=kubens /bin /usr/local/bin/kubens | ||
COPY --from=helm /bin /usr/local/bin/helm |
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,6 @@ | ||
echo "Terminal Go tools:" | ||
echo " * mockgen: generate mocks and stubs" | ||
echo " * mockery: generate testify/mock mocks from interfaces" | ||
echo "Terminal Docker tools aliases:" | ||
echo " * alpine: launch an interactive alpine 3.18 container" | ||
|
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,3 @@ | ||
# This file should NOT interact with stdout nor stdin! | ||
|
||
plugins=(vscode git colorize golang docker docker-compose kubectl helm) |