Commit 48f287a7 authored by TOUZE Francois's avatar TOUZE Francois
Browse files

development of dockerfiles

parent 4cf90829
#!/bin/env python3
from flask import Flask, render_template, jsonify
from flask import request
import os
import json
import urllib.parse
from pypspaclass import PyPspaClass
from pypspaplots import PyPspaPlots
from flask_cors import CORS
app = Flask(__name__, template_folder='.')
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
curdir = os.getcwd()
print( "current directory => ", curdir)
pkgRoot = curdir.split('pspa')
print( "root directory => ", pkgRoot[0])
upath = os.path.join(pkgRoot[0],'workZone/')
wpath = os.path.join(pkgRoot[0],'pspa/softwares/')
@app.route('/api/importe', methods=['GET', 'POST'])
def importe():
u_bytes= str.encode( upath )
w_bytes= str.encode( wpath )
ptr= PyPspaClass( u_bytes, w_bytes )
x= request.json
print( "/api/importe => ", x['fileName'] )
x_bytes= str.encode( x['fileName'] )
s= ptr.read( x_bytes ).decode('utf-8')
response = {
'import': s
}
return jsonify(response)
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def catch_all(path):
"""Our entry point"""
return render_template("index.html")
if __name__ == "__main__":
app.run("0.0.0.0", port=5000, debug=True)
......@@ -10,8 +10,6 @@ from modules import pspacode
from modules import pspaplot
from flask_cors import CORS
app = Flask(__name__, template_folder='.')
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
......@@ -119,13 +117,7 @@ def plots():
x_bytes= str.encode( data )
ptr.settings( x_bytes )
data= os.path.join(upath,'simulator-plot.txt')
"""
data= os.path.join(pkgRoot[0],"workZone/raf.txt")
"""
with open(data) as f:
ofi= json.load(f)
......@@ -161,7 +153,6 @@ def settings():
}
return jsonify(response)
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def catch_all(path):
......
......@@ -37,6 +37,122 @@ def importe():
}
return jsonify(response)
@app.route('/api/simulate', methods=['GET', 'POST'])
def simulate():
x= request.json
#print( "x => ", x["machine"])
#print( "y => ", x["simulations"])
#print( "z => ", x["projectName"])
u_bytes= str.encode( upath )
w_bytes= str.encode( wpath )
ptr= PyPspaClass( u_bytes, w_bytes )
data= json.dumps(x, ensure_ascii=False)
x_bytes= str.encode( data )
status= ptr.execute( x_bytes )
#print( "/api/simulate:: status => ", status )
s= "failure"
if (status): s= "success"
response = {
'status': s
}
return jsonify(response)
@app.route('/api/console', methods=['GET', 'POST'])
def console():
print( "api/console => ", request.full_path)
""" x is the list after splitting by the separator 'ids='
"""
x = request.full_path.split("ids=")
""" y is the list after splitting the 2nd item by the separator ','
"""
y = x[1].split(",")
#print( "api/pourVoir y => ", type(y), len(y))
#print( "api/pourVoir y => ", y)
z= []
if len(y[0]) > 0:
for item in y:
d={"id":urllib.parse.unquote( item )}
ids= urllib.parse.unquote( item ).split()
out= ids[0]+"-output.txt"
fname= os.path.join(upath,out)
if os.path.exists( fname ):
fp= open(fname).read()
d["output"]= fp
d["status"]= "loaded"
else:
d["output"]= "unknown result"
d["status"]= "not loaded"
z.append(d)
response = {
'results': z
}
return jsonify(response)
@app.route('/api/plots', methods=['GET', 'POST'])
def plots():
x= request.json
"""
x1= x['plotSimulation']
print( "/api/plots Ids=> ", x1, type(x1), len(x1) )
x2= x['plotItem']
print( "/api/plots item=> ", x2, type(x2) )
"""
up_bytes= str.encode( upath )
ptr= PyPspaPlots( up_bytes )
data= json.dumps(x, ensure_ascii=False)
x_bytes= str.encode( data )
ptr.settings( x_bytes )
data= os.path.join(upath,'simulator-plot.txt')
with open(data) as f:
ofi= json.load(f)
response = {
'chartConfig': ofi
}
return jsonify(response)
@app.route('/api/settings', methods=['GET', 'POST'])
def settings():
x= request.json
ids= x['selectedIds']
print( "/api/settings Ids=> ", ids, type(ids), len(ids) )
z= []
for id in ids:
d={"id": id}
out= id + "-plot.txt"
fname= os.path.join(upath,out)
if os.path.exists( fname ):
d['status']= 'found'
data= json.load( open(fname) )
d['software']= data['software']
d['action']= data['action']
else:
d['status']= 'not found'
z.append(d)
response = {
'parameters': z
}
return jsonify(response)
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def catch_all(path):
......
#!/bin/env python3
from flask import Flask, render_template, jsonify
from flask import request
import os
import json
import urllib.parse
from modules import pspacode
from modules import pspaplot
from flask_cors import CORS
app = Flask(__name__, template_folder='.')
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
curdir = os.getcwd()
print( "current directory => ", curdir)
pkgRoot = curdir.split('pspa.git')
print( "root directory => ", pkgRoot[0])
upath = os.path.join(pkgRoot[0],'workZone/')
wpath = os.path.join(pkgRoot[0],'pspa.git/softwares/')
@app.route('/api/importe', methods=['GET', 'POST'])
def importe():
u_bytes= str.encode( upath )
w_bytes= str.encode( wpath )
ptr= pspacode.Pypspa( u_bytes, w_bytes )
x= request.json
print( "/api/importe => ", x['fileName'] )
x_bytes= str.encode( x['fileName'] )
s= ptr.read( x_bytes ).decode('utf-8')
response = {
'import': s
}
return jsonify(response)
@app.route('/api/simulate', methods=['GET', 'POST'])
def simulate():
x= request.json
#print( "x => ", x["machine"])
#print( "y => ", x["simulations"])
#print( "z => ", x["projectName"])
u_bytes= str.encode( upath )
w_bytes= str.encode( wpath )
ptr= pspacode.Pypspa( u_bytes, w_bytes )
data= json.dumps(x, ensure_ascii=False)
x_bytes= str.encode( data )
status= ptr.execute( x_bytes )
#print( "/api/simulate:: status => ", status )
s= "failure"
if (status): s= "success"
response = {
'status': s
}
return jsonify(response)
@app.route('/api/console', methods=['GET', 'POST'])
def console():
print( "api/console => ", request.full_path)
""" x is the list after splitting by the separator 'ids='
"""
x = request.full_path.split("ids=")
""" y is the list after splitting the 2nd item by the separator ','
"""
y = x[1].split(",")
#print( "api/pourVoir y => ", type(y), len(y))
#print( "api/pourVoir y => ", y)
z= []
if len(y[0]) > 0:
for item in y:
d={"id":urllib.parse.unquote( item )}
ids= urllib.parse.unquote( item ).split()
out= ids[0]+"-output.txt"
fname= os.path.join(upath,out)
if os.path.exists( fname ):
fp= open(fname).read()
d["output"]= fp
d["status"]= "loaded"
else:
d["output"]= "unknown result"
d["status"]= "not loaded"
z.append(d)
response = {
'results': z
}
return jsonify(response)
@app.route('/api/plots', methods=['GET', 'POST'])
def plots():
x= request.json
"""
x1= x['plotSimulation']
print( "/api/plots Ids=> ", x1, type(x1), len(x1) )
x2= x['plotItem']
print( "/api/plots item=> ", x2, type(x2) )
"""
up_bytes= str.encode( upath )
ptr= pspaplot.Pypspaplot( up_bytes )
data= json.dumps(x, ensure_ascii=False)
x_bytes= str.encode( data )
ptr.settings( x_bytes )
data= os.path.join(upath,'simulator-plot.txt')
"""
data= os.path.join(pkgRoot[0],"workZone/raf.txt")
"""
with open(data) as f:
ofi= json.load(f)
response = {
'chartConfig': ofi
}
return jsonify(response)
@app.route('/api/settings', methods=['GET', 'POST'])
def settings():
x= request.json
ids= x['selectedIds']
print( "/api/settings Ids=> ", ids, type(ids), len(ids) )
z= []
for id in ids:
d={"id": id}
out= id + "-plot.txt"
fname= os.path.join(upath,out)
if os.path.exists( fname ):
d['status']= 'found'
data= json.load( open(fname) )
d['software']= data['software']
d['action']= data['action']
else:
d['status']= 'not found'
z.append(d)
response = {
'parameters': z
}
return jsonify(response)
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def catch_all(path):
"""Our entry point"""
return render_template("index.html")
if __name__ == "__main__":
app.run("0.0.0.0", port=5000, debug=True)
FROM utilitybox:latest
SHELL ["/bin/bash", "-c"]
ENV CMT_VERSION v1r20p20090520
ENV CMT_PKG CMTv1r20p20090520Linux-i686.tar.gz
RUN cd /usr/local \
&& wget http://www.cmtsite.net/$CMT_VERSION/$CMT_PKG \
&& tar -xf $CMT_PKG \
&& rm $CMT_PKG \
&& cd CMT/$CMT_VERSION/mgr \
&& ./INSTALL \
&& source setup.sh
ENV CMTROOT /usr/local/CMT/v1r20p20090520
ENV CMT $CMTROOT/Linux-x86_64/cmt
ENV CMTPATH /home/pspa/backend
# Install backend package
RUN cd /home \
&& /bin/ln -s /usr/bin/make /usr/bin/gmake \
&& git clone https://gitlab.in2p3.fr/PSPA/PSPA.git pspa \
&& cd pspa/backend/pspa/v0/cmt \
&& $CMT config \
&& source setup.sh \
&& $CMT make
RUN cd /home
COPY madx-linux64-gnu /home/pspa/softwares/madx64
COPY astra-linux-x86_64 /home/pspa/softwares/astra
COPY generator-linux-x86_64 /home/pspa/softwares/generator
COPY defns.rpn /home/pspa/softwares/defns.rpn
COPY elegant-linux-x86_64 /home/pspa/softwares/elegant
COPY sddsprintout-linux-x86_64 /home/pspa/softwares/sddsprintout
COPY betabatchbin /home/pspa/softwares/betabatchbin
ENV RPN_DEFNS /home/pspa/softwares/defns.rpn
ENV LIBPATH /usr/lib/x86_64-linux-gnu
RUN apt-get install -y libgsl23 \
&& ln $LIBPATH/libgsl.so.23 $LIBPATH/libgsl.so.0 \
&& apt-get install -y libgslcblas0 \
&& apt-get install -y liblapack3 \
&& apt-get install -y libgfortran3
RUN apt-get install -y libxss1 \
&& apt-get install -y libxft2 \
&& ln $LIBPATH/libpng16.so.16 $LIBPATH/libpng12.so.0
FROM utilitybox:latest
ENV CMT_VERSION v1r20p20090520
ENV CMT_PKG CMTv1r20p20090520Linux-i686.tar.gz
SHELL ["/bin/bash", "-c"]
RUN cd /usr/local \
&& wget http://www.cmtsite.net/$CMT_VERSION/$CMT_PKG \
&& tar -xf $CMT_PKG \
&& rm $CMT_PKG \
&& cd CMT/$CMT_VERSION/mgr \
&& ./INSTALL \
&& source setup.sh
FROM cmtbox:latest
ENV CMTROOT /usr/local/CMT/v1r20p20090520
ENV CMT $CMTROOT/Linux-x86_64/cmt
ENV CMTPATH /home/pspa/backend
ENV PYTHONPATH /home/pspa/controller/cython-cpp
FROM backbox:latest
SHELL ["/bin/bash", "-c"]
# Install backend package
RUN cd home \
&& /bin/ln -s /usr/bin/make /usr/bin/gmake \
&& git clone https://gitlab.in2p3.fr/PSPA/PSPA.git pspa \
&& cd pspa/backend/pspa/v0/cmt \
&& $CMT config \
&& source setup.sh \
&& $CMT make
ENV PYTHONPATH /home/pspa/controller/cython-cpp
# Install controller package
RUN cd home/pspa/controller \
RUN cd /home/pspa/controller \
&& apt-get install -y python3-dev python3-pip \
&& pip3 install -r requirements.txt \
&& cd cython-cpp \
&& python3 pspaclass.py build_ext --inplace \
&& python3 pspaplots.py build_ext --inplace
# Install frontend package
RUN cd home/pspa/frontend \
COPY package.json /home/pspa/frontend/package.json
WORKDIR /home/pspa/frontend
RUN cd /home/pspa/frontend \
&& apt-get install -y curl sudo \
&& curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - \
&& apt-get install -y nodejs \
&& npm install
\ No newline at end of file
&& npm install
EXPOSE 8080
CMD ["npm","run","dev"]
......@@ -5,7 +5,7 @@
"author": "Patrick BOUZANQUET <patrick.bouzanquet@cgi.com>",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"dev": "webpack-dev-server --host 0.0.0.0 --port 8080 --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"unit": "jest --config test/unit/jest.conf.js --coverage",
"test": "npm run unit",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment