Skip to content

Commit

Permalink
Make matcher dir the build context for docker images
Browse files Browse the repository at this point in the history
- Refactor frontend imports as result, also to facilitate pytest testing
- Will facilitate importing shared files (e.g. scripts) to both backend and frontend
  • Loading branch information
hooveran committed Oct 31, 2023
1 parent 278dfd2 commit 439396d
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 29 deletions.
4 changes: 2 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ RUN apt-get update -y && apt-get install libxrender1 -y

WORKDIR /opt

COPY environment.yml requirements.txt ./backend/
COPY ./backend/environment.yml ./backend/requirements.txt ./backend/

RUN conda env create -f ./backend/environment.yml

COPY . ./backend
COPY ./backend ./backend

EXPOSE 8001

Expand Down
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ services:
- matcher-network
backend:
build:
context: ./backend
context: .
dockerfile: ./backend/Dockerfile
ports:
- 8001:8001
environment:
Expand All @@ -29,7 +30,8 @@ services:
- matcher-network
frontend:
build:
context: ./frontend
context: .
dockerfile: ./frontend/Dockerfile
ports:
- 8000:8000
environment:
Expand Down
7 changes: 7 additions & 0 deletions frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.env
.env.example
Makefile
__pycache__
assets
requirements.dev.txt
venv
16 changes: 6 additions & 10 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ FROM condaforge/miniforge3

WORKDIR /opt

COPY environment.yml requirements.txt ./
COPY ./frontend/environment.yml ./frontend/requirements.txt ./frontend/

RUN conda env create -f /opt/environment.yml
RUN conda env create -f ./frontend/environment.yml

COPY frontend_api.py monkey.py config.py dash_app.py ./
COPY examples/ ./examples/
COPY css/ ./css/
COPY js/* ./js/
COPY ketcher/ ./ketcher/
COPY pages/ ./pages/
COPY templates/ ./templates/
COPY ./frontend ./frontend

EXPOSE 8000

ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "matcher-frontend", "gunicorn", "--worker-class", "gevent", "--workers", "2", "--bind", "0.0.0.0:8000", "monkey:server"]
ENV PYTHONPATH=/opt

ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "matcher-frontend", "gunicorn", "--worker-class", "gevent", "--workers", "2", "--bind", "0.0.0.0:8000", "frontend.monkey:server"]
Empty file added frontend/__init__.py
Empty file.
6 changes: 3 additions & 3 deletions frontend/dash_app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from dash import Dash

from frontend_api import app as Flask_app
from frontend.frontend_api import app as Flask_app

# imports callbacks required to register callbacks with the app
import pages.rep.callbacks as rep_callbacks # noqa
import pages.snap.callbacks as snap_callbacks # noqa
import frontend.pages.rep.callbacks as rep_callbacks # noqa
import frontend.pages.snap.callbacks as snap_callbacks # noqa


app_dash = Dash(
Expand Down
2 changes: 1 addition & 1 deletion frontend/monkey.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from gevent import monkey
monkey.patch_all()

from dash_app import server # noqa
from frontend.dash_app import server # noqa
4 changes: 2 additions & 2 deletions frontend/pages/common/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import pandas as pd
import plotly.graph_objects as go

from config import backend_root
from pages.common.pairplot import (
from frontend.config import backend_root
from frontend.pages.common.pairplot import (
get_individual_transforms_df,
get_group_by_fragment_df,
get_group_by_fragment_table,
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/common/pairplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pandas as pd
import urllib
import logging
from config import external_backend_root
from frontend.config import external_backend_root

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand Down
6 changes: 3 additions & 3 deletions frontend/pages/rep/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from dash import callback, clientside_callback
from dash.dependencies import Input, Output, State, ALL

from config import backend_root
from pages.rep.constants import create_id
from pages.common.callbacks import (instantiate_output_elements, aggregate_statistics_by_rule, selected_point_to_pair_tables, update_graph)
from frontend.config import backend_root
from frontend.pages.rep.constants import create_id
from frontend.pages.common.callbacks import (instantiate_output_elements, aggregate_statistics_by_rule, selected_point_to_pair_tables, update_graph)

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/rep/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from dash import dcc, html

import logging
from pages.rep.constants import DASH_PAGE_PREFIX, create_id
from frontend.pages.rep.constants import DASH_PAGE_PREFIX, create_id

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand Down
6 changes: 3 additions & 3 deletions frontend/pages/snap/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import pandas as pd
import requests

from pages.common.callbacks import (run_persistent_query, instantiate_output_elements, aggregate_statistics_by_rule, selected_point_to_pair_tables, update_graph)
from config import backend_root, external_frontend_root
from pages.snap.constants import create_id
from frontend.pages.common.callbacks import (run_persistent_query, instantiate_output_elements, aggregate_statistics_by_rule, selected_point_to_pair_tables, update_graph)
from frontend.config import backend_root, external_frontend_root
from frontend.pages.snap.constants import create_id

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/snap/layout.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dash
from dash import dcc, html

from pages.snap.constants import DASH_PAGE_PREFIX
from frontend.pages.snap.constants import DASH_PAGE_PREFIX

dash.register_page(__name__, path=f'/{DASH_PAGE_PREFIX}/')

Expand Down

0 comments on commit 439396d

Please sign in to comment.