Skip to content

Commit

Permalink
Add Init Container To Onboard MSISDN's (#55)
Browse files Browse the repository at this point in the history
* Add init container to onboard with central-ledger

* Remove environment var processing script

* Switch RUN to CMD

* Add OCI labels

* Add contributor

* Update init/central-ledger/Dockerfile

Co-Authored-By: Matt Kingston <mattkingston@gmail.com>

* Clear whitespace and unused comments

* Add build and publish to CI for init-central-ledger

* Fix indentation

* created insert msisnd script

* complete docker container and MSISDN onboarding script

* change MSISDN_LIST name

* change script to handle MSISDN data

* ignore dependency vulneravility

* update dockerfile

* rename

* change pathfinder url name

* modify scripts

* fix script and docker container

* add CI pipeline and remove unused files

* fix docker command

* fix indentation

* fix tag implementation

* yaml is fun

* resolve vulnerabilities and fix docker save

* fix docker build

* fix docker image naming and add Matt suggestion

* log current images

* idk why but it works now

* Clean up naming and pipeline

* Bump version

Co-authored-by: Kamuela Franco <kamuela.franco@gmail.com>
Co-authored-by: Matt Kingston <mattkingston@gmail.com>
  • Loading branch information
3 people authored Jul 9, 2020
1 parent 8da29c5 commit b708224
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 37 deletions.
124 changes: 116 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ jobs:
echo "Building Docker image: $CIRCLE_TAG"
docker build
--build-arg=BUILD_DATE="$(date -u --iso-8601=seconds)"
--build-arg=VERSION="$RELEASE_TAG"
--build-arg=VCS_URL="$CIRCLE_REPOSITORY_URL"
--build-arg=VCS_REF="$CIRCLE_SHA1"
--build-arg BUILD_DATE="$(date -u --iso-8601=seconds)"
--build-arg VERSION="$RELEASE_TAG"
--build-arg VCS_URL="$CIRCLE_REPOSITORY_URL"
--build-arg VCS_REF="$CIRCLE_SHA1"
-t $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:$CIRCLE_TAG .
- run:
name: Save docker image to workspace
Expand All @@ -215,6 +215,29 @@ jobs:
paths:
- ./docker-image.tar

build-onboard-msisdn-oracle:
executor: default-machine
steps:
- checkout
- run:
name: Build Docker onboard-msisdn-oracle $CIRCLE_TAG image
command: >
echo "Building Docker image: onboard-msisdn-oracle $CIRCLE_TAG"
docker build
--build-arg BUILD_DATE="$(date -u --iso-8601=seconds)"
--build-arg VERSION="$RELEASE_TAG"
--build-arg VCS_URL="$CIRCLE_REPOSITORY_URL"
--build-arg VCS_REF="$CIRCLE_SHA1"
-t $DOCKER_ORG/onboard-msisdn-oracle:$CIRCLE_TAG .
- run:
name: Save docker image to workspace
command: docker save -o /tmp/docker-onboard-msisdn-oracle.tar $DOCKER_ORG/onboard-msisdn-oracle:$CIRCLE_TAG
- persist_to_workspace:
root: /tmp
paths:
- ./docker-onboard-msisdn-oracle.tar

build-local:
executor: default-machine
steps:
Expand All @@ -225,10 +248,10 @@ jobs:
echo "Building Docker image: local"
docker build
--build-arg=BUILD_DATE="$(date -u --iso-8601=seconds)"
--build-arg=VERSION="local"
--build-arg=VCS_URL="$CIRCLE_REPOSITORY_URL"
--build-arg=VCS_REF="$CIRCLE_SHA1"
--build-arg BUILD_DATE="$(date -u --iso-8601=seconds)"
--build-arg VERSION="local"
--build-arg VCS_URL="$CIRCLE_REPOSITORY_URL"
--build-arg VCS_REF="$CIRCLE_SHA1"
-t $DOCKER_ORG/$CIRCLE_PROJECT_REPONAME:local .
- run:
name: Save docker image to workspace
Expand All @@ -238,6 +261,29 @@ jobs:
paths:
- ./docker-image.tar

