diff --git a/.gitignore b/.gitignore index f55e48a348..6bbfdaf23d 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,8 @@ local_settings.py *.old # Files used for testing +inventree-demo-dataset/ +inventree-data/ dummy_image.* _tmp.csv inventree/label.pdf diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fc6d71dabc..cd60026f42 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,27 +1,38 @@ Hi there, thank you for your intrest in contributing! Please read the contribution guidelines below, before submitting your first pull request to the InvenTree codebase. -Up an running in 3 LOC: +## Quickstart + +The following commands will get you quickly configure and run a development server, complete with a demo dataset to work with: + +### Bare Metal + ```bash git clone https://github.com/inventree/InvenTree.git && cd InvenTree python3 -m venv env && source env/bin/activate +pip install invoke && invoke pip install invoke && invoke setup-dev --tests ``` +### Docker -## Setup +```bash +git clone https://github.com/inventree/InvenTree.git && cd InvenTree +docker compose run inventree-dev-server invoke setup-test +docker compose up -d +``` + +Read the [InvenTree setup documentation](https://inventree.readthedocs.io/en/latest/start/intro/) for a complete installation reference guide. + +### Setup Devtools Run the following command to set up all toolsets for development. + ```bash invoke setup-dev ``` -With the flag `tests` the database will additionally be populated with the [offical](https://github.com/inventree/demo-dataset) test dataset. -```bash -invoke setup-dev --tests -``` - -Run either command to set up your development setup before starting to contribute. This will install and set up `pre-commit` to run some checks before each commit and help reduce the style errors. +*We recommend you run this command before starting to contribute. This will install and set up `pre-commit` to run some checks before each commit and help reduce the style errors.* ## Branches and Versioning diff --git a/docker-compose.yml b/docker-compose.yml index 1bb2867523..17ac6ca47c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,7 @@ version: "3.8" +name: "inventree-development" + # Docker compose recipe for InvenTree development server # - Runs PostgreSQL as the database backend # - Uses built-in django webserver @@ -23,12 +25,12 @@ services: container_name: inventree-dev-db image: postgres:13 expose: - - ${INVENTREE_DB_PORT:-5432}/tcp + - 5432/tcp environment: - PGDATA=/var/lib/postgresql/data/pgdb - - POSTGRES_USER=${INVENTREE_DB_USER:?You must provide the 'INVENTREE_DB_USER' variable in the .env file} - - POSTGRES_PASSWORD=${INVENTREE_DB_PASSWORD:?You must provide the 'INVENTREE_DB_PASSWORD' variable in the .env file} - - POSTGRES_DB=${INVENTREE_DB_NAME:?You must provide the 'INVENTREE_DB_NAME' variable in the .env file} + - POSTGRES_USER=pguser + - POSTGRES_PASSWORD=pgpassword + - POSTGRES_DB=inventree volumes: # Map 'data' volume such that postgres database is stored externally - ./data:/var/lib/postgresql/data @@ -52,7 +54,7 @@ services: # Mount local source directory to /home/inventree - ./:/home/inventree env_file: - - .env + - docker.dev.env restart: unless-stopped # Background worker process handles long-running or periodic tasks @@ -66,5 +68,5 @@ services: # Mount local source directory to /home/inventree - ./:/home/inventree env_file: - - .env + - docker.dev.env restart: unless-stopped diff --git a/.env b/docker.dev.env similarity index 92% rename from .env rename to docker.dev.env index 586b0daab3..ac91f59769 100644 --- a/.env +++ b/docker.dev.env @@ -16,5 +16,3 @@ INVENTREE_DB_PASSWORD=pgpassword # Enable plugins? INVENTREE_PLUGINS_ENABLED=True - -COMPOSE_PROJECT_NAME=inventree-development diff --git a/docker/production/docker-compose.yml b/docker/production/docker-compose.yml index e691ed7fa2..9f5e3689be 100644 --- a/docker/production/docker-compose.yml +++ b/docker/production/docker-compose.yml @@ -1,5 +1,7 @@ version: "3.8" +name: "inventree-production" + # Docker compose recipe for a production-ready InvenTree setup, with the following containers: # - PostgreSQL as the database backend # - gunicorn as the InvenTree web server diff --git a/tasks.py b/tasks.py index 6fb2e6140f..5f03c2aade 100644 --- a/tasks.py +++ b/tasks.py @@ -518,25 +518,30 @@ def test(c, database=None): manage(c, 'test', pty=True) -@task(pre=[update], help={'dev': 'Set up development enviroment at the end'}) -def setup_test(c, dev=False): +@task(help={'dev': 'Set up development enviroment at the end'}) +def setup_test(c, ignore_update=False, dev=False, path="inventree-demo-dataset"): """Setup a testing enviroment.""" + + if not ignore_update: + update(c) + # Remove old data directory - print("Removing old data ...") - c.run('rm inventree-data -r') + if os.path.exists(path): + print("Removing old data ...") + c.run(f'rm {path} -r') # Get test data - print("Starting to clone demo dataset ...") - c.run('git clone https://github.com/inventree/demo-dataset inventree-data') + print("Cloning demo dataset ...") + c.run(f'git clone https://github.com/inventree/demo-dataset {path} -v') print("========================================") # Make sure migrations are done - might have just deleted sqlite database - print("Running migrations ...") - migrate(c) + if not ignore_update: + migrate(c) # Load data print("Loading data ...") - import_records(c, filename='inventree-data/inventree_data.json', clear=True) + import_records(c, filename=f'{path}/inventree_data.json', clear=True) print("Done setting up test enviroment...") print("========================================")