Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/agardnerit/devcontainer
https://github.com/agardnerit/devcontainer
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/agardnerit/devcontainer
- Owner: agardnerIT
- Created: 2023-10-03T03:21:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-03T05:29:43.000Z (over 1 year ago)
- Last Synced: 2023-10-04T17:20:08.460Z (over 1 year ago)
- Language: HTML
- Size: 104 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# A Sample Dev Container
This will work with GitHub codespaces (either in browser or via your local VSCode - requires a VSCode extension).
This uses [the sample Python devcontainer](https://github.com/devcontainers/images/tree/main/src/python) as inspiration. Lots more sample environments [here](https://github.com/devcontainers/templates/tree/main/src).
Also interesting (but untested) is https://github.com/loft-sh/devpod which promises to read this file but spin up on local machines / any cloud.
Don't forget to delete your codespace after use, see below!
## Usage
To launch a new codespace, click the `Code` button, change to the `Codespaces` tab and click `Create codespace on main`.
The random, two word name for the codespace will be generated. In this case "probable winner".
![](images/1.png)
The codespace will begin creation in a new browser window. Wait until the codespace is running.
You should see this command in the terminal. Leave it running.
![](images/2.png)
Toggle over to the `Ports` tab and right click the row for port `8080`.
Choose `Open in browser`
![](images/3.png)
The demo application should be displayed.
![](images/4.png)
## Explanation
The codespace template is found in [.devcontainer/devcontainer.json](.devcontainer/devcontainer.json).
In this example, a custom container is built from the [Dockerfile](.devcontainer/Dockerfile) (but you can also reference an existing image).
After the container is built and running, the `postStartCommand` (see [.devcontainer/devcontainer.json](.devcontainer/devcontainer.json)) is used to run a flask web application server automatically for you.
The `forwardPorts` directive in [.devcontainer/devcontainer.json](.devcontainer/devcontainer.json) is used to privately (only to your GitHub user) expose port 8080 and make the application available.
## Codespace teardown
Go to https://github.com/codespaces and delete your codespace to avoid unneccessary charges!
## Links
- [DevContainer features are documented here](https://github.com/devcontainers/features)