Skip to content

Latest commit

 

History

History
102 lines (74 loc) · 2.45 KB

README.md

File metadata and controls

102 lines (74 loc) · 2.45 KB

Docker App Image CI

Local Setup

Requirements

We need a couple of tools (pre-commit and poetry) installed globally. For that we advice using pipx (Python Application Manager). pipx installs each tool in it's own virtual environment and exposes the tool by manipulating the PATH.

# install pipx
python3 -m pip install --user pipx
python3 -m pipx ensurepath

# install requirements
pipx install poetry
pipx install pre-commit

Virtual environment and dependencies

We use poetry to manage the virtual environment and also the dependencies.

# create virtual environment and install dependencies
poetry install
# activate the virtual environment
poetry shell

See the usage details in the poetry documentation.

pre-commit

pre-commit is a framework for running various linters locally on every commit. It points out annoying formatting/linter errors before the CI pipeline or a code review does.

# activate it in project
pre-commit install

This will run all specified linters in .pre-commit-config.yaml, and block the commit in case there is an error. Certain linters might also modify files (e.g. reformat code), so you might need to add the changes again to Git and make the commit again.

See the usage details in the Formatting / Linting documentation.

IDE integration

See the IDE Integration documentation.

Run

Run server

# start the server
uvicorn data_analyzer.main:app --port 8080
# or simply run main.py

Run tests and static code analysis

# run tests
pytest
# run mypy
mypy 

See more usage details and configuration in the Testing documentation.

Run Docker container

# run and build the application
docker-compose build app
docker-compose run app

# run tests
docker-compose build dev
docker-compose run dev

# run pre-commit in Docker
docker-compose build pre-commit
docker-compose run pre-commit

Run the database

Create a .env file in the root of the project containing the following:

POSTGRES_USER=dev
POSTGRES_PASSWORD=dev
POSTGRES_SERVER=localhost
POSTGRES_PORT=5432
POSTGRES_DB=dataanalyzer

and run

docker-compose run -d postgres