Development docker image

- Uses multistage build
- Adds a docker compose file for dev
This commit is contained in:
Oliver Walters 2021-05-10 14:23:17 +10:00
parent d301794516
commit 914db9e913
4 changed files with 80 additions and 1 deletions

View File

@ -30,6 +30,7 @@ jobs:
context: ./docker context: ./docker
platforms: linux/amd64,linux/arm64,linux/arm/v7 platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true push: true
target: production
repository: inventree/inventree repository: inventree/inventree
tags: inventree/inventree:latest tags: inventree/inventree:latest
- name: Image Digest - name: Image Digest

View File

@ -28,4 +28,5 @@ jobs:
repository: inventree/inventree repository: inventree/inventree
tag_with_ref: true tag_with_ref: true
dockerfile: ./Dockerfile dockerfile: ./Dockerfile
target: production
platforms: linux/amd64,linux/arm64,linux/arm/v7 platforms: linux/amd64,linux/arm64,linux/arm/v7

View File

@ -1,4 +1,4 @@
FROM python:alpine as production FROM python:alpine as base
# GitHub source # GitHub source
ARG repository="https://github.com/inventree/InvenTree.git" 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 psycopg2 mysqlclient pgcli mariadb
RUN pip install --no-cache-dir -U gunicorn RUN pip install --no-cache-dir -U gunicorn
FROM base as production
# Clone source code # Clone source code
RUN echo "Downloading InvenTree from ${INVENTREE_REPO}" RUN echo "Downloading InvenTree from ${INVENTREE_REPO}"
RUN git clone --branch ${INVENTREE_BRANCH} --depth 1 ${INVENTREE_REPO} ${INVENTREE_SRC_DIR} RUN git clone --branch ${INVENTREE_BRANCH} --depth 1 ${INVENTREE_REPO} ${INVENTREE_SRC_DIR}
@ -97,3 +98,9 @@ WORKDIR ${INVENTREE_SRC_DIR}
# Let us begin # Let us begin
CMD ["bash", "./start_prod_server.sh"] 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}

View File

@ -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: