Update dockerfile to allow downloading against a specific git tag

This commit is contained in:
Oliver 2021-08-12 22:01:14 +10:00
parent fcff8d4825
commit 31bb7734ce

View File

@ -4,6 +4,9 @@ FROM alpine:3.13 as base
ARG repository="https://github.com/inventree/InvenTree.git" ARG repository="https://github.com/inventree/InvenTree.git"
ARG branch="master" ARG branch="master"
# Optionally specify a particular tag to checkout
ARG tag=""
ENV PYTHONUNBUFFERED 1 ENV PYTHONUNBUFFERED 1
# InvenTree key settings # InvenTree key settings
@ -12,8 +15,9 @@ ENV PYTHONUNBUFFERED 1
ENV INVENTREE_HOME="/home/inventree" ENV INVENTREE_HOME="/home/inventree"
# GitHub settings # GitHub settings
ENV INVENTREE_REPO="${repository}" ENV INVENTREE_GIT_REPO="${repository}"
ENV INVENTREE_BRANCH="${branch}" ENV INVENTREE_GIT_BRANCH="${branch}"
ENV INVENTREE_GIT_TAG="${tag}"
ENV INVENTREE_LOG_LEVEL="INFO" ENV INVENTREE_LOG_LEVEL="INFO"
ENV INVENTREE_DOCKER="true" ENV INVENTREE_DOCKER="true"
@ -80,8 +84,12 @@ RUN pip install --no-cache-dir -U gunicorn
FROM base as production FROM base as production
# Clone source code # Clone source code
RUN echo "Downloading InvenTree from ${INVENTREE_REPO}" RUN echo "Downloading InvenTree from ${INVENTREE_GIT_REPO}"
RUN git clone --branch ${INVENTREE_BRANCH} --depth 1 ${INVENTREE_REPO} ${INVENTREE_HOME}
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
# Install InvenTree packages # Install InvenTree packages
RUN pip install --no-cache-dir -U -r ${INVENTREE_HOME}/requirements.txt RUN pip install --no-cache-dir -U -r ${INVENTREE_HOME}/requirements.txt