Skip to content

Commit

Permalink
docs: update README.md and .devcontainer/README.md
Browse files Browse the repository at this point in the history
- remove Windows without WSL step
- update 'remote containers extension' to 'dev containers extension'
- remove invalid warning on `~/.docker` directory creation
- simplify customizations section
  - remove "publish a port" since it can be done at runtime now
   - expand documentation on custom welcome script and where to specify the bind mount
   - use bullet points instead of subsections headings
  • Loading branch information
qdm12 committed Oct 11, 2024
1 parent d6d4491 commit 3671eed
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 32 deletions.
53 changes: 26 additions & 27 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ 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
- [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

Expand All @@ -20,41 +20,40 @@ It works on Linux, Windows and OSX.
mkdir -p ~/.ssh
```

1. **For Docker on OSX or Windows without WSL**: ensure your home directory `~` is accessible by Docker.
1. **For Docker on OSX**: ensure the project directory and your home directory `~` are 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.
1. Select `Dev Containers: Open Folder in Container...` and choose the project directory.

## Customization
## Customizations

### Customize the image
For customizations to take effect, you should "rebuild and reopen":

You can make changes to the [Dockerfile](Dockerfile) and then rebuild the image. For example, your Dockerfile could be:
1. Open the command palette in Visual Studio Code (CTRL+SHIFT+P)
2. Select `Dev Containers: Rebuild Container`

```Dockerfile
FROM qmcgaw/godevcontainer
RUN apk add curl
```
Customizations available are notably:

To rebuild the image, either:
- Extend the Docker image in [Dockerfile](Dockerfile). For example add curl to it:

- 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
```Dockerfile
FROM qmcgaw/godevcontainer
RUN apk add curl
```

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.
- Changes to VSCode **settings** and **extensions** in [devcontainer.json](devcontainer.json).
- Change the entrypoint script by adding a bind mount in [devcontainer.json](devcontainer.json) of 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:

### Run other services
```json
// Welcome script
{
"source": "./.welcome.sh",
"target": "/root/.welcome.sh",
"type": "bind"
},
```

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:
- Change the `vscode` service container configuration either in [docker-compose.yml](docker-compose.yml) or in [devcontainer.json](devcontainer.json).
- Add other services in [docker-compose.yml](docker-compose.yml) to run together with the development VSCode service container. For example to add a test database:

```yml
database:
Expand All @@ -64,4 +63,4 @@ To access a port from your host to your development container, publish a port in
POSTGRES_PASSWORD: password
```

1. In the VS code command palette, rebuild the container.
- More customizations available are documented in the [devcontainer.json reference](https://containers.dev/implementors/json_reference/).
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
## Requirements

- [Docker](https://www.docker.com/products/docker-desktop) installed and running
- If you don't use Linux or Windows with WSL, share the directory `~/.ssh` and the directory of your project with Docker Desktop
- If you use OSX, share the `~/.ssh` directory and the directory of your project with Docker Desktop
- [Docker Compose](https://docs.docker.com/compose/install/) installed
- [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
- [VS code dev containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed

## Setup for a project

Expand All @@ -80,7 +80,7 @@
Or use the [built binary](https://github.com/qdm12/devtainr#binary)
- Or manually: download this repository and put the [.devcontainer](.devcontainer) directory in your project.
1. 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*.
1. Open the command palette in Visual Studio Code (CTRL+SHIFT+P) and select `Remote-Containers: Open Folder in Container...` and choose your project directory
1. Open the command palette in Visual Studio Code (CTRL+SHIFT+P) and select `Dev Containers: Open Folder in Container...` and choose your project directory
## Customization
Expand Down
2 changes: 1 addition & 1 deletion alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ LABEL \
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"
org.opencontainers.image.description="Go development container for Visual Studio Code Dev Containers development"
COPY --from=go /usr/local/go /usr/local/go
ENV GOPATH=/go
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH \
Expand Down
2 changes: 1 addition & 1 deletion debian.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ LABEL \
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"
org.opencontainers.image.description="Go development container for Visual Studio Code Dev Containers development"
COPY --from=go /usr/local/go /usr/local/go
ENV GOPATH=/go
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH \
Expand Down

0 comments on commit 3671eed

Please sign in to comment.