Skip to content

Commit 808fa96

Browse files
committed
Update Docker Compose MongoDB version, revise README setup instructions, and add production proxy configuration.
1 parent e89971a commit 808fa96

3 files changed

Lines changed: 232 additions & 48 deletions

File tree

README.md

Lines changed: 207 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,81 +16,242 @@ Please checkout the development branch before starting to code and create a new
1616
git checkout development
1717
git checkout -b rreitmann/issue1234
1818

19-
Before you can build this project, you must install and configure the following dependencies on your machine:
19+
Before you can build this project, install and configure the following dependencies:
2020

21-
1. Java: You need to install java 15 sdk on your system. On Ubuntu you should use [SDKMAN!][] (`sdk install java 15.0.2.hs-adpt`)
22-
2. Maven: You need to install maven 3.6.1 or above on your system. On Ubuntu you should use [SDKMAN!][] (`sdk install maven`)
23-
3. [Node.js][]: Node.js 16 and npm (coming with node.js) are required as well. On Ubuntu you should install node using [NVM][] (`nvm install v16`)
21+
1. Java 17
22+
2. Maven 3.6.1 or newer
23+
3. [Node.js][] 18 with npm, preferably through [NVM][]
24+
4. Docker Desktop or a compatible Docker Engine with Docker Compose
25+
26+
On macOS with Homebrew:
27+
28+
```bash
29+
brew install openjdk@17 maven nvm
30+
brew install --cask docker
31+
mkdir -p ~/.nvm
32+
```
33+
34+
Add NVM and Java to your shell profile, for example `~/.zshrc`:
35+
36+
```bash
37+
export NVM_DIR="$HOME/.nvm"
38+
source "$(brew --prefix nvm)/nvm.sh"
39+
export JAVA_HOME="/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home"
40+
export PATH="$JAVA_HOME/bin:$PATH"
41+
```
42+
43+
Reload the shell and install Node:
44+
45+
```bash
46+
source ~/.zshrc
47+
nvm install 18
48+
nvm use 18
49+
```
2450

2551
On Windows, `patch.exe` has to exist in the PATH. It is distributed as part of git bash, or can be downloaded manually from [GnuWin32][].
2652

2753
## Running on your local machine
28-
Make sure that you have read-write-access on the **data** directory (in your project directory) for Elasticsearch and MongoDB. Specifically **Mac** users need to run the following command to create all data directories before bringing up the containers for the first time:
54+
55+
### 1. Prepare local service directories
56+
57+
Make sure that you have read-write access on the **data** directory in your project directory for Elasticsearch and MongoDB. Specifically **Mac** users need to run the following command to create all data directories before bringing up the containers for the first time:
58+
2959
```bash
3060
mkdir -p data/elasticsearch/data data/mongodb/db data/mongodb/logs
3161
```
32-
Otherwise your Docker Host will attempt to change permissions on the directories and fail.
3362

34-
Use `docker-compose up` to create all containers initially. MongoDB and Elasticsearch will be listening on their default ports. MailDev will show all locally sent email on 8081 and the identity-provider can be setup on port 8082. Any time after that use either `docker-compose up` or `docker-compose start`.
63+
Otherwise your Docker host may attempt to change permissions on the directories and fail.
64+
65+
### 2. Start Docker services
66+
67+
Start Docker Desktop first. Then start the local infrastructure:
68+
69+
```bash
70+
docker compose up -d
71+
```
72+
73+
MongoDB and Elasticsearch listen on their default ports. MailDev shows locally sent email on `http://localhost:8081`, and the identity provider is available on `http://localhost:8082`.
3574

3675
In case elasticsearch does not start successfully, you might need to increase its memory limit
37-
`mem_limit: 512m`, e.g. to `1024` (this change required removing and re-building the container).
76+
`mem_limit: 512m`, e.g. to `1024` (this change requires removing and re-building the container).
3877

39-
You can get a MongoDB dump and restore it locally:
78+
Verify the services:
79+
80+
```bash
81+
curl http://localhost:9200/
82+
docker exec mongodb mongosh --quiet --eval 'db.runCommand({ ping: 1 }).ok'
4083
```
41-
$ wget https://metadatamanagement-public.s3.eu-central-1.amazonaws.com/20220926_metadatamanagement_e2e.zip
42-
$ unzip 20220926_metadatamanagement_e2e.zip
43-
$ mv dump/metadatamanagement data/mongodb/db/
44-
$ docker exec -it mongodb bash
45-
mongo$ cd /data/mongodb/db
46-
mongo$ mongorestore ./metadatamanagement --db=metadatamanagement
47-
mongo$ exit
48-
rm -r dump
84+
85+
The MongoDB connection used by the local backend is:
86+
87+
```text
88+
host: localhost
89+
port: 27017
90+
database: metadatamanagement
4991
```
5092

