From 09a451c55fa4a96e745be1ccbf1be444a0ac9a2c Mon Sep 17 00:00:00 2001 From: thatmattlove Date: Sun, 3 Mar 2024 00:21:43 -0500 Subject: [PATCH] add docker & docker compose support --- .dockerignore | 43 +++++++++++++++++++++++++++++++++++++++++++ .gitignore | 1 + Dockerfile | 30 ++++++++++++++++++++++++++++++ compose.yaml | 19 +++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 compose.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b00d3d7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,43 @@ +hyperglass/hyperglass/static +node_modules +.DS_Store +hyperglass/ui/.env* +hyperglass.json +custom.*[js, html] +.next +out/ +fonts/ +__pycache__ +.python-version +.venv +.mypy_cache +.pytest_cache +.ruff_cache +*.so +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +*.rdb +*.py[cod] +.ipynb* diff --git a/.gitignore b/.gitignore index 4afa7c3..aa88379 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Project hyperglass/hyperglass/static TODO* +.env test.py .DS_Store diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1fe9678 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM python:3.12.2-bookworm as base +WORKDIR /opt/hyperglass +ENV HYPERGLASS_APP_PATH=/etc/hyperglass +ENV HYPERGLASS_HOST=0.0.0.0 +ENV HYPERGLASS_PORT=8001 +ENV HYPERGLASS_DEBUG=false +ENV HYPERGLASS_DEV_MODE=false +ENV HYPERGLASS_REDIS_HOST=redis +ENV HYPEGLASS_DISABLE_UI=true + +# RUN curl -sSf https://rye-up.com/get | RYE_INSTALL_OPTION="--yes" bash +# ENV PATH="${PATH}:$HOME/.rye/shims" +COPY . . +# RUN $HOME/.rye/shims/rye sync +# RUN . ./.venv/bin/activate +RUN pip3 install . + + +FROM base as ui +WORKDIR /opt/hyperglass/hyperglass/ui +RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - +RUN apt-get install -y nodejs +RUN npm install -g pnpm +RUN pnpm install -P + +FROM ui as hyperglass +WORKDIR /opt/hyperglass + +EXPOSE ${HYPERGLASS_PORT} +CMD ["python3", "-m", "hyperglass.console", "start"] diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..5efe4e9 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,19 @@ +services: + redis: + image: "redis:alpine" + hyperglass: + depends_on: + - redis + environment: + - HYPERGLASS_APP_PATH=/etc/hyperglass + - HYPERGLASS_HOST=${HYPERGLASS_HOST-0.0.0.0} + - HYPERGLASS_PORT=${HYPERGLASS_PORT-8001} + - HYPERGLASS_DEBUG=${HYPERGLASS_DEBUG-false} + - HYPERGLASS_DEV_MODE=${HYPERGLASS_DEV_MODE-false} + - HYPERGLASS_REDIS_HOST=${HYPERGLASS_REDIS_HOST-redis} + - HYPEGLASS_DISABLE_UI=${HYPEGLASS_DISABLE_UI-false} + build: . + ports: + - "${HYPERGLASS_PORT-8001}:${HYPERGLASS_PORT-8001}" + volumes: + - ${HYPERGLASS_APP_PATH-/etc/hyperglass}:/etc/hyperglass