diff --git a/README.md b/README.md index 0f6c14d..71eb45a 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,12 @@ To start NOMAD you need to navigate to nomad-server folder and run docker-compose up -d ``` +To start after updating dependencies in any package.json file you have to build new Docker images by using command + +```bash +docker-compose up -d --build +``` + To stop use command ```console diff --git a/docker-compose.yaml b/docker-compose.yaml index a56dec0..489eb88 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,7 +9,7 @@ services: backend: build: ./nomad-rest-api env_file: - - ./env/backend.env + - ./envs/dev/backend.env ports: - '8080:8080' volumes: @@ -23,7 +23,7 @@ services: frontend: build: ./nomad-front-end env_file: - - ./env/frontend.env + - ./envs/dev/frontend.env ports: - '3003:3003' volumes: @@ -34,6 +34,8 @@ services: - backend client: + profiles: + - client build: ../nomad-spect-client volumes: - ../nomad-spect-client/src:/app/src @@ -42,7 +44,7 @@ services: - /mnt/c/Users/tl12/nomad-data-test/clientData/auto:/app/nmr-data/auto - /mnt/c/Users/tl12/nomad-data-test/clientData/manual:/app/nmr-data/manual env_file: - - ./env/client.env + - ./envs/dev/client.env depends_on: - backend diff --git a/envs/dev/backend-test.env b/envs/dev/backend-test.env new file mode 100644 index 0000000..013cafa --- /dev/null +++ b/envs/dev/backend-test.env @@ -0,0 +1,34 @@ +PORT=8080 +MONGODB_URL='mongodb://mongodb:27017/nomad' +HOST='0.0.0.0' +#Frontend host url +FRONT_HOST_URL='http://localhost:3003' + +#Password for automatically generated admin user +ADMIN_PASSWORD='foo' + +#JWT expiration time in seconds. Set to 10h for development +JWT_EXPIRATION=36000 + +#Secret word for generating JWT +JWT_SECRET='bar' + +EMAIL_SUFFIX='' + +#SMTP configuration +SMTP_HOST='' +SMTP_PORT=587 +SMTP_SECURE=false +SMTP_REQUIRE_TLS=true +SMTP_USER='' +SMTP_PASS='' +SMTP_SENDER='' + +#Set true if NOMAD submission is used +SUBMIT_ON=true + +#Set true if NOMAD datastore is used +DATASTORE_ON=true, +DATASTORE_PATH='/app/datastore' +#timeout for upload data route connection +DATA_UPLOAD_TIMEOUT=30000 diff --git a/envs/dev/backend.env b/envs/dev/backend.env new file mode 100644 index 0000000..be8d413 --- /dev/null +++ b/envs/dev/backend.env @@ -0,0 +1,35 @@ +NODE_ENV='dev' +PORT=8080 +MONGODB_URL='mongodb://mongodb:27017/nomad' +HOST='0.0.0.0' +#Frontend host url +FRONT_HOST_URL='http://localhost:3003' + +#Password for automatically generated admin user +ADMIN_PASSWORD='foo' + +#JWT expiration time in seconds. Set to 10h for development +JWT_EXPIRATION=36000 + +#Secret word for generating JWT +JWT_SECRET='bar' + +EMAIL_SUFFIX='' + +#SMTP configuration +SMTP_HOST='' +SMTP_PORT=587 +SMTP_SECURE=false +SMTP_REQUIRE_TLS=true +SMTP_USER='' +SMTP_PASS='' +SMTP_SENDER='' + +#Set true if NOMAD submission is used +SUBMIT_ON=true + +#Set true if NOMAD datastore is used +DATASTORE_ON=true, +DATASTORE_PATH='/app/datastore' +#timeout for upload data route connection +DATA_UPLOAD_TIMEOUT=30000 diff --git a/env-example/client.env b/envs/dev/client.env similarity index 100% rename from env-example/client.env rename to envs/dev/client.env diff --git a/env-example/frontend.env b/envs/dev/frontend.env similarity index 83% rename from env-example/frontend.env rename to envs/dev/frontend.env index 54f799b..4fad93f 100644 --- a/env-example/frontend.env +++ b/envs/dev/frontend.env @@ -1,4 +1,5 @@ VITE_API_URL=http://localhost:8080/api +VITE_SOCKETS_URL=http://localhost:8080 VITE_NMRIUM_URL=http://localhost:3000 #Set true if corresponding NOMAD modules are used diff --git a/env-example/backend-test.env b/envs/example/backend-test.env similarity index 100% rename from env-example/backend-test.env rename to envs/example/backend-test.env diff --git a/env-example/backend.env b/envs/example/backend.env similarity index 100% rename from env-example/backend.env rename to envs/example/backend.env diff --git a/envs/example/client.env b/envs/example/client.env new file mode 100644 index 0000000..50e6397 --- /dev/null +++ b/envs/example/client.env @@ -0,0 +1,6 @@ +INSTRUMENT_ID=60361c01a94fe37cd04dd7c3 +STATUS_PATH= /app/status_files/status.html +HISTORY_PATH=/app/status_files/status.html +SERVER_URL=http://backend:8080 +SUBMIT_PATH=/app/submit_files/ +UPLOAD_DELAY=10000 \ No newline at end of file diff --git a/envs/example/frontend.env b/envs/example/frontend.env new file mode 100644 index 0000000..cf2902b --- /dev/null +++ b/envs/example/frontend.env @@ -0,0 +1,7 @@ +VITE_API_URL=http://localhost:8080 +VITE_NMRIUM_URL=http://localhost:3000 + +#Set true if corresponding NOMAD modules are used +VITE_SUBMIT_ON=true +VITE_BATCH_SUBMIT_ON=true +VITE_DATASTORE_ON=true \ No newline at end of file diff --git a/nomad-front-end/src/socketConnection.js b/nomad-front-end/src/socketConnection.js index 991678b..f2c674f 100644 --- a/nomad-front-end/src/socketConnection.js +++ b/nomad-front-end/src/socketConnection.js @@ -1,5 +1,7 @@ import { io } from 'socket.io-client' -const socket = io(import.meta.env.PROD ? window.location.hostname : import.meta.env.VITE_API_URL) +const socket = io( + import.meta.env.PROD ? window.location.hostname : import.meta.env.VITE_SOCKETS_URL +) export default socket diff --git a/nomad-rest-api/Dockerfile b/nomad-rest-api/Dockerfile index 44a53c7..7ed3168 100644 --- a/nomad-rest-api/Dockerfile +++ b/nomad-rest-api/Dockerfile @@ -6,8 +6,6 @@ COPY package.json /app/ RUN npm install -COPY . . - EXPOSE 8080 -CMD ["npm", "run" , "dev-docker"] \ No newline at end of file +CMD ["npm", "run", "dev-docker"] diff --git a/nomad-rest-api/package.json b/nomad-rest-api/package.json index 5cd8a87..71e796e 100644 --- a/nomad-rest-api/package.json +++ b/nomad-rest-api/package.json @@ -5,12 +5,12 @@ "main": "server.js", "type": "module", "scripts": { - "test-once": "env-cmd -f ../env/backend-test.env vitest --run", + "test-once": "env-cmd -f ../envs/dev/backend-test.env vitest --run", "test-action": "vitest --run", - "test": "env-cmd -f ../env/backend-test.env vitest --reporter verbose", - "coverage": "env-cmd -f ../env/backend-test.env vitest run --coverage", - "start": "env-cmd -f ../env/api-no-docker.env node server.js", - "dev": "env-cmd -f ../env/api-no-docker.env nodemon server.js", + "test": "env-cmd -f ../envs/dev/backend-test.env vitest --reporter verbose", + "coverage": "env-cmd -f ../envs/dev/backend-test.env vitest run --coverage", + "start": "env-cmd -f ../envs/dev/api-no-docker.env node server.js", + "dev": "env-cmd -f ../envs/dev/api-no-docker.env nodemon server.js", "dev-docker": "nodemon server.js" }, "keywords": [],