Skip to content

Commit

Permalink
Freshen up things now that docker images work
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed Apr 28, 2021
1 parent dfab05b commit 3014179
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 336 deletions.
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG NODE_VER=14-buster
ARG NODE_VER=16-alpine

FROM node:$NODE_VER AS install

Expand All @@ -16,9 +16,13 @@ RUN yarn install --immutable

COPY . /trellis/ainz/

RUN yarn build && rm -rf node_modules
# Build code and remove dev deps
RUN yarn build && rm -rfv .yarn .pnp*

FROM node:$NODE_VER-slim AS production
FROM node:$NODE_VER AS production

# Do not run service as root
USER node

WORKDIR /trellis/ainz

Expand Down
44 changes: 26 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[![License](https://img.shields.io/github/license/trellisfw/ainz)](LICENSE)
![Docker Pulls](https://img.shields.io/docker/pulls/trellisfw/ainz)

# Ainz

This is a microservice which moves (actually just makes links)
Expand All @@ -8,35 +11,40 @@ resources from a "watch list" to another list based on rules.
Eventually Ainz images should be pushed to dockerhub,
but for now you can run Ainz by cloning this repo.

### Within the [OADA Reference API Server][]
### docker-compose

To add Ainz to the services run with an OADA v3 server,
simply add the following to your `docker-compose.override.yml`:
Here is an example of using ainz with docker-compose.

```yaml
services:
ainz:
extends:
# Change this to wherever you cloned the ainz git
file: ./ainz/docker-compose.yml
service: ainz
image: trellisfw/ainz
restart: unless-stopped
#volumes:
# Additional template helpers can be mapped into the helpers dir.
# Ainz will load all helpers it finds at boot.
#- ./path/to/helper-module:/trellis/ainz/dist/helpers/helper-module
environment:
NODE_TLS_REJECT_UNAUTHORIZED:
NODE_ENV=: ${NODE_ENV:-development}
DEBUG: ${DEBUG-*:error,*:warn,*:info}
# Connect to host if DOMAIN not set.
# You should really not rely on this though. Set DOMAIN.
domain: ${DOMAIN:-host.docker.internal}
# Unless your API server is running with development tokens enabled,
# you will need to give Ainz token(s) to use.
#
# Alternatively you can set ANIZ_TOKENS in your environment.
token: abc123,def456
token: ${AINZ_TOKENS:-abc123,def456}
```
In the example above,
the path assumes you ran this repo inside the folder
with the OADA v3 `docker-compose.yml` etc. inside.
You can have ainz anywhere, just adjust the path to it accordingly.
### Running ainz within the [OADA Reference API Server]
To add Ainz to the services run with an OADA v3 server,
simply add a snippet like the one in the previous section
to your `docker-compose.override.yml`.

### External Usage

To run Ainz separately, simply set the domain and token(s) of the OADA API
and then run `docker-compose` in the directory where you cloned this git.
To run Ainz separately, simply set the domain and token(s) of the OADA API.

```shell
# Set up the environment.
Expand All @@ -52,9 +60,9 @@ docker-compose up -d

See [rule.example.json5](rule.example.json5) for an annotated example of a rule.

You can also see the corresponsing [schemas][] from OADA formats.
You can also see the corresponsing [schemas] from OADA formats.

A user's rules are located at `/bookmarks/services/ainz/rules` by default.

[OADA Reference API Server]: https://github.com/OADA/oada-srvc-docker
[oada reference api server]: https://github.com/OADA/oada-srvc-docker
[schemas]: https://github.com/OADA/formats/tree/master/schemas/oada/ainz
9 changes: 4 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ services:
ainz:
build:
context: .
image: trellisfw/ainz
restart: unless-stopped
#volumes:
# Additional template helpers can be mapped into the helpers dir.
# Ainz will load all helpers it finds at boot.
#- ./path/to/helper-module:/trellis/ainz/dist/helpers/helper-module
#networks:
#- http_net
# Additional template helpers can be mapped into the helpers dir.
# Ainz will load all helpers it finds at boot.
#- ./path/to/helper-module:/trellis/ainz/dist/helpers/helper-module
environment:
- NODE_TLS_REJECT_UNAUTHORIZED
- NODE_ENV=${NODE_ENV:-development}
Expand Down
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,31 @@
"build": "tsc -b"
},
"author": "Alex Layton <[email protected]>",
"license": "ISC",
"license": "Apache-2.0",
"dependencies": {
"@oada/client": "^2.4.1",
"@oada/list-lib": "^2.1.6",
"@oada/types": "^1.5.1",
"ajv": "^7.2.3",
"bluebird": "^3.5.1",
"debug": "^4.3.1",
"ajv": "^7.2.4",
"bluebird": "^3.7.2",
"debug": "^4.3.2",
"handlebars": "^4.7.7",
"json-pointer": "^0.6.1",
"jsonschema8": "^1.1.1",
"luxon": "^1.26.0",
"minimist": "^1.2.5",
"nconf": "^0.11.2",
"p-queue": "^6.6.2",
"pino-debug": "^2.0.0"
"p-queue": "^6.6.2"
},
"devDependencies": {
"@tsconfig/node12": "^1.0.7",
"@tsconfig/node14": "^1.0.0",
"@types/bluebird": "^3.5.33",
"@types/debug": "^4.1.5",
"@types/json-pointer": "^1.0.30",
"@types/luxon": "^1.26.3",
"@types/luxon": "^1.26.5",
"@types/minimist": "^1.2.1",
"@types/node": "^14.14.35",
"@yarnpkg/pnpify": "^2.4.0",
"@types/node": "^14.14.43",
"@yarnpkg/pnpify": "^3.0.0-rc.3",
"prettier": "^2.2.1",
"typescript": "^4.2.3"
"typescript": "^4.2.4"
}
}
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import { join, dirname, extname } from 'path';
import { join, dirname } from 'path';
import { promises as fs } from 'fs';

import Bluebird from 'bluebird';
Expand All @@ -29,7 +29,6 @@ import Rule, { assert as assertRule } from '@oada/types/oada/ainz/rule';
import Resource, { assert as assertResource } from '@oada/types/oada/resource';

import config from './config';
import { Hash } from 'node:crypto';

const trace = debug('ainz:trace');
const info = debug('ainz:info');
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@tsconfig/node12",
"extends": "@tsconfig/node14",
"compilerOptions": {
"sourceMap": true,
"allowJs": true,
Expand Down
Loading

0 comments on commit 3014179

Please sign in to comment.