diff --git a/.devcontainer/.dockerignore b/.devcontainer/.dockerignore index ac9cb068d..ebf94300f 100644 --- a/.devcontainer/.dockerignore +++ b/.devcontainer/.dockerignore @@ -1,5 +1,4 @@ .dockerignore devcontainer.json -docker-compose.yml Dockerfile README.md diff --git a/.devcontainer/README.md b/.devcontainer/README.md index 0ab8e7eb7..807b6c393 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -9,7 +9,6 @@ It works on Linux, Windows (WSL2) and OSX. - [VS code](https://code.visualstudio.com/download) installed - [VS code dev 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 @@ -34,14 +33,14 @@ Customizations available are notably: - Changes to the Docker image in [Dockerfile](Dockerfile) - Changes to VSCode **settings** and **extensions** in [devcontainer.json](devcontainer.json). -- Change the entrypoint script by adding in [docker-compose.yml](docker-compose.yml) a bind mount to a shell script to `/root/.welcome.sh` to replace the [current welcome script](https://github.com/qdm12/godevcontainer/blob/master/shell/.welcome.sh). For example: - - ```yml - volumes: - # ... - - ./.welcome.sh:/root/.welcome.sh:ro - # ... +- Change the entrypoint script by adding in [devcontainer.json](devcontainer.json) a bind mount to a shell script to `/root/.welcome.sh` to replace the [current welcome script](https://github.com/qdm12/godevcontainer/blob/master/shell/.welcome.sh). For example: + + ```json + { + "source": "/yourpath/.welcome.sh", + "target": "/root/.welcome.sh", + "type": "bind" + }, ``` -- Change the docker container configuration in [docker-compose.yml](docker-compose.yml). - More customizations available are documented in the [devcontainer.json reference](https://containers.dev/implementors/json_reference/). diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a73b7a7c3..0b85f17e1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,16 +1,50 @@ { "name": "gluetun-dev", - "dockerComposeFile": [ - "docker-compose.yml" + // User defined settings + "containerEnv": { + "TZ": "" + }, + // Fixed settings + "build": { + "dockerfile": "./Dockerfile" + }, + "postCreateCommand": "~/.windows.sh && go mod download", + "capAdd": [ + "NET_ADMIN", // Gluetun specific + "SYS_PTRACE" // for dlv Go debugging ], - "service": "vscode", - "runServices": [ - "vscode" + "securityOpt": [ + "seccomp=unconfined" // for dlv Go debugging + ], + "mounts": [ + // Zsh commands history persistence + { + "source": "${localEnv:HOME}/.zsh_history", + "target": "/root/.zsh_history", + "type": "bind" + }, + // Git configuration file + { + "source": "${localEnv:HOME}/.gitconfig", + "target": "/root/.gitconfig", + "type": "bind" + }, + // 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. + { + "source": "${localEnv:HOME}/.ssh", + "target": "/mnt/ssh", + "type": "bind" + }, + // Docker socket to access the host Docker server + { + "source": "/var/run/docker.sock", + "target": "/var/run/docker.sock", + "type": "bind" + } ], - "shutdownAction": "stopCompose", - "postCreateCommand": "~/.windows.sh && go mod download && go mod tidy", - "workspaceFolder": "/workspace", - // "overrideCommand": "", "customizations": { "vscode": { "extensions": [ diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml deleted file mode 100644 index 9075c16a2..000000000 --- a/.devcontainer/docker-compose.yml +++ /dev/null @@ -1,28 +0,0 @@ -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 - - NET_ADMIN - security_opt: - # For debugging with dlv - - seccomp:unconfined - entrypoint: [ "zsh", "-c", "while sleep 1000; do :; done" ]