Skip to content

Commit

Permalink
chore(devcontainer): drop requirement for docker-compose and use devc…
Browse files Browse the repository at this point in the history
…ontainer.json settings directly
  • Loading branch information
qdm12 committed Oct 10, 2024
1 parent ea31886 commit 694988b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 47 deletions.
1 change: 0 additions & 1 deletion .devcontainer/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.dockerignore
devcontainer.json
docker-compose.yml
Dockerfile
README.md
17 changes: 8 additions & 9 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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/).
52 changes: 43 additions & 9 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
28 changes: 0 additions & 28 deletions .devcontainer/docker-compose.yml

This file was deleted.

0 comments on commit 694988b

Please sign in to comment.