Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jmgogo/devcontainer-w-dockerfile
Repo to demonstrate the setup of a python:3.9-alpine development container with a Dockerfile for use on Visual Studio Code.
https://github.com/jmgogo/devcontainer-w-dockerfile
devcontainers docker dockerfile python-alpine
Last synced: about 2 months ago
JSON representation
Repo to demonstrate the setup of a python:3.9-alpine development container with a Dockerfile for use on Visual Studio Code.
- Host: GitHub
- URL: https://github.com/jmgogo/devcontainer-w-dockerfile
- Owner: jmgogo
- License: mit
- Created: 2023-09-20T02:08:27.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-26T20:48:41.000Z (about 1 year ago)
- Last Synced: 2024-09-21T01:33:46.069Z (3 months ago)
- Topics: devcontainers, docker, dockerfile, python-alpine
- Language: Dockerfile
- Homepage:
- Size: 163 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Devcontainer with Dockerfile
Foreword
python:3.9-alpine development container setup with dockerfile for use on Visual Studio.
Report Bug
·
Request Feature
## Table of Contents
## About
[Devcontainer with Compose](https://github.com/jgome284/devcontainer-w-dockerfile)This project serves as an example of how to setup a development container. A Development Container (or Dev Container for short) allows you to use a container as a full-featured development environment. It can be used to run an application, to separate tools, libraries, or runtimes needed for working with a codebase, and to aid in continuous integration and testing. Dev containers can be run locally or remotely, in a private or public cloud, in a variety of supporting tools and editors.
[This devcontainer](.devcontainer), is built IAW the [dev containers specification](https://containers.dev/implementors/spec/) and tailored for a build environment that runs on alpine linux and python with the cowsay library as an additional dependency for demonstration purposes. Additionally, the devcontainer has git for version control and several extensions installed for Visual Studio Code as development utilities.
## Prerequisites
To start, you need to have Docker Engine and Docker Compose on your machine. You can either:
* Install Docker Desktop which includes both Docker Engine and Docker Compose
* Install Docker Engine and Docker Compose as standalone binariesAdditionally, this devcontainer is meant to work on Visual Studio Code. You should have it installed along with the [remote development pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) to enable the IDE's devcontainers functionality.
Create a `config.sh` file to host your git configuration settings. This file is run as a `postCreateCommand` as specified in `.devcontainer.json`. The format of this file should looks as such:
```sh
#!/bin/ash
echo "" # add white space for formattingecho "Configuring Git..."
echo "-----------------------------------------"
# config username and print for confirmation
git config --global user.name "YOUR NAME"
echo -n "User: "
git config --global user.name
# config email and print for confirmation
git config --global user.email "YOUR EMAIL"
echo -n "Email: "
git config --global user.email
echo "" # add white space for formattingecho "Displaying OS Info..."
echo "-----------------------------------------"
cat /etc/os-release
echo "" # add white space for formatting
```
All dependencies within your `requirements.txt` file will be handled during the build process with Docker.## Getting started
This project is setup to work with Docker on Visual Studio Code. Once the [remote development pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) extension is installed, start the development container by running `Dev Containers: Rebuild and Reopen In Container` in the command palette. It can be accessed with the keyboard shortcut `ctrl + shift + P` on your keyboard. The command shows as follows:![Rebuild and Reopen In Container](imgs/rebuildAndReopenInContainer.png)
Doing so will start the build process for the devcontainer. Visual Studio will establish a remote connection to the development container with several common python extensions installed in the IDE. Of note when a successful connection is established to the container, the user name and email provided for git configuration is displayed along with information for the alpine-linux OS as shown below:
![Operating System Information](imgs/postCreate.png)
The `src` folder includes a python file, ``main.py``, that can be run to validate that the `cowsay` dependency included in our `requirements.txt` file was added correctly.
To validate that requirements were installed correctly, run:
```sh
python src/main.py
```
A little cow from the cowsay library should display with a very special greeting in your console.
![Hello World!](imgs/cowsayHelloWorld.png)## License
Distributed under the MIT License. See `LICENSE` for more information.