Skip to content

tailucas/simple-app

Repository files navigation

simple-app

Simplest possible app based on base-app whose built images are maintained by me in the GitHub Container Registry.

Required Tools

  1. Install the docker engine with the current user added to the docker group to eliminate the need to run the docker CLI using sudo. You will also need the compose CLI plugin.
  2. Install the Dev Container CLI. NodeJS on which the CLI depends can be installed using this.
  3. Clone this project: https://github.com/tailucas/simple-app.git
  4. Use the project's provided Makefile whose default action is to build and start a development container, by simply invoking make. If make successful, your terminal will show the session on the development container, running as the user vscode.
vscode ➜ /home/user/simple-app (main) $ whoami
vscode

Note: this step can be replaced by opening the simple-app folder in vscode which will automatically detect the dev container configuration in .devcontainer/ and prompt to re-open the project in a container. At this point, you can start a terminal session within the editor and this is redunant.

Explore the project

  1. Open ./app/__main__.py for an example Python project. Make sure that VS Code has selected ./.venv/bin/python as the runtime that Poetry has set up for you, then imports to tailucas_pylib will resolve properly.
  2. Verify that the local Java dependencies are working by opening ./src/main/java/simple/app/App.java and checking imports.

Configure the project

If you do not want to run any Python app, set the environment variable NO_PYTHON_APP to anything. See base_entrypoint.sh for an example. If you do not want to run a Java app, set the environment variable RUN_JAVA_APP to anything other than true. See base_entrypoint.sh for an example. See the create-dot-env command in Taskfile.yml for example environment variable settings.

Build and run the runtime container

  1. In a dev container terminal session, run the applications using task run and in a separate terminal look for the application logs under /var/log/syslog.

Note: the applications are designed to run in an application container via the task run command for interactive execution or task rund for background execution from which Docker will then manage the container life-cycle. For development purposes, the Java sample can be run directly from VS Code and the Python application can be run from the command-line using poetry run app which uses a tooling hint found in pyproject.toml. task rund is useful because the terminal session can be closed and your built container will continue running on the host docker instance, made possible by the feature ghcr.io/devcontainers/features/docker-outside-of-docker:1 configured in base-app.