51-
You will need to setup your `~/.m2/settings.xml` so that maven can download a dependency from Github:
93+
### 3. Configure Maven GitHub package access
94+
95+
Maven needs access to GitHub Packages for the `pl.allegro.tech:embedded-elasticsearch` test dependency. Configure `~/.m2/settings.xml`:
5296

5397
```xml
54-
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
55-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
56-
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
57-
http://maven.apache.org/xsd/settings-1.0.0.xsd">
58-
<servers>
59-
<server>
60-
<id>github</id>
61-
<username>${GITHUB_USERNAME}</username>
62-
<password>${GITHUB_TOKEN}</password>
63-
</server>
64-
</servers>
65-
</settings>
66-
```
67-
68-
Run `mvn` **first** to start the Spring backend and to **make sure** the frontend Angular constants module has been generated by the Maven Plugin. Run `npm --prefix mdm-frontend start` to start the Angular Frontend.
98+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
99+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
100+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
101+
http://maven.apache.org/xsd/settings-1.0.0.xsd">
102+
<servers>
103+
<server>
104+
<id>github</id>
105+
<username>YOUR_GITHUB_USERNAME</username>
106+
<password>YOUR_GITHUB_TOKEN</password>
107+
</server>
108+
</servers>
109+
</settings>
110+
```
111+
112+
The token needs package read access.
113+
114+
### 4. Install the local Maven plugin
115+
116+
Install the local MDM Maven plugin. This plugin generates frontend translations and constants during the main Maven build.
117+
69118
```shell
70119
mvn clean install -f maven-plugin/pom.xml
71-
mvn spring-boot:run
72120
```
73121

74-
In order for all external services to work on your local machine, you need to set the following environment variables
75-
when starting the Spring Boot application:
122+
### 5. Install frontend dependencies
123+
124+
```bash
125+
cd mdm-frontend
126+
npm ci
127+
cd ..
128+
```
129+
130+
### 6. Generate backend and frontend build artifacts
131+
132+
Run Maven once before starting the frontend so the generated Angular constants file exists:
133+
134+
```bash
135+
mvn compile -DskipTests -Dpmd.skip=true
136+
```
137+
138+
This generates `mdm-frontend/src/app/legacy/app.constants.js`.
139+
140+
### 7. Start the Spring backend
141+
142+
In order for all external services to work on your local machine, set the following environment variables when starting the Spring Boot application:
143+
76144
* `DARA_ENDPOINT` (regular endpoint for registering projects)
77145
* `DARA_USERNAME`
78146
* `DARA_PASSWORD`
79147
* `DARA_PID_ENDPOINT` (endpoint for registering variables)
80148
* `DARA_PID_USERNAME`
81149
* `DARA_PID_PASSWORD`
150+
* `DATACITE_ENDPOINT`
151+
* `DATACITE_USERNAME`
152+
* `DATACITE_PASSWORD`
153+
154+
For normal local development, dummy values are enough to start the application:
82155

83-
Starting the application from the command line would look like this:
84156
```sh
85-
DARA_ENDPOINT="https://dara.service/projects/" \
86-
DARA_USERNAME="bob" \
87-
DARA_PASSWORD="secret" \
88-
DARA_PID_ENDPOINT="https://dara.service/variables/" \
89-
DARA_PID_USERNAME="alice" \
90-
DARA_PID_PASSWORD="pid-secret" \
91-
mvn spring-boot:run
92-
```
93-
Use `sensitive-variables.tf` to fill in the **correct credentials**.
157+
DARA_ENDPOINT="http://localhost/dara/projects" \
158+
DARA_USERNAME="dummy" \
159+
DARA_PASSWORD="dummy" \
160+
DARA_PID_ENDPOINT="http://localhost/dara/variables" \
161+
DARA_PID_USERNAME="dummy" \
162+
DARA_PID_PASSWORD="dummy" \
163+
DATACITE_ENDPOINT="http://localhost/datacite" \
164+
DATACITE_USERNAME="dummy" \
165+
DATACITE_PASSWORD="dummy" \
166+
mvn spring-boot:run
167+
```
168+
169+
Verify the backend:
170+
171+
```bash
172+
curl http://localhost:8080/management/info
173+
```
174+
175+
Expected result: HTTP `200`.
176+
177+
`/management/health` may return `503 DOWN` locally when DARA/DataCite credentials are dummy values.
178+
179+
### 8. Start the Angular frontend
180+
181+
In a second terminal:
182+
183+
```bash
184+
cd mdm-frontend
185+
npm start
186+
```
187+
188+
Open:
189+
190+
```text
191+
http://localhost:4200/
192+
```
193+
194+
Verify the frontend:
195+
196+
```bash
197+
curl http://localhost:4200/
198+
```
199+
200+
Expected result: HTTP `200`.
201+
202+
### 9. Optional: restore a MongoDB dump
203+
204+
You can get a MongoDB dump and restore it locally:
205+
206+
```bash
207+
wget https://metadatamanagement-public.s3.eu-central-1.amazonaws.com/20220926_metadatamanagement_e2e.zip
208+
unzip 20220926_metadatamanagement_e2e.zip
209+
mv dump/metadatamanagement data/mongodb/db/
210+
docker exec -it mongodb bash
211+
cd /data/db
212+
mongorestore ./metadatamanagement --db=metadatamanagement
213+
exit
214+
rm -r dump
215+
```
216+
217+
### 10. Optional: run local frontend against production API
218+
219+
Create or use `mdm-frontend/proxy.prod.conf.json` with production targets for `/api`, `/oauth`, `/management`, and `/websocket`. Then start the frontend on a separate port:
220+
221+
```bash
222+
cd mdm-frontend
223+
npm run ng -- serve --port 4201 --proxy-config proxy.prod.conf.json
224+
```
225+
226+
Open:
227+
228+
```text
229+
http://localhost:4201/
230+
```
231+
232+
This runs local frontend code against the production backend/search API.
233+
234+
### 11. Optional: check the ELSST version
235+
236+
The MDM interface uses ELSST keywords from the CESSDA ELSST thesaurus. The configured ELSST version is used in:
237+
238+
* `mdm-frontend/src/app/legacy/common/i18n/directives/tageditor/elsst-search.service.js`
239+
* `mdm-frontend/src/app/legacy/common/i18n/directives/tageditor/tag-editor-elsst.controller.js`
240+
* `src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/service/DataCiteService.java`
241+
* `mdm-frontend/src/app/legacy/datapackagemanagement/configuration/translations-de.js`
242+
* `mdm-frontend/src/app/legacy/datapackagemanagement/configuration/translations-en.js`
243+
244+
Run the version check before releases and after CESSDA publishes a new ELSST release:
245+
246+
```bash
247+
npm --prefix mdm-frontend run check:elsst-version
248+
```
249+
250+
The check compares the MDM configuration with the current CESSDA `https://thesauri.cessda.eu/elsst/` redirect. If it fails, update the configured ELSST version, update the info dialog text, and verify the release notes:
251+
252+
```text
253+
https://elsst.cessda.eu/releases
254+
```
94255

