mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Simplification of development docker-compose file (#3429)
* Simplification of development docker-compose file - Rename .env file - Remove requirement for variable interpolation within the docker-compose file itself * Add debug flag to CI test * Additional quick-start docs (for docker) * docker-compose update - Introspection did not work quite as expected - Set project name inside docker-compose file * Fixes for "setup_test" task - Check if directory exists before first deleting it - Parameterize the "path" variable - Add option to ignore update step * Add demo data dir to .gitignore * Remove debug call * Update CONTRIBUTING.md
This commit is contained in:
parent
9ccf211650
commit
3fc9a36d4b
2
.gitignore
vendored
2
.gitignore
vendored
@ -36,6 +36,8 @@ local_settings.py
|
||||
*.old
|
||||
|
||||
# Files used for testing
|
||||
inventree-demo-dataset/
|
||||
inventree-data/
|
||||
dummy_image.*
|
||||
_tmp.csv
|
||||
inventree/label.pdf
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -16,5 +16,3 @@ INVENTREE_DB_PASSWORD=pgpassword
|
||||
|
||||
# Enable plugins?
|
||||
INVENTREE_PLUGINS_ENABLED=True
|
||||
|
||||
COMPOSE_PROJECT_NAME=inventree-development
|
@ -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
|
||||
|
23
tasks.py
23
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("========================================")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user