From 93313cb9293a6f8ea77576d4cf1c8e56bf3562e4 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 12 May 2021 22:09:51 +1000 Subject: [PATCH] Add information on configuring a development setup in docker --- docs/start/docker_dev.md | 79 ++++++++++++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 80 insertions(+) create mode 100644 docs/start/docker_dev.md diff --git a/docs/start/docker_dev.md b/docs/start/docker_dev.md new file mode 100644 index 0000000..4b0344f --- /dev/null +++ b/docs/start/docker_dev.md @@ -0,0 +1,79 @@ +--- +title: Docker Development Setup +--- + +## Docker Development Setup + +You can also use docker to launch and manage a development server, in a similar fashion to managing a production server. + +There are some key differences compared to the docker production setup: + +- The docker image is built locally, rather than being downloaded from DockerHub +- The docker image points to the source code on your local machine, instead of cloning from GitHub +- The django webserver is used, instead of running behind Gunicorn +- The server will automatically reload when code changes are detected + +The [InvenTree docker image](https://github.com/inventree/InvenTree/blob/master/docker/Dockerfile) uses a [multi-stage build](https://docs.docker.com/develop/develop-images/multistage-build/) process to allow both production and development setups from the same image. The key difference is that the production image is pre-built using InvenTree source code from GitHub, while the development image uses the source code from your local machine (allowing live code updates). + +### Docker Compose + +A docker compose script for running a development server is provided at `docker/docker-compose.dev.yml`: + +### Setup + +#### Download Source Code + +First download the source code from GitHub: + +``` +git clone git@github.com:inventree/InvenTree.git +cd inventree/docker +``` + +#### Edit docker-compose File + +Now, edit the `docker-compose.dev.yml` file (in the `docker` subdirectory), ensuring that the `src` volume points to the directory on your local machine where you have just cloned the source code. + +#### Launch Development Server + +Launch the development server with the following command: + +``` +docker-compose -f docker-compose.dev.yml up -d inventree-server +``` + +This launches the InvenTree server (in development mode) and also performs the following tasks: + +- Creates an sqlite database +- Creates a `config.yaml` file +- Creates a `secret_key.txt` file +- Creates `inventree_media` directory for uploaded media files +- Creates `inventree_static` directory for storing static files + +!!! info "Wait for Install" + The first time the server is launched, it will take a few minutes to install the required python packages. + +Check that the server is running at [http://localhost:8000](http://localhost:8000) + +#### Create Superuser + +Once the development server is running, create a superuser (admin) account: + +``` +docker-compose -f docker-compose.dev.yml run inventree-server bash +``` + +Inside the docker shell, run the following commands: + +``` +source ./inventree-docker-dev/bin/activate +invoke superuser +``` + +#### Start Background Worker + +To launch the backround worker process: + +``` +docker-compose -f docker-compose.dev.yml up -d inventree-worker +``` diff --git a/mkdocs.yml b/mkdocs.yml index ba2aaa7..f587f53 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -47,6 +47,7 @@ nav: - Introduction: start/intro.md - Configuration: start/config.md - Docker Installation: start/docker.md + - Docker Development: start/docker_dev.md - Manual Installation: start/install.md - Development Server: start/development.md - Production Server: start/production.md