Docker Example#
Let’s check how to set up regta with docker. For this example, we wrote a little basic example project.
FROM python:3.10-buster
WORKDIR /code
ENV PYTHONPATH "${PYTHONPATH}:/code"
# Instal dependencies using poetry
RUN pip install poetry
COPY pyproject.toml ./
RUN poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi --no-dev
# Copy project's files
COPY ./ ./
# Start regta with verbose output
CMD ["regta", "run", "--path", "jobs/", "--verbose", "--logger", "logger:logger_factory"]
Example’s files Structure#
docker_example_project
├── Dockerfile
├── README.md
├── docker-compose.yaml
├── jobs
│ ├── __init__.py
│ ├── first_job.py
│ ├── second_job.py
│ └── third_job.py
├── logger.py
└── pyproject.toml
[tool.poetry]
name = "docker_example_project"
version = "0.1.0"
description = ""
authors = ["Vladimir Alinsky <Vladimir@Alinsky.tech>"]
license = "MIT"
[tool.poetry.dependencies]
python = "^3.10"
regta = "^0.3.0"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
import logging
def logger_factory():
level = logging.INFO
formatter = logging.Formatter('%(asctime)s [%(job)s] [%(levelname)s] - %(message)s')
handler = logging.FileHandler('output.log')
handler.setLevel(level)
handler.setFormatter(formatter)
logger = logging.getLogger(__name__)
logger.setLevel(level)
logger.addHandler(handler)
return logger
See also
Full example with all files is hosted in docs/source/user_guide/docker_example_project.