From ab57fd3b764a3e0411c81919a175daecb6627afc Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Wed, 31 Mar 2021 22:45:42 +1100 Subject: [PATCH] Build docker image --- .github/workflows/docker.yaml | 16 ++++++++++++ docker/Dockerfile | 46 +++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/docker.yaml create mode 100644 docker/Dockerfile diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000000..448babcc31 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,16 @@ +# Test that the docker file builds correctly + +name: Docker + +on: ["push", "pull_request"] + +jobs: + + docker: + runs-on: ubtun-latest + + steps: + - uses: actions/checkout@v2 + - name: Build Docker Image + run: docker build . --file docker/Dockerfile --tag inventree-:$(date +%s) + \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000000..da0ddebf39 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,46 @@ +FROM python:alpine as production + +# Configuration params +ARG INVENTREE_REPO="https://github.com/inventree/InvenTree.git" +ARG INVENTREE_VERSION="master" +ARG INVENTREE_HOME="/home/inventree" + +ENV PYTHONUNBUFFERED 1 + +# InvenTree paths +ENV INVENTREE_SRC_DIR="$INVENTREE_HOME/src" +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" + +RUN echo "Installing InvenTree '${INVENTREE_VERSION}' from ${INVENTREE_REPO}" + +# Create user account +RUN useradd -ms /bin/bash inventree +USER inventree +WORKDIR /home/inventree + +# Clone source code +RUN git clone --branch $INVENTREE_VERSION --depth 1 ${INVENTREE_REPO} ${INVENTREE_SRC_DIR} + +# Install required system packages +RUN apk add --no-cache postgresql-contrib postgresql-dev libpq-dev +RUN apk add --no-cache libmysqlclient-dev + +# Install required PIP packages +RUN python -m venv $INVENTREE_VENV && pip install --upgrade pip setuptools wheel +RUN python -m venv $INVENTREE_VENV && pip install --no-cache-dir -U invoke +RUN python -m venv $INVENTREE_VENV && pip install --no-cache-dir -U psycopg2 mysqlclient pgcli mariadb + +# Install InvenTree packages +RUN python -m venv $INVENTREE_VENV && pip install --no-cache-dir -U -r $INVENTREE_SRC_DIR/requirements.txt + +# Install supervisor +RUN apt add --no-cache supervisor + +# Copy supervisor file +COPY deploy/inventree.conf /etc/supervisor/conf.d/inventree.conf + +RUN sudo service supervisor start