diff --git a/.eslintignore b/.eslintignore index a45eaf5491e..1164f0cae98 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,4 +4,4 @@ services/web/client/source-output/ services/*node_modules/ services/dy-modeling/client/source/resource/ services/dy-modeling/client/source-output/ -services/dy-modeling/server/thrift/ +services/dy-modeling/server/source/thrift/ diff --git a/services/dy-modeling/_dockerfiles/build-npm/Dockerfile b/services/dy-modeling/_dockerfiles/build-npm/Dockerfile deleted file mode 100644 index b8e9b0a1631..00000000000 --- a/services/dy-modeling/_dockerfiles/build-npm/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM node:8.9.2 - -ENV NPM_CONFIG_LOGLEVEL warn - -# Web server variables -ARG web_app_port=8080 -ENV SIMCORE_WEB_HOSTNAME "0.0.0.0" -ENV SIMCORE_WEB_PORT $web_app_port -ENV SIMCORE_WEB_OUTDIR /home/node/source-output - -# S4L as CompServ variables -ARG s4l_ip="0.0.0.0" -ARG s4l_port_app="9095" -ARG s4l_port_mod="9096" -ENV CS_S4L_HOSTNAME $s4l_ip -ENV CS_S4L_PORT_APP $s4l_port_app -ENV CS_S4L_PORT_MOD $s4l_port_mod - -WORKDIR /home/node/ -VOLUME /home/node/source-output -VOLUME /home/node - -EXPOSE $web_app_port - -# TODO ensure npm@5.5.1 -ENTRYPOINT npm install -y \ - && echo node $(node --version) \ - && echo npm $(npm --version) \ - && npm install promise \ - && npm install nodemon -g \ - && nodemon -L start \ No newline at end of file diff --git a/services/dy-modeling/_dockerfiles/build-qx/Dockerfile b/services/dy-modeling/_dockerfiles/build-qx/Dockerfile deleted file mode 100644 index e40e9bce259..00000000000 --- a/services/dy-modeling/_dockerfiles/build-qx/Dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -# Compilation stage ---- -FROM node:8.9.2 - -LABEL maintainer=pcrespov - -ENV NPM_CONFIG_LOGLEVEL warn - -WORKDIR /home/node/ -# https://www.npmjs.com/package/qxcompiler -RUN npm install qxcompiler - -# TODO: why to create again? not better taking entire client-qx?? -ENV PATH="/home/node/node_modules/.bin/:${PATH}" -#RUN qx create qxapp -I --qxpath /home/node/node_modules/qooxdoo-sdk/framework/ - -VOLUME /home/node/qxapp -WORKDIR /home/node/qxapp - - -ENTRYPOINT qx compile --watch diff --git a/services/dy-modeling/client/Dockerfile b/services/dy-modeling/client/Dockerfile new file mode 100644 index 00000000000..43a718e4a5b --- /dev/null +++ b/services/dy-modeling/client/Dockerfile @@ -0,0 +1,25 @@ +FROM node:8.9.2 AS common +ENV NPM_CONFIG_LOGLEVEL warn +# + /home/node/ +# + app/source-output/ +# + app/source/ +# + app/*.json + +WORKDIR /home/node/ +RUN npm install qxcompiler + +ENV PATH="/home/node/node_modules/.bin/:${PATH}" + +WORKDIR /home/node/qxapp + +#-----------------Development----------------------- +FROM common as development + +CMD ["qx", "compile", "--watch"] + +#-----------------Production---------------------- +FROM common AS production + +COPY source /home/node/qxapp/source +COPY *.json ./ +RUN qx compile --target=build \ No newline at end of file diff --git a/services/dy-modeling/docker-compose.debug.yml b/services/dy-modeling/docker-compose.debug.yml new file mode 100644 index 00000000000..636e4c8985b --- /dev/null +++ b/services/dy-modeling/docker-compose.debug.yml @@ -0,0 +1,18 @@ +# USAGE: docker-compose -f docker-compose.yml -f docker-compose.debug.yml ... +version: '3.4' +services: + client: + build: + target: development + image: client-dev + volumes: + - './client:/home/node/qxapp' + server: + build: + target: development + image: server-dev + ports: + - '8080:9090' + volumes: + - './server/source:/home/node/source' + - './client/source-output:/home/node/source-output' \ No newline at end of file diff --git a/services/dy-modeling/docker-compose.dev.yml b/services/dy-modeling/docker-compose.dev.yml deleted file mode 100644 index 8fa7164f667..00000000000 --- a/services/dy-modeling/docker-compose.dev.yml +++ /dev/null @@ -1,25 +0,0 @@ -version: '3' -services: - build-qx: - build: - context: . - dockerfile: _dockerfiles/build-qx/Dockerfile - working_dir: /home/node/qxapp - volumes: - - './client:/home/node/qxapp' - nodeexpress: - build: - context: . - dockerfile: _dockerfiles/build-npm/Dockerfile - args: - web_app_port: 9090 - s4l_ip: "172.16.9.89" - s4l_port_app: 9095 - s4l_port_mod: 9096 - ports: - - '8080:9090' - volumes: - - './server:/home/node' - - './client/source-output:/home/node/source-output' - depends_on: - - build-qx \ No newline at end of file diff --git a/services/dy-modeling/docker-compose.yml b/services/dy-modeling/docker-compose.yml index 63c1a2bae35..91bfa6687e8 100644 --- a/services/dy-modeling/docker-compose.yml +++ b/services/dy-modeling/docker-compose.yml @@ -1,13 +1,21 @@ -version: '3' +version: '3.4' services: - qxapp: + client: build: - context: . - dockerfile: _dockerfiles/qxapp/node/Dockerfile + context: client + target: production + image: client-prod + server: + build: + context: server args: web_app_port: 9090 s4l_ip: "172.16.9.89" s4l_port_app: 9095 s4l_port_mod: 9096 + target: production + image: server-prod ports: - '8080:9090' + depends_on: + - client diff --git a/services/dy-modeling/_dockerfiles/qxapp/node/Dockerfile b/services/dy-modeling/server/Dockerfile similarity index 50% rename from services/dy-modeling/_dockerfiles/qxapp/node/Dockerfile rename to services/dy-modeling/server/Dockerfile index 23115c08bd8..d9da8d6fe5b 100644 --- a/services/dy-modeling/_dockerfiles/qxapp/node/Dockerfile +++ b/services/dy-modeling/server/Dockerfile @@ -1,35 +1,16 @@ -# Compilation stage ---- -FROM node:8.9.2 - -LABEL maintainer=pcrespov +FROM node:8.9.2 AS common ENV NPM_CONFIG_LOGLEVEL warn -WORKDIR /home/node/ -# https://www.npmjs.com/package/qxcompiler -RUN npm install qxcompiler - -# TODO: why to create again? not better taking entire client?? -ENV PATH="/home/node/node_modules/.bin/:${PATH}" -#RUN qx create qxapp -I --qxpath /home/node/node_modules/qooxdoo-sdk/framework/ - -WORKDIR /home/node/qxapp -COPY client/source source -COPY client/*.json ./ -RUN qx compile - - -# Deployment stage ----- -FROM node:8.9.2 - # Web server variables ARG web_app_port=8080 ENV SIMCORE_WEB_HOSTNAME "0.0.0.0" ENV SIMCORE_WEB_PORT $web_app_port ENV SIMCORE_WEB_OUTDIR /home/node/source-output +EXPOSE $web_app_port LABEL simcore.service.settings='[{"name": "ports", "type": "int", "value": 9090}, {"name": "constraints", "type": "string", "value": ["node.platform.os == linux"]}, {"name": "env", "type": "string", "value": ["CS_S4L_HOSTNAME=xrpc-worker_%service_uuid%"]}]' -# S4L as CompServ variables +# S4L host and ports ARG s4l_ip="0.0.0.0" ARG s4l_port_app="9095" ARG s4l_port_mod="9096" @@ -37,16 +18,25 @@ ENV CS_S4L_HOSTNAME $s4l_ip ENV CS_S4L_PORT_APP $s4l_port_app ENV CS_S4L_PORT_MOD $s4l_port_mod +# + /home/node/ json files +# + source-output/ client source files +# + source/ server source files WORKDIR /home/node/ -COPY --from=0 /home/node/qxapp/source-output source-output -COPY server . +COPY package.json /home/node/package.json +VOLUME /home/node/source-output +#--------------------Development------------------ +FROM common AS development -# TODO ensure npm@5.5.1 RUN npm install -y \ - && npm install promise \ - && echo node $(node --version) \ - && echo npm $(npm --version) + && npm install nodemon -g -EXPOSE $web_app_port +CMD ["nodemon", "-L", "start"] + +#---------------------Production------------------ +FROM common AS production +WORKDIR /home/node/ +COPY --from=client-prod:latest /home/node/qxapp/build-output source-output +COPY source /home/node/source +RUN npm install -y -CMD ["npm", "start"] +ENTRYPOINT ["npm", "start"] \ No newline at end of file diff --git a/services/dy-modeling/server/package.json b/services/dy-modeling/server/package.json index 9d93e2afe32..461b84c3083 100644 --- a/services/dy-modeling/server/package.json +++ b/services/dy-modeling/server/package.json @@ -2,10 +2,10 @@ "name": "server-nex", "version": "1.0.0", "description": "boilerplate nodejs express server", - "main": "server.js", + "main": "source/server.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "start": "node server.js" + "start": "node source/server.js" }, "author": "", "license": "ISC", diff --git a/services/dy-modeling/server/server.js b/services/dy-modeling/server/source/server.js similarity index 100% rename from services/dy-modeling/server/server.js rename to services/dy-modeling/server/source/server.js diff --git a/services/dy-modeling/server/thrift/ApplicationJSNode/gen-nodejs/Application.js b/services/dy-modeling/server/source/thrift/ApplicationJSNode/gen-nodejs/Application.js similarity index 100% rename from services/dy-modeling/server/thrift/ApplicationJSNode/gen-nodejs/Application.js rename to services/dy-modeling/server/source/thrift/ApplicationJSNode/gen-nodejs/Application.js diff --git a/services/dy-modeling/server/thrift/ApplicationJSNode/gen-nodejs/Logger.js b/services/dy-modeling/server/source/thrift/ApplicationJSNode/gen-nodejs/Logger.js similarity index 100% rename from services/dy-modeling/server/thrift/ApplicationJSNode/gen-nodejs/Logger.js rename to services/dy-modeling/server/source/thrift/ApplicationJSNode/gen-nodejs/Logger.js diff --git a/services/dy-modeling/server/thrift/ApplicationJSNode/gen-nodejs/ProcessFactory.js b/services/dy-modeling/server/source/thrift/ApplicationJSNode/gen-nodejs/ProcessFactory.js similarity index 100% rename from services/dy-modeling/server/thrift/ApplicationJSNode/gen-nodejs/ProcessFactory.js rename to services/dy-modeling/server/source/thrift/ApplicationJSNode/gen-nodejs/ProcessFactory.js diff --git a/services/dy-modeling/server/thrift/ApplicationJSNode/gen-nodejs/SharedService.js b/services/dy-modeling/server/source/thrift/ApplicationJSNode/gen-nodejs/SharedService.js similarity index 100% rename from services/dy-modeling/server/thrift/ApplicationJSNode/gen-nodejs/SharedService.js rename to services/dy-modeling/server/source/thrift/ApplicationJSNode/gen-nodejs/SharedService.js diff --git a/services/dy-modeling/server/thrift/ApplicationJSNode/gen-nodejs/application_types.js b/services/dy-modeling/server/source/thrift/ApplicationJSNode/gen-nodejs/application_types.js similarity index 100% rename from services/dy-modeling/server/thrift/ApplicationJSNode/gen-nodejs/application_types.js rename to services/dy-modeling/server/source/thrift/ApplicationJSNode/gen-nodejs/application_types.js diff --git a/services/dy-modeling/server/thrift/ModelerJSNode/gen-nodejs/Modeler.js b/services/dy-modeling/server/source/thrift/ModelerJSNode/gen-nodejs/Modeler.js similarity index 100% rename from services/dy-modeling/server/thrift/ModelerJSNode/gen-nodejs/Modeler.js rename to services/dy-modeling/server/source/thrift/ModelerJSNode/gen-nodejs/Modeler.js diff --git a/services/dy-modeling/server/thrift/ModelerJSNode/gen-nodejs/modeler_types.js b/services/dy-modeling/server/source/thrift/ModelerJSNode/gen-nodejs/modeler_types.js similarity index 100% rename from services/dy-modeling/server/thrift/ModelerJSNode/gen-nodejs/modeler_types.js rename to services/dy-modeling/server/source/thrift/ModelerJSNode/gen-nodejs/modeler_types.js