<< Short Description >>
<< List of features >>
To install the latest version of the <> Service, run the following command:
docker pull ghcr.io/schweizerischebundesbahnen/<<docker-image-name>>:latest
To start the <> service container, execute:
docker run --detach \
--init \
--publish <<port>>:<<port>> \
--name <<docker-image-name>> \
ghcr.io/schweizerischebundesbahnen/<<docker-image-name>>:latest
The service will be accessible on port <>.
Important: The
--init
flag enables Docker's built-in init process which handles signal forwarding and zombie process reaping. This is required for proper operation of the service.
The service includes a robust logging system with the following features:
- Log files are stored in
/opt/<<docker-image-name>>/logs
directory - Log level can be configured via
LOG_LEVEL
environment variable (default: INFO) - Log format:
timestamp - logger name - log level - message
- Each service start creates a new timestamped log file
To customize logging when running the container:
docker run --detach \
--publish <<port>>:<<port>> \
--name <<docker-image-name>> \
--env LOG_LEVEL=DEBUG \
--volume /path/to/local/logs:/opt/<<docker-image-name>>/logs \
ghcr.io/schweizerischebundesbahnen/<<docker-image-name>>:latest
Available log levels:
- DEBUG: Detailed information for debugging
- INFO: General operational information (default)
- WARNING: Warning messages for potential issues
- ERROR: Error messages for failed operations
- CRITICAL: Critical issues that require immediate attention
To extend or customize the service, use it as a base image in the Dockerfile:
FROM ghcr.io/schweizerischebundesbahnen/<<docker-image-name>>:latest
To run the service using Docker Compose:
docker-compose up -d
The Docker Compose configuration includes the init: true
parameter which enables proper process management for the container.
To build the Docker image from the source with a custom version, use:
docker build \
--build-arg APP_IMAGE_VERSION=0.0.0 \
--file Dockerfile \
--tag <<docker-image-name>>:0.0.0 .
Replace 0.0.0 with the desired version number.
To start the Docker container with your custom-built image:
docker run --detach \
--publish 9080:9080 \
--name <<docker-container-name>> \
<<docker-image-name>>:0.0.0
To stop the running container, execute:
docker container stop <<docker-container-name>>
The container-structure-test tool is used to verify that the Docker image meets expected standards and specifications. It validates the container structure, ensuring proper file paths, permissions, and commands are available, which helps maintain consistency and reliability of the containerized application.
Before running the following command, ensure that the container-structure-test
tool is installed. You can find installation instructions in the official documentation.
container-structure-test test --image <<docker-container-name>>:0.0.0 --config ./tests/container/container-structure-test.yaml
Grype is used for vulnerability scanning of the Docker image. This tool helps identify known security vulnerabilities in the dependencies and packages included in the container, ensuring the deployed application meets security standards and doesn't contain known exploitable components.
To scan the Docker image for vulnerabilities, you can use Grype. First, ensure that Grype is installed by following the installation instructions.
Then run the vulnerability scan on your image:
grype <<docker-container-name>>:0.0.0
Tox automates testing in different Python environments, ensuring that the application works correctly across various Python versions and configurations. It helps maintain compatibility and provides a standardized way to run test suites, formatting checks, and other quality assurance processes.
poetry run tox
Pytest is used for unit and integration testing of the application code. These tests verify that individual components and the entire application function correctly according to specifications. Running pytest during development helps catch bugs early and ensures code quality.
# all tests
poetry run pytest
# a specific test
poetry run pytest tests/test_app.py -v
Pre-commit hooks run automated checks on code before it's committed to the repository. This ensures consistent code style, formatting, and quality across the project. It helps catch common issues early in the development process, maintaining high code standards and reducing the need for style-related revisions during code reviews.
poetry run pre-commit run --all
This service provides REST API. OpenAPI Specification can be obtained here.