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

Mongodb DAO Update #112

Merged
merged 27 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6b8b89b
Updating all versions to the highest possible w/o conflicts.
patrickfuhrmann Jun 20, 2024
c0d6c09
Replacing the 'del' package by the 'rimraf' package to avoid
patrickfuhrmann Jun 20, 2024
4b786dc
Updating the production/.env with some reasonable values.
patrickfuhrmann Jun 20, 2024
daa02c4
Updating the dao driver code to comply with mongdb >= 6.
patrickfuhrmann Jun 20, 2024
ee96447
Using the 'date' substructure of releaseDate. Error otherwise.
patrickfuhrmann Jun 20, 2024
924ccdd
TS now requires to use 'const pino ..' instead of 'import pino ..'
patrickfuhrmann Jun 20, 2024
c8e8e19
Adding an upgrade of npm to [email protected].
patrickfuhrmann Jun 20, 2024
f1835ee
Adding a description of the required variables. Can to to README.md
patrickfuhrmann Jun 20, 2024
3ba061a
Formatting fixed.
patrickfuhrmann Jul 21, 2024
4485e2e
a) mongo 'Filter' type replacing 'any' b) Formatting improved
patrickfuhrmann Jul 21, 2024
9819f17
Mongodb already returns Promises, which we forward to the calling fun…
patrickfuhrmann Jul 21, 2024
ea1c815
This is to get the test running again.
patrickfuhrmann Jul 21, 2024
4e088c6
Run the TEST
patrickfuhrmann Jul 21, 2024
2aac59c
Deployment taken from BE
patrickfuhrmann Jul 21, 2024
658b721
Describing necessary ENV variables
patrickfuhrmann Jul 21, 2024
8e50d62
Was moved to README.md
patrickfuhrmann Jul 21, 2024
6ddedbf
Adding the real update time
patrickfuhrmann Jul 21, 2024
ee664d0
Fixing format with XML namespace url
patrickfuhrmann Jul 21, 2024
0dc0853
Applying workflow to master instead of the development branch.
patrickfuhrmann Jul 22, 2024
daab992
Formal Fix: Merging MongoClient, Filter import from mongodb.
patrickfuhrmann Jul 22, 2024
95b512b
Changed default LOG_LEVEL to 'error' in .env and README.md
patrickfuhrmann Jul 22, 2024
738df60
Putting { id:1 } projection back to identifiersQuery.
patrickfuhrmann Jul 22, 2024
c16411c
Switching back to the node:18-slim version as apline seems to produce…
patrickfuhrmann Jul 23, 2024
0c81791
Making the mongoFilter more typesafe with Filter<StatusFilter>), avoi…
patrickfuhrmann Jul 23, 2024
eac0a72
Only pushing output image to ghcr if we push code to master
patrickfuhrmann Jul 24, 2024
372bfc7
Changing trigger back to master
patrickfuhrmann Jul 24, 2024
077150a
Pushing to the GitHub Container Registry only on 'push' not on 'pr'
patrickfuhrmann Jul 25, 2024
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: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: CI

on: [pull_request]
on:
push:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this ca be on PR only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I wanted to make sure that the test/deploy works on your side.

branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
test_build:
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deploy

on:
push:
branches: [ "mongo-workflow-fix" ]
minottic marked this conversation as resolved.
Show resolved Hide resolved

jobs:
deploy:
name: Build and deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create image tags
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
flavor: latest=true # adds :latest tag to outputs.tags
tags: type=sha,format=long,prefix= # adds :<sha> tag to outputs.tags

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64/v8
push: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we set this to true only on push to master? in this way, we avoid the permission error when coming from a fork

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think we can:

  • eac0a72 : made the push dependent on push to master.
  • 372bfc7: forgot to change the trigger back to master.

Copy link
Collaborator

@minottic minottic Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be enough to evaluate the true false condition in the push field.

push: ${{ github.event_name. == 'push' }}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I misunderstood. I fixed with 077150a. Seems to work for 'push' on my branch and 'pr' on the scicat master.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np! thanks for the changes! I would be fine merging now, do you plan any other change or is it good to go?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not planning any other changes in this PR so we are good to go from my side. Thanks a lot for your help.

tags: ${{ steps.meta.outputs.tags }}

5 changes: 5 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": "tsx",
"extension": ["ts"],
"spec": [ "src/server/env.ts" , "test/**/*.ts"]
}
70 changes: 0 additions & 70 deletions ENVIRONMENT_README.md
minottic marked this conversation as resolved.
Outdated
Show resolved Hide resolved

This file was deleted.

70 changes: 67 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ The National Library of Finland.

## Dependenices

* Node 8.9.4+
* Typescript 2.7.2+
* npm 5.6.0+
* Node v18.20.38+
* Typescript 5.5.3+
* npm 10.8.1+
* tsx v4.16.2 (for mocha tests only)

## Capabilities

Expand Down Expand Up @@ -56,6 +57,69 @@ Add new records to your mongodb instance by HTTP PUT using the following route:
* `http://localhost:3000/scicat/Publication`


## ENVIRONMENT Variables

*System variables**
Key | Description | Default
--------:|-------------| --------
DAPP_ID | No Idea | oai-pmh-service
CONNECTOR | (don't change) | mongodb
ADMIN_USER_EMAIL | E-Mail address of the admin user | none
LOG_LEVEL | default/error/warning | none
minottic marked this conversation as resolved.
Show resolved Hide resolved

**Mongo DB variables**
Key | Description | Default
--------:|-------------| --------
CONNECTOR | (don't change) | mongodb
DB_HOST | Database Hostname | none
DB_PORT | Database Port | none
DB_USER | Database Username | none
DB_PASS | Database Password | none
DB_URL | [&lt;user&gt;:&lt;password&gt;@]&lt;host&gt;:&lt;port&gt;/&lt;dbName&gt;| none
DATABASE | Publication Database | dacat-next

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe change to new scicat namings in a follow-up

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok will do later.

COLLECTION | Collection to storage Publation Documents| PublishedData
COLLECTION_ID | Unique Identifier of records | 'doi'
BASE_URL | Prefix to link back to this server | http://localhost

**Note**: When DB_URL is specified, DB_HOST/DB_PORT/DB_USER/DB_PASS and DATABASE are ignored.

**OAI_PMH Listen Port**

Key | Description | Default
--------:|-------------| --------
HOST_CONFIGURATION | web server configuration | production/host_config.json

The content of the *host_config.json* file are the json encoded variables to steer the web server itself.
As far as I can see, the 'host' variable is ignored in the code, but the 'port' variable is honored.

**Example** for a *host_config.json* file.
```
{
"host": "localhost",
"port": 3000
}
```

### Docker start example
Docker start example, assuming there is a network called
'scicatlive_default'.
```
docker run \
--network=scicatlive_default \
-e CONNECTOR=mongodb \
-e DB_HOST=mongodb \
-e DB_PORT=27017 \
-e DB_USER="" \
-e DB_PASSWORD="" \
-e DATABASE=dacat-next \
-e COLLECTION=PublishedData \
-e COLLECTION_ID="_id" \
-e HOST_CONFIG=server/host_config.json \
-p 7002:3001 \
--name=oai-pmh-provider \
oai-pmh-provider
```

## Run in *production* mode:

At the simplest level:
Expand Down
Loading
Loading