Docker presentation and demo for Python in the Grass 🐍 🌱
Very little of this gets tested on Windows hosts. Windows Subsystem for Linux (WSL) is used where necessary with the default Ubuntu LTS install. Moved bulk of document to the docs directory to opt-in vs. opt-out of documentation.
Table of Contents
Development environments and tooling are first-class citizens on macOS and *nix. For Windows faithfuls, please setup WSL.
# install python w/asdf
asdf list python
asdf install python 3.11.3
# create virtual environment
poetry config virtualenvs.in-project true
poetry env use python
poetry install --no-root# poetry
poetry run ./startup.sh <override_port> # ctrl-c to exit
# docker
docker build -t my-hello-world -f Dockerfile.web .
docker run -it --rm -p 80:3000 my-hello-world # ctrl-c to exit
docker exec -it my-hello-world bash # ctrl-d to exit
# docker-compose
docker-compose build --no-cache --parallel
docker-compose up -d
docker-compose down --remove-orphans
# justfile
just # list all options
## docker
just run # ctrl-c to exit
just exec # ctrl-d to exit
## docker-compose
just build-clean # docker-compose build --no-cache --parallel
just up # docker-compose up -d
just down # docker-compose down --remove-orphansCopy the .env.example file to .env and modify the values as needed.
Default port is 3000. If you want to override the port, pass it as an argument to the startup.sh script.
Open a browser to either the override port or the default port to see the application running (e.g. http://localhost:3000).
Available endpoints are /docs and /message/{msg}; latter encodes whitespace as %20 automatically.
Docker Hub is a cloud-based repository in which Docker users and partners create, test, store and distribute container images. Docker images are pushed to Docker Hub through the docker push command. A single Docker Hub repository can hold many Docker images (stored as tags).
Automated CI is implemented via GitHub Actions to build and push this repository's image to Docker Hub in .github/workflows/ci.yml.
- Add repository secrets (Docker Hub)
DOCKERHUB_TOKENDOCKERHUB_USER
- Add environment variable (image name)
APP_NAME
For completeness, add another git repo as a submodule.
bash git submodule add https://github.com/pythoninthegrass/node_with_docker.git node git submodule update --init --recursive git submodule update --recursive
Instructions to create a token.
Instructions to disable this action if you don't want this feature.