diff --git a/.github/workflows/docker_build.yaml b/.github/workflows/docker_build.yaml index 26fc69a0f5..ec8bdf7306 100644 --- a/.github/workflows/docker_build.yaml +++ b/.github/workflows/docker_build.yaml @@ -30,6 +30,7 @@ jobs: context: ./docker platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true + target: production repository: inventree/inventree tags: inventree/inventree:latest - name: Image Digest diff --git a/.github/workflows/docker_publish.yaml b/.github/workflows/docker_publish.yaml index c25696d6dd..4a8cef0952 100644 --- a/.github/workflows/docker_publish.yaml +++ b/.github/workflows/docker_publish.yaml @@ -28,4 +28,5 @@ jobs: repository: inventree/inventree tag_with_ref: true dockerfile: ./Dockerfile + target: production platforms: linux/amd64,linux/arm64,linux/arm/v7 diff --git a/docker/Dockerfile b/docker/Dockerfile index c95c2867df..504236c131 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM python:alpine as production +FROM python:alpine as base # GitHub source ARG repository="https://github.com/inventree/InvenTree.git" @@ -73,6 +73,7 @@ RUN pip install --no-cache-dir -U invoke RUN pip install --no-cache-dir -U psycopg2 mysqlclient pgcli mariadb RUN pip install --no-cache-dir -U gunicorn +FROM base as production # Clone source code RUN echo "Downloading InvenTree from ${INVENTREE_REPO}" RUN git clone --branch ${INVENTREE_BRANCH} --depth 1 ${INVENTREE_REPO} ${INVENTREE_SRC_DIR} @@ -97,3 +98,9 @@ WORKDIR ${INVENTREE_SRC_DIR} # Let us begin CMD ["bash", "./start_prod_server.sh"] + +FROM base as dev +# The development image requires the source code to be mounted to /home/inventree/src/ +# So from here, we don't actually "do" anything + +WORKDIR ${INVENTREE_SRC_DIR} diff --git a/docker/docker-compose.dev.yml b/docker/docker-compose.dev.yml new file mode 100644 index 0000000000..b2e64f026a --- /dev/null +++ b/docker/docker-compose.dev.yml @@ -0,0 +1,70 @@ +version: "3.8" + +# Docker compose recipe for InvenTree development server +# - Runs sqlite3 as the database backend +# - Uses built-in django webserver + +# IMPORANT NOTE: +# The InvenTree docker image does not clone source code from git. +# Instead, you must specify *where* the source code is located, +# (on your local machine). +# The django server will auto-detect any code changes and reload the server. + +services: + # InvenTree web server services + # Uses gunicorn as the web server + inventree-server: + container_name: inventree-server + image: inventree/inventree:latest + entrypoint: ./start_dev_server.sh + ports: + - 8000 + depends_on: + - inventree-db + volumes: + # Ensure you specify the location of the 'src' directory at the end of this file + - src:/home/inventree/src + - data:/home/inventree/data + - static:/home/inventree/static + environment: + # Configure a simple sqlite server for development + # Note: You can always change to a different database backend if required! + - INVENTREE_DB_ENGINE=sqlite + - INVENTREE_DB_NAME=inventree + restart: unless-stopped + + # Background worker process handles long-running or periodic tasks + inventree-worker: + container_name: inventree-worker + image: inventree/inventree:latest + entrypoint: ./start_worker.sh + depends_on: + - inventree-db + - inventree-server + volumes: + # Ensure you specify the location of the 'src' directory at the end of this file + - data:/home/inventree/data + - static:/home/inventree/static + environment: + # Configure a simple sqlite server for development + # Note: You can always change to a different database backend if required! + - INVENTREE_DB_ENGINE=sqlite + - INVENTREE_DB_NAME=inventree + restart: unless-stopped + +volumes: + # NOTE: Change /path/to/src to a directory on your local machine, where the InvenTree source code is located + # This directory must conatin the file *manage.py* + # Persistent data, stored external to the container(s) + src: + driver: local + driver_opts: + type: none + o: bind + # This directory specified where InvenTree source code is stored "outside" the docker containers + # Note: This directory must conatin the file *manage.py* + device: /path/to/src + # Uploaded data / media files, shared between containers + data: + # Static files, shared between containers + static: \ No newline at end of file