95256
If you run the backend on your machine for the first time, or you have restored a
96257
mongodb dump, then you need to setup/reindex the elasticsearch indices. Therefore, login as admin to the application,

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
version: "3.10"
55
services:
66
mongodb:
7-
image: mongo:latest
7+
image: mongo:6.0
88
container_name: mongodb
99
environment:
1010
- MONGO_DATA_DIR=/data/mongodb/data
1111
- MONGO_LOG_DIR=/data/mongodb/logs
1212
volumes:
13-
- ./data/mongodb/db:/data/mongodb/db
13+
- ./data/mongodb/db:/data/db
1414
- ./data/mongodb/logs:/data/mongodb/logs
1515
command: mongod
1616
ports:

mdm-frontend/proxy.prod.conf.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"/api": {
3+
"target": "https://metadata.fdz.dzhw.eu",
4+
"changeOrigin": true,
5+
"secure": true
6+
},
7+
"/oauth": {
8+
"target": "https://metadata.fdz.dzhw.eu",
9+
"changeOrigin": true,
10+
"secure": true
11+
},
12+
"/management": {
13+
"target": "https://metadata.fdz.dzhw.eu",
14+
"changeOrigin": true,
15+
"secure": true
16+
},
17+
"/websocket": {
18+
"target": "https://metadata.fdz.dzhw.eu",
19+
"changeOrigin": true,
20+
"secure": true,
21+
"ws": true
22+
}
23+
}

0 commit comments

Comments
 (0)