johnbradley commited on
Commit
aa18684
1 Parent(s): a18c912

Add Dockerfile to deploy Andromeda in huggingface

Browse files

Adds a multi-phase build Dockerfile that builds static html
then sets up Andromeda python to run. The app.py script
adds logic to andromeda to serve the static html instead of
expecting nginx to serve it. This is to be compatible
with huggingface spaces.

Files changed (4) hide show
  1. .gitmodules +3 -0
  2. Andromeda +1 -0
  3. Dockerfile +24 -0
  4. app.py +14 -0
.gitmodules ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [submodule "Andromeda"]
2
+ path = Andromeda
3
+ url = https://github.com/Imageomics/Andromeda
Andromeda ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit b3ec75c0f0022e3054547d94b4dc72a360b707c9
Dockerfile ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:18.16.0 as builder
2
+ WORKDIR /src
3
+ COPY ./Andromeda/andromeda-ui/package.json ./
4
+ RUN npm install
5
+ COPY ./Andromeda/andromeda-ui/. .
6
+ RUN npm run build
7
+
8
+ FROM python:3.11
9
+
10
+ COPY ./Andromeda/andromeda/requirements.txt /tmp/requirements.txt
11
+ WORKDIR /tmp
12
+ RUN pip3 install gunicorn && pip3 install -r requirements.txt
13
+
14
+ COPY ./Andromeda/andromeda/. /api
15
+ COPY ./app.py /api/app.py
16
+ COPY --from=builder /src/out /api/static
17
+ WORKDIR /api
18
+
19
+ # fix since root home directory is read only in HF
20
+ RUN mkdir /tmp/home
21
+ RUN chmod a+w /tmp/home
22
+ ENV XDG_DATA_HOME=/tmp/home
23
+
24
+ CMD python app.py
app.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Adds logic to serve static html for running within huggingface
2
+ from flask import send_from_directory, request
3
+ from main import app
4
+
5
+ @app.errorhandler(404)
6
+ def page_not_found(e):
7
+ path = request.path.lstrip('/')
8
+ if path == '':
9
+ path = 'index.html'
10
+ print(path)
11
+ return send_from_directory('static', path)
12
+
13
+ if __name__ == '__main__':
14
+ app.run(host="0.0.0.0", port=7860)