build-local-onboard-msisdn-oracle:
executor: default-machine
steps:
- checkout
- run:
name: Build Docker onboard-msisdn-oracle local image for testing
command: >
echo "Building Docker image: onboard-msisdn-oracle local"
docker build
--build-arg BUILD_DATE="$(date -u --iso-8601=seconds)"
--build-arg VERSION="local"
--build-arg VCS_URL="$CIRCLE_REPOSITORY_URL"
--build-arg VCS_REF="$CIRCLE_SHA1"
-t $DOCKER_ORG/onboard-msisdn-oracle:local ./init/onboard-msisdn-oracle/
- run:
name: Save docker image to workspace
command: docker save -o /tmp/docker-onboard-msisdn-oracle.tar $DOCKER_ORG/onboard-msisdn-oracle:local
- persist_to_workspace:
root: /tmp
paths:
- ./docker-onboard-msisdn-oracle.tar

license-scan:
executor: default-machine
steps:
Expand Down Expand Up @@ -338,6 +384,39 @@ jobs:
-H 'cache-control: no-cache' \
-d "{\"text\": \"*${CIRCLE_PROJECT_REPONAME}* - Release \`${CIRCLE_TAG}\`: https://github.com/mojaloop/${CIRCLE_PROJECT_REPONAME}/releases/tag/${CIRCLE_TAG}\"}"
publish-onboard-msisdn-oracle:
executor: default-machine
steps:
- checkout
- attach_workspace:
at: /tmp
- run:
name: Load the pre-built docker image for onboard-msisdn-oracle from workspace
command: docker load -i /tmp/docker-onboard-msisdn-oracle.tar
- run:
name: Login to Docker Hub
command: docker login -u $DOCKER_USER -p $DOCKER_PASS
- run:
name: Setup environment vars for release/snapshot
command: ./.circleci/_set_up_deploy_envs.sh
- run:
name: Re-tag pre built image
command: |
docker tag docker-onboard-msisdn-oracle.tar $DOCKER_ORG/onboard-msisdn-oracle:$RELEASE_TAG
- run:
name: Publish Docker image $CIRCLE_TAG & Latest tag to Docker Hub for onboard-msisdn-oracle
command: |
echo "Publishing $DOCKER_ORG/onboard-msisdn-oracle:$CIRCLE_TAG"
docker push $DOCKER_ORG/onboard-msisdn-oracle:$CIRCLE_TAG
- run:
name: Slack announcement for tag releases
command: |
curl -X POST \
$SLACK_WEBHOOK_ANNOUNCEMENT \
-H 'Content-type: application/json' \
-H 'cache-control: no-cache' \
-d "{\"text\": \"*onboard-msisdn-oracle* - Release \`${CIRCLE_TAG}\`: https://github.com/mojaloop/${CIRCLE_PROJECT_REPONAME}/releases/tag/${CIRCLE_TAG}\"}"
deploy:
executor: deploy-kube/helm-kube
steps:
Expand Down Expand Up @@ -414,6 +493,14 @@ workflows:
- /feature*/
- /bugfix*/
- /hotfix*/
- build-local-onboard-msisdn-oracle:
context: org-global
filters:
branches:
ignore:
- /feature*/
- /bugfix*/
- /hotfix*/
- license-scan:
context: org-global
requires:
Expand Down Expand Up @@ -442,10 +529,30 @@ workflows:
branches:
ignore:
- /.*/
- build-onboard-msisdn-oracle:
context: org-global
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*(\-snapshot)?(\-hotfix(\.[0-9]+))?/
branches:
ignore:
- /.*/
- publish:
context: org-global
requires:
- build
- build-onboard-msisdn-oracle
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*(\-snapshot)?(\-hotfix(\.[0-9]+))?/
branches:
ignore:
- /.*/
- publish-onboard-msisdn-oracle:
context: org-global
requires:
- build
- build-onboard-msisdn-oracle
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*(\-snapshot)?(\-hotfix(\.[0-9]+))?/
Expand All @@ -456,6 +563,7 @@ workflows:
context: org-global
requires:
- publish
- publish-onboard-msisdn-oracle
filters:
tags:
only: /v[0-9]+(\.[0-9]+)*(\-snapshot)?/
Expand Down
22 changes: 22 additions & 0 deletions init/onboard-msisdn-oracle/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM alpine

