diff --git a/docker/dev/timesketch/Dockerfile b/docker/dev/timesketch/Dockerfile index a58223d75a..cf5341ff12 100644 --- a/docker/dev/timesketch/Dockerfile +++ b/docker/dev/timesketch/Dockerfile @@ -19,6 +19,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ python3-wheel \ python3-setuptools \ python3-psycopg2 \ + python3-venv \ tzdata \ && rm -rf /var/lib/apt/lists/* @@ -64,13 +65,18 @@ RUN if [ -n "${PYTHON_PIP_CONF}" ]; then \ # Install Yarn for frontend development RUN npm install --global yarn -# Install dependencies for Timesketch -COPY ./requirements.txt /timesketch-requirements.txt -RUN pip3 install -r /timesketch-requirements.txt +# Install dependencies for Timesketch in a virtual environment +COPY ["./requirements.txt", "/timesketch-requirements.txt"] +COPY ["./test_requirements.txt", "/timesketch-test-requirements.txt"] +RUN python3 -m venv --upgrade-deps ~/.virtualenvs/timesketch \ + && . ~/.virtualenvs/timesketch/bin/activate \ + && pip install --no-cache-dir \ + -r /timesketch-requirements.txt \ + -r /timesketch-test-requirements.txt \ + psycopg2-binary -# Install test dependencies for Timesketch -COPY ./test_requirements.txt /timesketch-test-requirements.txt -RUN pip3 install -r /timesketch-requirements.txt -r /timesketch-test-requirements.txt +# Update the PATH to include the virtual environment +ENV PATH="/root/.virtualenvs/timesketch/bin:${PATH}" # Copy the entrypoint script into the container COPY ["./docker/dev/timesketch/docker-entrypoint.sh", "/"] diff --git a/docker/dev/timesketch/docker-entrypoint.sh b/docker/dev/timesketch/docker-entrypoint.sh index 2792682cea..2af3122aec 100644 --- a/docker/dev/timesketch/docker-entrypoint.sh +++ b/docker/dev/timesketch/docker-entrypoint.sh @@ -17,12 +17,14 @@ function kill_other_processes() { exit 0 } +. "${HOME}/.virtualenvs/app/bin/activate" + # Run the container the default way if [[ "$1" = 'timesketch' ]]; then CONF_DIR="/etc/timesketch" # Install Timesketch in editable mode from volume - pip3 install -e /usr/local/src/timesketch/ + pip install -e /usr/local/src/timesketch/ # Add web user tsctl create-user --password "${TIMESKETCH_PASSWORD}" "${TIMESKETCH_USER}"