2021-05-10 04:23:17 +00:00
|
|
|
FROM python:alpine 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-03-31 11:45:42 +00:00
|
|
|
ENV PYTHONUNBUFFERED 1
|
|
|
|
|
2021-04-01 09:30:51 +00:00
|
|
|
# InvenTree key settings
|
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
|
|
|
|
ENV INVENTREE_REPO="${repository}"
|
|
|
|
ENV INVENTREE_BRANCH="${branch}"
|
|
|
|
|
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-04-01 09:14:17 +00:00
|
|
|
ENV INVENTREE_SRC_DIR="${INVENTREE_HOME}/src"
|
2021-04-01 13:03:56 +00:00
|
|
|
ENV INVENTREE_MNG_DIR="${INVENTREE_SRC_DIR}/InvenTree"
|
2021-04-10 07:36:19 +00:00
|
|
|
ENV INVENTREE_DATA_DIR="${INVENTREE_HOME}/data"
|
2021-04-10 12:08:36 +00:00
|
|
|
ENV INVENTREE_STATIC_ROOT="${INVENTREE_HOME}/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-04-18 05:05:52 +00:00
|
|
|
# Default web server port is 8000
|
|
|
|
ENV INVENTREE_WEB_PORT="8000"
|
|
|
|
|
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-04-01 09:14:17 +00:00
|
|
|
org.label-schema.version=${INVENTREE_VERSION} \
|
|
|
|
org.label-schema.vcs-url=${INVENTREE_REPO} \
|
|
|
|
org.label-schema.vcs-branch=${BRANCH} \
|
|
|
|
org.label-schema.vcs-ref=${COMMIT}
|
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-04-01 10:11:59 +00:00
|
|
|
WORKDIR ${INVENTREE_HOME}
|
2021-03-31 11:45:42 +00:00
|
|
|
|
2021-05-24 23:32:21 +00:00
|
|
|
RUN mkdir -p ${INVENTREE_STATIC_ROOT}
|
2021-04-10 12:08:36 +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-03-31 12:22:17 +00:00
|
|
|
zlib zlib-dev
|
2021-04-18 04:45:41 +00:00
|
|
|
|
|
|
|
# Cairo deps for WeasyPrint (these will be deprecated once WeasyPrint drops cairo requirement)
|
2021-03-31 12:20:32 +00:00
|
|
|
RUN apk add --no-cache cairo cairo-dev pango pango-dev
|
|
|
|
RUN apk add --no-cache fontconfig ttf-droid ttf-liberation ttf-dejavu ttf-opensans ttf-ubuntu-font-family font-croscore font-noto
|
2021-04-18 04:45:41 +00:00
|
|
|
|
|
|
|
# Python
|
2021-04-18 04:50:22 +00:00
|
|
|
RUN apk add --no-cache python3 python3-dev
|
2021-04-18 04:45:41 +00:00
|
|
|
|
|
|
|
# SQLite support
|
2021-04-18 04:57:25 +00:00
|
|
|
RUN apk add --no-cache sqlite
|
2021-04-18 04:45:41 +00:00
|
|
|
|
|
|
|
# PostgreSQL support
|
2021-04-18 05:05:52 +00:00
|
|
|
RUN apk add --no-cache postgresql postgresql-contrib postgresql-dev libpq
|
2021-04-18 04:45:41 +00:00
|
|
|
|
|
|
|
# MySQL support
|
2021-04-18 05:09:01 +00:00
|
|
|
RUN apk add --no-cache mariadb-connector-c mariadb-dev mariadb-client
|
2021-03-31 11:45:42 +00:00
|
|
|
|
2021-04-10 11:40:27 +00:00
|
|
|
# Install required python packages
|
|
|
|
RUN pip install --upgrade pip setuptools wheel
|
|
|
|
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
|
2021-03-31 11:45:42 +00:00
|
|
|
|
2021-05-10 04:23:17 +00:00
|
|
|
FROM base as production
|
2021-04-10 05:08:10 +00:00
|
|
|
# Clone source code
|
|
|
|
RUN echo "Downloading InvenTree from ${INVENTREE_REPO}"
|
|
|
|
RUN git clone --branch ${INVENTREE_BRANCH} --depth 1 ${INVENTREE_REPO} ${INVENTREE_SRC_DIR}
|
|
|
|
|
2021-03-31 11:45:42 +00:00
|
|
|
# Install InvenTree packages
|
2021-04-10 11:40:27 +00:00
|
|
|
RUN pip install --no-cache-dir -U -r ${INVENTREE_SRC_DIR}/requirements.txt
|
2021-03-31 11:45:42 +00:00
|
|
|
|
2021-04-01 09:38:18 +00:00
|
|
|
# Copy gunicorn config file
|
2021-04-07 13:46:03 +00:00
|
|
|
COPY gunicorn.conf.py ${INVENTREE_HOME}/gunicorn.conf.py
|
2021-04-01 13:40:47 +00:00
|
|
|
|
2021-04-10 05:08:10 +00:00
|
|
|
# Copy startup scripts
|
2021-04-18 06:26:32 +00:00
|
|
|
COPY start_prod_server.sh ${INVENTREE_SRC_DIR}/start_prod_server.sh
|
2021-04-10 12:35:10 +00:00
|
|
|
COPY start_worker.sh ${INVENTREE_SRC_DIR}/start_worker.sh
|
2021-04-01 13:40:47 +00:00
|
|
|
|
2021-04-18 06:26:32 +00:00
|
|
|
RUN chmod 755 ${INVENTREE_SRC_DIR}/start_prod_server.sh
|
2021-04-10 12:35:10 +00:00
|
|
|
RUN chmod 755 ${INVENTREE_SRC_DIR}/start_worker.sh
|
2021-04-01 13:40:47 +00:00
|
|
|
|
2021-04-10 12:25:07 +00:00
|
|
|
# exec commands should be executed from the "src" directory
|
|
|
|
WORKDIR ${INVENTREE_SRC_DIR}
|
|
|
|
|
2021-04-01 13:40:47 +00:00
|
|
|
# Let us begin
|
2021-04-18 06:26:32 +00:00
|
|
|
CMD ["bash", "./start_prod_server.sh"]
|
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-06-15 13:05:03 +00:00
|
|
|
ENV INVENTREE_DEV_DIR = "${INVENTREE_HOME}/dev"
|
2021-05-12 10:53:50 +00:00
|
|
|
|
2021-06-15 13:05:03 +00:00
|
|
|
WORKDIR ${INVENTREE_HOME}
|
2021-05-12 10:53:50 +00:00
|
|
|
|
2021-06-15 13:05:03 +00:00
|
|
|
CMD ["bash", "/home/inventree/docker/start_dev_server.sh"]
|