diff --git a/deploy/config/lib.env b/deploy/config/lib.env deleted file mode 100644 index 7a5546478..000000000 --- a/deploy/config/lib.env +++ /dev/null @@ -1,6 +0,0 @@ -PORT='4001' -MODE='local' -LOCAL_PATH ='/dtaas/libms/files' -LOG_LEVEL='debug' -APOLLO_PATH='/lib' -GRAPHQL_PLAYGROUND='true' \ No newline at end of file diff --git a/deploy/config/libms.yaml b/deploy/config/libms.yaml new file mode 100644 index 000000000..30b1f0c54 --- /dev/null +++ b/deploy/config/libms.yaml @@ -0,0 +1,14 @@ +port: '4001' +mode: 'local' #git or local +local-path: '/dtaas/libms/files' +log-level: 'debug' +apollo-path: '/lib' +graphql-playground: 'true' + +git-repos: #only used in git mode + - user1: + repo-url: 'https://gitlab.com/dtaas/user1.git' + - user2: + repo-url: 'https://gitlab.com/dtaas/user2.git' + - common: + repo-url: 'https://gitlab.com/dtaas/common.git' \ No newline at end of file diff --git a/docker/.env b/docker/.env index cc4751d72..52c522edf 100644 --- a/docker/.env +++ b/docker/.env @@ -4,7 +4,5 @@ OAUTH_URL='https://gitlab.com' OAUTH_CLIENT_ID='xx' OAUTH_CLIENT_SECRET='xx' OAUTH_SECRET='random-secret-string' -OAUTH_CONF_FILEPATH='/Users//DTaaS/docker/conf.dev' username1='user1' -username2='user2' -LIB_CONFIG='/Users//DTaaS/servers/lib/config/.env.default' \ No newline at end of file +username2='user2' \ No newline at end of file diff --git a/docker/compose.dev.yml b/docker/compose.dev.yml index 7f12c87f2..830ecf3cb 100644 --- a/docker/compose.dev.yml +++ b/docker/compose.dev.yml @@ -40,7 +40,7 @@ services: restart: unless-stopped volumes: - ${DTAAS_DIR}/files:/dtaas/libms/files - - ${LIB_CONFIG}:/dtaas/libms/config/.env.default + - ${DTAAS_DIR}/servers/lib/config/libms.dev.yaml:/dtaas/libms/config/libms.yaml labels: - "traefik.enable=true" - "traefik.http.routers.libms.entryPoints=web" @@ -90,7 +90,7 @@ services: image: thomseddon/traefik-forward-auth:latest restart: unless-stopped volumes: - - ${OAUTH_CONF_FILEPATH}:/conf + - ${DTAAS_DIR}/docker/conf.dev:/conf environment: - DEFAULT_PROVIDER=generic-oauth - PROVIDERS_GENERIC_OAUTH_AUTH_URL=${OAUTH_URL}/oauth/authorize diff --git a/docker/libms.dockerfile b/docker/libms.dockerfile index 9b70a4e67..d8678a768 100644 --- a/docker/libms.dockerfile +++ b/docker/libms.dockerfile @@ -1,4 +1,4 @@ -FROM node:20.10.0-slim as build +FROM node:22.12.0-slim as build #! docker should be run from the root directory of the project @@ -15,13 +15,14 @@ RUN yarn install --immutable --immutable-cache --check-cache RUN yarn build -FROM node:20.10.0-slim +FROM node:22.12.0-slim COPY --from=build /dtaas/libms/dist /dtaas/libms/dist COPY --from=build /dtaas/libms/node_modules /dtaas/libms/node_modules COPY --from=build /dtaas/libms/package.json /dtaas/libms/package.json COPY --from=build /dtaas/libms/config /dtaas/libms/config WORKDIR /dtaas/libms +COPY ./deploy/config/libms.yaml libms.yaml # Define the command to run your app -CMD ["yarn", "start", "--config", "config/.env.default", "-H", "config/http.json"] \ No newline at end of file +CMD ["yarn", "start", "--config", "libms.yaml", "-H", "config/http.json"] \ No newline at end of file diff --git a/docker/libms.npm.dockerfile b/docker/libms.npm.dockerfile index 2290968b5..fa1fb36d3 100644 --- a/docker/libms.npm.dockerfile +++ b/docker/libms.npm.dockerfile @@ -1,4 +1,4 @@ -FROM node:20.10.0-slim +FROM node:22.12.0-slim #! docker should be run from the root directory of the project @@ -9,7 +9,7 @@ WORKDIR /dtaas/libms ARG VERSION="latest" RUN npm i -g @into-cps-association/libms@${VERSION} -COPY ./deploy/config/lib.env .env +COPY ./deploy/config/libms.yaml libms.yaml COPY ./servers/lib/config/http.json . # Define the command to run your app diff --git a/docs/developer/docker/docker.md b/docs/developer/docker/docker.md index bb164a652..1818d1fde 100644 --- a/docs/developer/docker/docker.md +++ b/docs/developer/docker/docker.md @@ -63,7 +63,7 @@ The configuration files to be updated are: 1. **client/config/local.js** please see [client config](../../admin/client/config.md) for help with updating this config file -1. **servers/lib/config/.env.default** +1. **servers/lib/config/libms.dev.yaml** please see [lib config](../../admin/servers/lib/docker.md) for help with updating this config file diff --git a/servers/lib/DEVELOPER.md b/servers/lib/DEVELOPER.md index b945024df..ebad3714e 100644 --- a/servers/lib/DEVELOPER.md +++ b/servers/lib/DEVELOPER.md @@ -116,17 +116,13 @@ running the following commands. The microservices require configuration and the docker version of the microservices uses the configuration -file available in `config/.env.default`. +file available in `config/libms.dev.yaml`. -Please add a `.env` file with the environment variables for -the docker compose file to use. -e.g. +For more see [configuration documentation](./README.md#gear-configure). +The `config/libms.dev.yaml` file is used for configuration of the container. -```sh -PORT='4001' -MODE='local' -LOCAL_PATH='..\..\files' -``` +A new directory named `files` is created in `servers/lib` directory and +files are saved and served from the `files` directory. ### Use @@ -140,7 +136,7 @@ docker compose -f compose.lib.dev.yml up -d This command brings up the lib docker container and makes the website available at . -The `config/.env.default` file is used as the microservice configuration. +The `config/libms.dev.yaml` file is used as the microservice configuration. If the configuration values are changed, please restart the container. ```bash diff --git a/servers/lib/DOCKER.md b/servers/lib/DOCKER.md index b20a15554..3d64a7a8c 100644 --- a/servers/lib/DOCKER.md +++ b/servers/lib/DOCKER.md @@ -1,10 +1,11 @@ # Overview -The **libms microservice** is a simplified file manager providing graphQL API. -It has two features: +The **lib microservice** is a simplified file manager which serves files +from local file system or public git repositories. It is possible to -* provide a listing of directory contents. -* transfer a file to user. +* Upload and download files from web browser +* Query available files and download them using GraphQL API +* Clone public git repositories and serve them as local files ## Use in Docker Environment @@ -19,12 +20,13 @@ services: image: intocps/libms:latest restart: unless-stopped volumes: + - ./libms.yaml:/dtaas/libms/libms.yaml - ./files:/dtaas/libms/files ports: - "4001:4001" ``` -### Create Files Directory +### Create Files Directory (optional) The **libms microservice** serves files available from `files` directory. @@ -47,6 +49,71 @@ files/ Please create this `files` directory in the same file system location as that of the `compose.lib.yml` file. +:label: The directory structure is optional if you are using +libms as a standalone service. + +## :gear: Configure + +The microservices requires config specified in `libms.yaml` file. +The template configuration file is: + +```yaml +port: '4001' +mode: 'local' #git or local +local-path: 'files' +log-level: 'debug' +apollo-path: '/lib' +graphql-playground: 'true' + +git-repos: #only used in git mode + - user1: + repo-url: 'https://gitlab.com/dtaas/user1.git' + - user2: + repo-url: 'https://gitlab.com/dtaas/user2.git' + - common: + repo-url: 'https://gitlab.com/dtaas/common.git' +``` + +The `local-path` variable is the relative filepath to the +location of the local directory which will be served to users +by the Library microservice. + +Replace the default values the appropriate values for your setup. +Please save this config in `libms.yaml`. + +### Operation Modes + +The mode indicates the backend storage for the files. +There are two possible modes - `local` and `git`. +The files available in the `local-path` are served to users in `local` mode. +In the `git` mode, the remote git repos are cloned and they are +served to users as local files. Only public git repositories +are supported at present. + +#### git mode + +A fragment of the config for `git` mode is: + +```yaml +... +git-repos: + - user1: + repo-url: 'https://gitlab.com/dtaas/user1.git' + - user2: + repo-url: 'https://gitlab.com/dtaas/user2.git' + - common: + repo-url: 'https://gitlab.com/dtaas/common.git' +``` + +Here, `user1`, `user2` and `common` are the local directories into which +the remote git repositories get cloned. The name of the repository need not +match with the local directory name. For example, the above configuration +enables library microservice to clone +`https://gitlab.com/dtaas/user1.git` repository into +`user1` directory. Any git server accessible over +HTTP(S) protocol is supported. +The `.git` suffix is optional. + ### Run Use the following commands to start and stop the container respectively: diff --git a/servers/lib/README.md b/servers/lib/README.md index 0e4ddc462..053dab09b 100644 --- a/servers/lib/README.md +++ b/servers/lib/README.md @@ -38,24 +38,24 @@ needs to have _read:packages_ scope. ## :gear: Configure -The microservices requires config specified in INI format. +The microservices requires config specified in yaml format. The template configuration file is: ```yaml port: '4001' -mode: 'git' # either git or local -local-path: 'files' +mode: 'local' #git or local +local-path: '..\..\files' log-level: 'debug' apollo-path: '/lib' graphql-playground: 'true' -git-repos: - - user-1: - repo-url: 'https://github.com/isomorphic-git/lightning-fs' - - user-2: +git-repos: #only used in git mode + - user1: + repo-url: 'https://gitlab.com/dtaas/user1.git' + - user2: repo-url: 'https://gitlab.com/dtaas/user2.git' - common: - repo-url: 'https://gitlab.com/dtaas/common' + repo-url: 'https://gitlab.com/dtaas/common.git' ``` The `local-path` variable is the relative filepath to the @@ -80,20 +80,20 @@ A fragment of the config for `git` mode is: ```yaml ... git-repos: - - user-1: - repo-url: 'https://github.com/isomorphic-git/lightning-fs' - - user-2: + - user1: + repo-url: 'https://gitlab.com/dtaas/user1.git' + - user2: repo-url: 'https://gitlab.com/dtaas/user2.git' - common: - repo-url: 'https://gitlab.com/dtaas/common' + repo-url: 'https://gitlab.com/dtaas/common.git' ``` -Here, `user-1`, `user-2` and `common` are the local directories into which +Here, `user1`, `user2` and `common` are the local directories into which the remote git repositories get cloned. The name of the repository need not match with the local directory name. For example, the above configuration enables library microservice to clone -`https://github.com/isomorphic-git/lightning-fs` repository into -`user-1` directory. Any git server accessible over +`https://gitlab.com/dtaas/user1.git` repository into +`user1` directory. Any git server accessible over HTTP(S) protocol is supported. The `.git` suffix is optional. diff --git a/servers/lib/compose.lib.dev.yml b/servers/lib/compose.lib.dev.yml index f1e4a8ba0..6e8e9ac0e 100644 --- a/servers/lib/compose.lib.dev.yml +++ b/servers/lib/compose.lib.dev.yml @@ -4,6 +4,7 @@ services: context: ../../ dockerfile: ./docker/libms.dockerfile volumes: - - ${LOCAL_PATH}:/dtaas/libms/files + - ./files:/dtaas/libms/files + - ./config/libms.dev.yaml:/dtaas/libms/libms.yaml ports: - - ${PORT}:4001 + - 4001:4001 diff --git a/servers/lib/compose.lib.yml b/servers/lib/compose.lib.yml index a4e080791..93e7d0df2 100644 --- a/servers/lib/compose.lib.yml +++ b/servers/lib/compose.lib.yml @@ -3,6 +3,7 @@ services: image: intocps/libms:latest restart: unless-stopped volumes: + - ./config/libms.dev.yaml:/dtaas/libms/libms.yaml - ./files:/dtaas/libms/files ports: - "4001:4001" diff --git a/servers/lib/config/libms.dev.yaml b/servers/lib/config/libms.dev.yaml new file mode 100644 index 000000000..1a136a56f --- /dev/null +++ b/servers/lib/config/libms.dev.yaml @@ -0,0 +1,14 @@ +port: '4001' +mode: 'local' #git or local +local-path: '/dtaas/libms/files' +log-level: 'debug' +apollo-path: '/lib' +graphql-playground: 'true' + +git-repos: #only used in git mode + - user1: + repo-url: 'https://gitlab.com/dtaas/user1.git' + - user2: + repo-url: 'https://gitlab.com/dtaas/user2.git' + - common: + repo-url: 'https://gitlab.com/dtaas/common.git' \ No newline at end of file diff --git a/servers/lib/config/libms.yaml.default b/servers/lib/config/libms.yaml.default index 956374c3f..1cd67b261 100644 --- a/servers/lib/config/libms.yaml.default +++ b/servers/lib/config/libms.yaml.default @@ -1,12 +1,14 @@ port: '4001' -mode: 'git' +mode: 'local' #git or local local-path: '..\..\files' log-level: 'debug' apollo-path: '/lib' graphql-playground: 'true' -git-repos: - - user-1: - repo-url: 'https://github.com/isomorphic-git/lightning-fs' - - user-2: - repo-url: 'https://github.com/isomorphic-git/lightning-fs' \ No newline at end of file +git-repos: #only used in git mode + - user1: + repo-url: 'https://gitlab.com/dtaas/user1.git' + - user2: + repo-url: 'https://gitlab.com/dtaas/user2.git' + - common: + repo-url: 'https://gitlab.com/dtaas/common.git' \ No newline at end of file diff --git a/servers/lib/libms.yaml.sample b/servers/lib/libms.yaml.sample deleted file mode 100644 index 956374c3f..000000000 --- a/servers/lib/libms.yaml.sample +++ /dev/null @@ -1,12 +0,0 @@ -port: '4001' -mode: 'git' -local-path: '..\..\files' -log-level: 'debug' -apollo-path: '/lib' -graphql-playground: 'true' - -git-repos: - - user-1: - repo-url: 'https://github.com/isomorphic-git/lightning-fs' - - user-2: - repo-url: 'https://github.com/isomorphic-git/lightning-fs' \ No newline at end of file diff --git a/servers/lib/package.json b/servers/lib/package.json index 812853f4b..67e321b4e 100644 --- a/servers/lib/package.json +++ b/servers/lib/package.json @@ -1,6 +1,6 @@ { "name": "@into-cps-association/libms", - "version": "0.5.2", + "version": "0.5.3", "description": "microservices that handles request by fetching and returning the file-names and folders of given directory", "author": "phillip.boe.jensen@gmail.com", "contributors": [