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

Improve developer experience #146

Merged
merged 7 commits into from
Nov 6, 2024
Merged
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
backend:
build: ./nomad-rest-api
env_file:
- ./env/backend.env
- ./envs/dev/backend.env
ports:
- '8080:8080'
volumes:
Expand All @@ -23,7 +23,7 @@ services:
frontend:
build: ./nomad-front-end
env_file:
- ./env/frontend.env
- ./envs/dev/frontend.env
ports:
- '3003:3003'
volumes:
Expand All @@ -34,6 +34,8 @@ services:
- backend

client:
profiles:
- client
build: ../nomad-spect-client
volumes:
- ../nomad-spect-client/src:/app/src
Expand All @@ -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
Expand Down
34 changes: 34 additions & 0 deletions envs/dev/backend-test.env
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions envs/dev/backend.env
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
1 change: 1 addition & 0 deletions env-example/frontend.env → envs/dev/frontend.env
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions envs/example/client.env
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions envs/example/frontend.env
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion nomad-front-end/src/socketConnection.js
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions nomad-rest-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ COPY package.json /app/

RUN npm install

COPY . .

EXPOSE 8080

CMD ["npm", "run" , "dev-docker"]
CMD ["npm", "run", "dev-docker"]
10 changes: 5 additions & 5 deletions nomad-rest-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
Expand Down