2021-07-02 02:57:37 +00:00
|
|
|
FROM alpine:3.13 as base
|
2021-03-31 11:45:42 +00:00
|
|
|
|
2021-04-01 10:11:59 +00:00
|
|
|
# GitHub source
|
2021-04-07 14:05:37 +00:00
|
|
|
ARG repository="https://github.com/inventree/InvenTree.git"
|
|
|
|
ARG branch="master"
|
2021-04-01 10:11:59 +00:00
|
|
|
|
2021-08-12 12:01:14 +00:00
|
|
|
# Optionally specify a particular tag to checkout
|
|
|
|
ARG tag=""
|
|
|
|
|
2021-03-31 11:45:42 +00:00
|
|
|
ENV PYTHONUNBUFFERED 1
|
|
|
|
|
2021-10-12 13:46:46 +00:00
|
|
|
# Ref: https://github.com/pyca/cryptography/issues/5776
|
|
|
|
ENV CRYPTOGRAPHY_DONT_BUILD_RUST 1
|
|
|
|
|
2021-04-01 09:30:51 +00:00
|
|
|
# InvenTree key settings
|
2021-06-16 12:36:05 +00:00
|
|
|
|
|
|
|
# The INVENTREE_HOME directory is where the InvenTree source repository will be located
|
2021-04-01 10:11:59 +00:00
|
|
|
ENV INVENTREE_HOME="/home/inventree"
|
2021-04-01 09:30:51 +00:00
|
|
|
|
2021-04-07 14:05:37 +00:00
|
|
|
# GitHub settings
|
2021-08-12 12:01:14 +00:00
|
|
|
ENV INVENTREE_GIT_REPO="${repository}"
|
|
|
|
ENV INVENTREE_GIT_BRANCH="${branch}"
|
|
|
|
ENV INVENTREE_GIT_TAG="${tag}"
|
2021-04-07 14:05:37 +00:00
|
|
|
|
2021-04-01 13:40:47 +00:00
|
|
|
ENV INVENTREE_LOG_LEVEL="INFO"
|
2021-05-16 16:19:35 +00:00
|
|
|
ENV INVENTREE_DOCKER="true"
|
2021-04-01 13:40:47 +00:00
|
|
|
|
2021-03-31 11:45:42 +00:00
|
|
|
# InvenTree paths
|
2021-06-16 12:36:05 +00:00
|
|
|
ENV INVENTREE_MNG_DIR="${INVENTREE_HOME}/InvenTree"
|
2021-04-10 07:36:19 +00:00
|
|
|
ENV INVENTREE_DATA_DIR="${INVENTREE_HOME}/data"
|
2021-06-16 12:36:05 +00:00
|
|
|
ENV INVENTREE_STATIC_ROOT="${INVENTREE_DATA_DIR}/static"
|
2021-04-10 09:01:02 +00:00
|
|
|
ENV INVENTREE_MEDIA_ROOT="${INVENTREE_DATA_DIR}/media"
|
2021-04-01 09:14:17 +00:00
|
|
|
|
2021-04-10 07:36:19 +00:00
|
|
|
ENV INVENTREE_CONFIG_FILE="${INVENTREE_DATA_DIR}/config.yaml"
|
2021-04-10 09:01:02 +00:00
|
|
|
ENV INVENTREE_SECRET_KEY_FILE="${INVENTREE_DATA_DIR}/secret_key.txt"
|
2021-04-10 07:36:19 +00:00
|
|
|
|
2021-07-29 06:37:34 +00:00
|
|
|
# Worker configuration (can be altered by user)
|
|
|
|
ENV INVENTREE_GUNICORN_WORKERS="4"
|
|
|
|
ENV INVENTREE_BACKGROUND_WORKERS="4"
|
|
|
|
|
2021-08-17 09:58:55 +00:00
|
|
|
# Default web server address:port
|
2021-08-17 23:34:09 +00:00
|
|
|
ENV INVENTREE_WEB_ADDR=0.0.0.0
|
|
|
|
ENV INVENTREE_WEB_PORT=8000
|
2021-04-18 05:05:52 +00:00
|
|
|
|
2021-04-01 00:35:03 +00:00
|
|
|
LABEL org.label-schema.schema-version="1.0" \
|
2021-04-01 09:14:17 +00:00
|
|
|
org.label-schema.build-date=${DATE} \
|
2021-04-01 00:35:03 +00:00
|
|
|
org.label-schema.vendor="inventree" \
|
|
|
|
org.label-schema.name="inventree/inventree" \
|
2021-04-01 13:40:47 +00:00
|
|
|
org.label-schema.url="https://hub.docker.com/r/inventree/inventree" \
|
2021-08-18 01:25:19 +00:00
|
|
|
org.label-schema.vcs-url=${INVENTREE_GIT_REPO} \
|
|
|
|
org.label-schema.vcs-branch=${INVENTREE_GIT_BRANCH} \
|
2021-08-18 05:16:22 +00:00
|
|
|
org.label-schema.vcs-ref=${INVENTREE_GIT_TAG}
|
2021-04-01 00:35:03 +00:00
|
|
|
|
2021-03-31 11:45:42 +00:00
|
|
|
# Create user account
|
2021-03-31 11:54:17 +00:00
|
|
|
RUN addgroup -S inventreegroup && adduser -S inventree -G inventreegroup
|
2021-05-24 23:32:21 +00:00
|
|
|
|
2021-03-31 11:45:42 +00:00
|
|
|
# Install required system packages
|
2021-03-31 12:20:32 +00:00
|
|
|
RUN apk add --no-cache git make bash \
|
|
|
|
gcc libgcc g++ libstdc++ \
|
|
|
|
libjpeg-turbo libjpeg-turbo-dev jpeg jpeg-dev \
|
|
|
|
libffi libffi-dev \
|
2021-08-17 12:58:44 +00:00
|
|
|
zlib zlib-dev \
|
|
|
|
# Cairo deps for WeasyPrint (these will be deprecated once WeasyPrint drops cairo requirement)
|
|
|
|
cairo cairo-dev pango pango-dev \
|
|
|
|
# Fonts
|
|
|
|
fontconfig ttf-droid ttf-liberation ttf-dejavu ttf-opensans ttf-ubuntu-font-family font-croscore font-noto \
|
|
|
|
# Core python
|
|
|
|
python3 python3-dev py3-pip \
|
|
|
|
# SQLite support
|
|
|
|
sqlite \
|
|
|
|
# PostgreSQL support
|
|
|
|
postgresql postgresql-contrib postgresql-dev libpq \
|
|
|
|
# MySQL/MariaDB support
|
2021-10-06 22:26:37 +00:00
|
|
|
mariadb-connector-c mariadb-dev mariadb-client \
|
|
|
|
# Required for python cryptography support
|
2021-10-12 13:46:46 +00:00
|
|
|
openssl-dev musl-dev libffi-dev rust cargo
|
2021-03-31 11:45:42 +00:00
|
|
|
|
2021-10-12 13:52:48 +00:00
|
|
|
# Update pip
|
|
|
|
RUN pip install --upgrade pip
|
|
|
|
|
2021-08-18 02:03:24 +00:00
|
|
|
# Install required base-level python packages
|
|
|
|
COPY requirements.txt requirements.txt
|
|
|
|
RUN pip install --no-cache-dir -U -r requirements.txt
|
2021-08-18 04:47:34 +00:00
|
|
|
|
|
|
|
# Production code (pulled from tagged github release)
|
2021-05-10 04:23:17 +00:00
|
|
|
FROM base as production
|
2021-08-17 12:58:44 +00:00
|
|
|
|
2021-04-10 05:08:10 +00:00
|
|
|
# Clone source code
|
2021-08-12 12:01:14 +00:00
|
|
|
RUN echo "Downloading InvenTree from ${INVENTREE_GIT_REPO}"
|
|
|
|
|
|
|
|
RUN git clone --branch ${INVENTREE_GIT_BRANCH} --depth 1 ${INVENTREE_GIT_REPO} ${INVENTREE_HOME}
|
|
|
|
|
|
|
|
# Checkout against a particular git tag
|
|
|
|
RUN if [ -n "${INVENTREE_GIT_TAG}" ] ; then cd ${INVENTREE_HOME} && git fetch --all --tags && git checkout tags/${INVENTREE_GIT_TAG} -b v${INVENTREE_GIT_TAG}-branch ; fi
|
2021-04-10 05:08:10 +00:00
|
|
|
|
2021-08-17 12:58:44 +00:00
|
|
|
RUN chown -R inventree:inventreegroup ${INVENTREE_HOME}/*
|
2021-03-31 11:45:42 +00:00
|
|
|
|
2021-08-17 12:58:44 +00:00
|
|
|
# Drop to the inventree user
|
|
|
|
USER inventree
|
2021-04-01 13:40:47 +00:00
|
|
|
|
2021-08-17 12:58:44 +00:00
|
|
|
# Install InvenTree packages
|
2021-08-17 13:15:05 +00:00
|
|
|
RUN pip3 install --no-cache-dir --disable-pip-version-check -r ${INVENTREE_HOME}/requirements.txt
|
2021-04-01 13:40:47 +00:00
|
|
|
|
2021-08-18 06:29:54 +00:00
|
|
|
# Need to be running from within this directory
|
|
|
|
WORKDIR ${INVENTREE_MNG_DIR}
|
|
|
|
|
2021-08-17 12:58:44 +00:00
|
|
|
# Server init entrypoint
|
2021-08-18 06:29:54 +00:00
|
|
|
ENTRYPOINT ["/bin/bash", "../docker/init.sh"]
|
2021-04-10 12:25:07 +00:00
|
|
|
|
2021-08-17 12:58:44 +00:00
|
|
|
# Launch the production server
|
2021-08-19 01:14:13 +00:00
|
|
|
# TODO: Work out why environment variables cannot be interpolated in this command
|
|
|
|
# TODO: e.g. -b ${INVENTREE_WEB_ADDR}:${INVENTREE_WEB_PORT} fails here
|
2021-08-18 10:52:14 +00:00
|
|
|
CMD gunicorn -c ./docker/gunicorn.conf.py InvenTree.wsgi -b 0.0.0.0:8000 --chdir ./InvenTree
|
2021-05-10 04:23:17 +00:00
|
|
|
|
|
|
|
FROM base as dev
|
2021-05-12 10:53:50 +00:00
|
|
|
|
2021-06-15 13:05:03 +00:00
|
|
|
# The development image requires the source code to be mounted to /home/inventree/
|
|
|
|
# So from here, we don't actually "do" anything, apart from some file management
|
2021-05-10 04:23:17 +00:00
|
|
|
|
2021-08-17 10:29:48 +00:00
|
|
|
ENV INVENTREE_DEV_DIR="${INVENTREE_HOME}/dev"
|
2021-05-12 10:53:50 +00:00
|
|
|
|
2021-08-17 12:58:44 +00:00
|
|
|
# Location for python virtual environment
|
|
|
|
# If the INVENTREE_PY_ENV variable is set, the entrypoint script will use it!
|
2021-08-17 13:15:05 +00:00
|
|
|
ENV INVENTREE_PY_ENV="${INVENTREE_DEV_DIR}/env"
|
2021-08-17 12:58:44 +00:00
|
|
|
|
2021-06-16 12:36:05 +00:00
|
|
|
# Override default path settings
|
|
|
|
ENV INVENTREE_STATIC_ROOT="${INVENTREE_DEV_DIR}/static"
|
|
|
|
ENV INVENTREE_MEDIA_ROOT="${INVENTREE_DEV_DIR}/media"
|
|
|
|
ENV INVENTREE_CONFIG_FILE="${INVENTREE_DEV_DIR}/config.yaml"
|
|
|
|
ENV INVENTREE_SECRET_KEY_FILE="${INVENTREE_DEV_DIR}/secret_key.txt"
|
|
|
|
|
2021-06-15 13:05:03 +00:00
|
|
|
WORKDIR ${INVENTREE_HOME}
|
2021-05-12 10:53:50 +00:00
|
|
|
|
2021-08-17 23:52:27 +00:00
|
|
|
# Entrypoint ensures that we are running in the python virtual environment
|
|
|
|
ENTRYPOINT ["/bin/bash", "./docker/init.sh"]
|
2021-08-17 12:58:44 +00:00
|
|
|
|
2021-06-16 12:36:05 +00:00
|
|
|
# Launch the development server
|
2021-08-17 23:52:27 +00:00
|
|
|
CMD ["invoke", "server", "-a", "${INVENTREE_WEB_ADDR}:${INVENTREE_WEB_PORT}"]
|