Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud functionality added #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dist-ssr
*.local
/.pnp
.pnp.js
.venv

# production
/build
Expand Down
16 changes: 16 additions & 0 deletions Dockerfile.client
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:20-alpine as build-step
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json package-lock.json tsconfig.json tsconfig.node.json vite.config.ts index.html .eslintrc.cjs ./
COPY ./src ./src
COPY ./public ./public
RUN npm install
RUN npm run build

# Build step #2: build an nginx container
FROM nginx:stable-alpine
COPY --from=build-step /app/dist /usr/share/nginx/html
COPY deployment/nginx.default.conf /etc/nginx/conf.d/default.conf

# Start Nginx when the container runs
CMD ["nginx", "-g", "daemon off;"]
11 changes: 11 additions & 0 deletions Dockerfile.server
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.11 as server-step

COPY ./data ./data
WORKDIR /app

COPY requirements.txt api/app.py api/config.yaml ./
RUN pip install -r ./requirements.txt
ENV FLASK_ENV production
EXPOSE 5000
CMD ["gunicorn", "-b", ":5000", "app:app"]

7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ This repository houses the Materials Cloud interactive phonons visualizer React
- install backend dependencies with `pip install -r requirements.txt`
- launch the backend with `python api/app.py`
- launch the app with `npm start`


#### Running on docker
The project contains client and server stacks to containerize the application
You can run the full stack application on a Docker install machine typing
`docker compose up `
on the terminal. You can reach to content via localhost:8080 port.
2 changes: 2 additions & 0 deletions api/.flaskenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FLASK_APP=app.py
FLASK_ENV=development
23 changes: 23 additions & 0 deletions deployment/nginx.default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# nginx configuration for Docker

server {
listen 80;
server_name localhost;

root /usr/share/nginx/html;
index index.html;
error_page 500 502 503 504 /50x.html;

location / {
try_files $uri $uri/ =404;
add_header Cache-Control "no-cache";
}

location /static {
expires 1y;
add_header Cache-Control "public";
}
location /app {
proxy_pass http://app:5000;
}
}
15 changes: 15 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
services:
app:
build:
context: .
dockerfile: Dockerfile.server
image: phonon-visualizer-server
ports:
- "5000:5000"
client:
build:
context: .
dockerfile: Dockerfile.client
image: phonon-visualizer-client
ports:
- "8080:80"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Flask==3.0.3
Flask-Cors==4.0.1
PyYAML==6.0.1
gunicorn==22.0.0