Skip to content

Commit

Permalink
Fixes wrong docker files for library microservice (#1102)
Browse files Browse the repository at this point in the history
  - Updates the configuration files of libms in docker containers
  - Updates the documentation to reflect the change.

---------
Co-authored-by: prasadtalasila <[email protected]>
  • Loading branch information
nichlaes authored Dec 13, 2024
1 parent 1b0e8d6 commit fc33c92
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 68 deletions.
6 changes: 0 additions & 6 deletions deploy/config/lib.env

This file was deleted.

14 changes: 14 additions & 0 deletions deploy/config/libms.yaml
Original file line number Diff line number Diff line change
@@ -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'
4 changes: 1 addition & 3 deletions docker/.env
Original file line number Diff line number Diff line change
Expand Up @@ -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/<Username>/DTaaS/docker/conf.dev'
username1='user1'
username2='user2'
LIB_CONFIG='/Users/<Username>/DTaaS/servers/lib/config/.env.default'
username2='user2'
4 changes: 2 additions & 2 deletions docker/compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions docker/libms.dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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"]
CMD ["yarn", "start", "--config", "libms.yaml", "-H", "config/http.json"]
4 changes: 2 additions & 2 deletions docker/libms.npm.dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/docker/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 6 additions & 10 deletions servers/lib/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 <http://localhost:4001>.
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
Expand Down
77 changes: 72 additions & 5 deletions servers/lib/DOCKER.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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.
Expand All @@ -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:
Expand Down
30 changes: 15 additions & 15 deletions servers/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand Down
5 changes: 3 additions & 2 deletions servers/lib/compose.lib.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions servers/lib/compose.lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
14 changes: 14 additions & 0 deletions servers/lib/config/libms.dev.yaml
Original file line number Diff line number Diff line change
@@ -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'
14 changes: 8 additions & 6 deletions servers/lib/config/libms.yaml.default
Original file line number Diff line number Diff line change
@@ -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'
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'
12 changes: 0 additions & 12 deletions servers/lib/libms.yaml.sample

This file was deleted.

2 changes: 1 addition & 1 deletion servers/lib/package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"contributors": [
Expand Down

0 comments on commit fc33c92

Please sign in to comment.