2021-03-31 11:45:42 +00:00
|
|
|
FROM python:alpine as production
|
|
|
|
|
2021-04-01 10:11:59 +00:00
|
|
|
# GitHub source
|
2021-03-31 11:45:42 +00:00
|
|
|
ARG INVENTREE_REPO="https://github.com/inventree/InvenTree.git"
|
|
|
|
ARG INVENTREE_VERSION="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-01 13:40:47 +00:00
|
|
|
ENV INVENTREE_LOG_LEVEL="INFO"
|
|
|
|
|
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-01 09:14:17 +00:00
|
|
|
ENV INVENTREE_STATIC_ROOT="${INVENTREE_HOME}/static"
|
|
|
|
ENV INVENTREE_MEDIA_ROOT="${INVENTREE_HOME}/media"
|
|
|
|
ENV INVENTREE_LOG_DIR="${INVENTREE_HOME}/log"
|
|
|
|
ENV INVENTREE_BACKUP_DIR="${INVENTREE_HOME}/backup"
|
|
|
|
ENV INVENTREE_VENV="${INVENTREE_HOME}/env"
|
|
|
|
|
|
|
|
# Pass DB configuration through as environment variables
|
|
|
|
ENV INVENTREE_DB_ENGINE="${INVENTREE_DB_ENGINE}"
|
|
|
|
ENV INVENTREE_DB_NAME="${INVENTREE_DB_NAME}"
|
|
|
|
ENV INVENTREE_DB_HOST="${INVENTREE_DB_HOST}"
|
|
|
|
ENV INVENTREE_DB_PORT="${INVENTREE_DB_PORT}"
|
|
|
|
ENV INVENTREE_DB_USER="${INVENTREE_DB_USER}"
|
|
|
|
ENV INVENTREE_DB_PASSWORD="${INVENTREE_DB_PASSWORD}"
|
2021-03-31 11:45:42 +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-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
|
|
|
RUN echo "Installing InvenTree '${INVENTREE_VERSION}' from ${INVENTREE_REPO}"
|
|
|
|
|
|
|
|
# Create user account
|
2021-03-31 11:54:17 +00:00
|
|
|
RUN addgroup -S inventreegroup && adduser -S inventree -G inventreegroup
|
2021-04-01 10:11:59 +00:00
|
|
|
WORKDIR ${INVENTREE_HOME}
|
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-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
|
|
|
|
RUN apk add --no-cache python3
|
2021-03-31 12:03:13 +00:00
|
|
|
RUN apk add --no-cache postgresql-contrib postgresql-dev libpq
|
2021-03-31 12:06:54 +00:00
|
|
|
RUN apk add --no-cache mariadb-connector-c mariadb-dev
|
2021-03-31 11:45:42 +00:00
|
|
|
|
2021-03-31 12:20:32 +00:00
|
|
|
# Clone source code
|
2021-04-01 09:14:17 +00:00
|
|
|
RUN git clone --branch ${INVENTREE_VERSION} --depth 1 ${INVENTREE_REPO} ${INVENTREE_SRC_DIR}
|
2021-03-31 12:20:32 +00:00
|
|
|
|
2021-04-01 09:44:13 +00:00
|
|
|
# Setup Python virtual environment
|
2021-04-01 10:11:59 +00:00
|
|
|
RUN python3 -m venv ${INVENTREE_VENV}
|
2021-04-01 09:44:13 +00:00
|
|
|
|
|
|
|
# Install required PIP packages (into the virtual environment!)
|
2021-04-01 10:11:59 +00:00
|
|
|
RUN source ${INVENTREE_VENV}/bin/activate && pip install --upgrade pip setuptools wheel
|
|
|
|
RUN source ${INVENTREE_VENV}/bin/activate && pip install --no-cache-dir -U invoke
|
|
|
|
RUN source ${INVENTREE_VENV}/bin/activate && pip install --no-cache-dir -U psycopg2 mysqlclient pgcli mariadb
|
|
|
|
RUN source ${INVENTREE_VENV}/bin/activate && pip install --no-cache-dir -U gunicorn
|
2021-03-31 11:45:42 +00:00
|
|
|
|
|
|
|
# Install InvenTree packages
|
2021-04-01 10:11:59 +00:00
|
|
|
RUN source ${INVENTREE_VENV}/bin/activate && pip install --no-cache-dir -U -r ${INVENTREE_SRC_DIR}/requirements.txt
|
2021-03-31 11:45:42 +00:00
|
|
|
|
|
|
|
# Install supervisor
|
2021-03-31 12:27:01 +00:00
|
|
|
RUN apk add --no-cache supervisor
|
2021-03-31 11:45:42 +00:00
|
|
|
|
2021-03-31 11:47:41 +00:00
|
|
|
# Create required directories
|
2021-04-01 10:11:59 +00:00
|
|
|
RUN mkdir ${INVENTREE_HOME}/media ${INVENTREE_HOME}/static ${INVENTREE_HOME}/backup
|
2021-03-31 11:47:41 +00:00
|
|
|
|
2021-03-31 11:45:42 +00:00
|
|
|
# Copy supervisor file
|
2021-04-07 13:46:03 +00:00
|
|
|
COPY supervisord.conf ${INVENTREE_HOME}/supervisord.conf
|
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
|
|
|
|
|
|
|
# Copy startup script
|
2021-04-07 13:46:03 +00:00
|
|
|
COPY start.sh ${INVENTREE_HOME}/start.sh
|
2021-04-01 13:40:47 +00:00
|
|
|
|
|
|
|
RUN chmod 755 ${INVENTREE_HOME}/start.sh
|
|
|
|
|
|
|
|
# Let us begin
|
2021-04-07 13:46:03 +00:00
|
|
|
CMD ["bash", "./start.sh"]
|