ARG CREATED
ARG SOURCE
ARG REVISION
ARG VERSION

# See https://github.com/opencontainers/image-spec/blob/master/annotations.md#pre-defined-annotation-keys and https://github.com/opencontainers/image-spec/blob/master/spec.md for info
LABEL org.opencontainers.image.created=${CREATED}
LABEL org.opencontainers.image.url="https://mojaloop.io/"
LABEL org.opencontainers.image.source=${SOURCE}
LABEL org.opencontainers.image.version=${VERSION}
LABEL org.opencontainers.image.revision=${REVISION}
LABEL org.opencontainers.image.title="onboard-msisdn-oracle"
LABEL org.opencontainers.image.authors="aaron.reynoza@modusbox.com"
LABEL org.opencontainers.image.licenses="Apache-2.0"

RUN apk add --no-cache --upgrade bash curl jq

COPY insert_msisdns.sh /insert_msisdns.sh

CMD ["sh", "/insert_msisdns.sh"]
16 changes: 16 additions & 0 deletions init/onboard-msisdn-oracle/insert_msisdns.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env sh

CURRENT_DATE=$(date)
for participantMSISDN in $(echo "${MSISDN_LIST}" | jq -c '.[]'); do
MSISDN=$(echo "${participantMSISDN}" | jq -r '.MSISDN');
CURRENCY=$(echo "${participantMSISDN}" | jq -r '.currency');
DATA="{\"currency\": \"${CURRENCY}\", \"fspId\": \"${DFSP_NAME}\"}"

curl -v --location --request PUT "${HOST_PATHFINDER_ORACLE}/participants/MSISDN/${MSISDN}" \
--header 'Content-Type: application/json' \
--header "date: ${CURRENT_DATE}" \
--header "fspiop-source: ${DFSP_NAME}" \
--data-raw "${DATA}";
done

echo "MSISDN's have been onboarded"
25 changes: 2 additions & 23 deletions src/audit-resolve.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
{
"decisions": {
"1300|nyc>istanbul-reports>handlebars": {
"madeAt": 0,
"decision": "fix"
},
"1316|nyc>istanbul-reports>handlebars": {
"madeAt": 0,
"decision": "fix"
},
"1324|nyc>istanbul-reports>handlebars": {
"madeAt": 0,
"decision": "fix"
},
"1325|nyc>istanbul-reports>handlebars": {
"madeAt": 0,
"decision": "fix"
},
"1500|npm-audit-resolver>yargs-unparser>yargs>yargs-parser": {
"decision": "ignore",
"madeAt": 1591787086979,
"expiresAt": 1592391879076
},
"1500|npm-audit-resolver>audit-resolve-core>yargs-parser": {
"decision": "ignore",
"madeAt": 1591787090589,
"expiresAt": 1592391879076
"madeAt": 1594258444388,
"expiresAt": 1594863234907
}
},
"rules": {},
Expand Down
9 changes: 4 additions & 5 deletions src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"name": "mojaloop-simulator",
"version": "10.4.1",
"version": "10.6.0",
"description": "A canonical test example implementation of the parties, transfers and quotes resources of the Mojaloop API",
"license": "Apache-2.0",
"main": "index.js",
"author": "Matt Kingston, ModusBox Inc.",
"contributors": [
"Kamuela Franco <kamuela.franco@modusbox.com>",
"Matt Kingston <matt.kingston@modusbox.com>",
"Steven Oderayi <steven.oderayi@modusbox.com>",
"Aaron Reynoza <aaron.reynoza@modusbox.com>",
"ModusBox",
"Mowali"
],
Expand Down

0 comments on commit b708224

Please sign in to comment.