Skip to content

Commit

Permalink
feat(mojaloop/project#1814): compile ts to js (#96)
Browse files Browse the repository at this point in the history
* feat: add pr-title-check step to ci/cd

* chore: change pr-tools orb to 0.1.10

* feat: compile ts to js for production

* fix: config json files are now copied manually

* fix: use js instead of ts for migrations and seeds

* feat: run migrations inside of docker

* fix: bad json formatting

* fix: test coverage

* fix: working on tricky integration test config
  • Loading branch information
lewisdaly authored Nov 5, 2021
1 parent 364869c commit 1f046f9
Show file tree
Hide file tree
Showing 18 changed files with 250 additions and 179 deletions.
16 changes: 10 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,23 @@ jobs:
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
mkdir -p ./test/results
- run:
name: Build docker images
name: Run mysql and migrate
command: |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
docker-compose up -d
./scripts/wait4.js cicd-integration-tests
# use development env since we are connecting to db outside of docker
docker-compose build
docker-compose up -d mysql
./scripts/wait4.js mysql
docker run --network mojaloop-net \
--rm mojaloop/auth-service:local \
sh -c "NODE_ENV=integration npm run migrate"
environment:
NODE_ENV: "development"
- run:
name: Migrate DB
name: run other containers
command: |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
npm -s run migrate
docker-compose up -d
./scripts/wait4.js cicd-integration-tests
# use development env since we are connecting to db outside of docker
environment:
NODE_ENV: "development"
Expand Down
24 changes: 11 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
FROM node:12.16.1-alpine as builder

FROM node:14.15-alpine as builder
USER root

WORKDIR /opt/auth-service

RUN apk add --no-cache -t build-dependencies git make gcc g++ python libtool autoconf automake \
&& cd $(npm root -g)/npm \
&& npm config set unsafe-perm true \
&& npm install -g node-gyp

COPY package.json package-lock.json* /opt/auth-service/

COPY package.json package-lock.json* ./
RUN npm ci

COPY . /opt/auth-service
COPY ./ ./
RUN npm run build
RUN rm -rf src secrets test docs
RUN npm prune --production

FROM node:12.16.1-alpine
FROM node:14.15-alpine

WORKDIR /opt/auth-service

# Create empty log file & link stdout to the application log file
RUN mkdir ./logs && touch ./logs/combined.log
RUN ln -sf /dev/stdout ./logs/combined.log

# Create a non-root user: as-user
RUN adduser -D as-user
USER as-user
COPY --chown=as-user --from=builder /opt/auth-service .
# Create a non-root user: ml-user
RUN adduser -D ml-user
USER ml-user
COPY --chown=ml-user --from=builder /opt/auth-service .

# cleanup
RUN npm prune --production
EXPOSE 4004
CMD ["npm", "run", "start"]
9 changes: 9 additions & 0 deletions audit-resolve.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@
"decision": "ignore",
"madeAt": 1634612509200,
"expiresAt": 1637204501456
},
"1004784|hapi-openapi>swagger-parser>@apidevtools/swagger-parser>z-schema>validator": {
"decision": "fix",
"madeAt": 1636084365307
},
"1004784|hapi-swagger>swagger-parser>z-schema>validator": {
"decision": "ignore",
"madeAt": 1636084373888,
"expiresAt": 1638676347746
}
},
"rules": {},
Expand Down
4 changes: 2 additions & 2 deletions config/integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@
"migrations": {
"tableName": "auth-service",
"loadExtensions": [
".ts"
".js"
]
},
"seeds": {
"loadExtensions": [
".ts"
".js"
]
}
}
Expand Down
4 changes: 2 additions & 2 deletions config/production.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@
"migrations": {
"tableName": "auth-service",
"loadExtensions": [
".ts"
".js"
]
},
"seeds": {
"loadExtensions": [
".ts"
".js"
]
}
}
Expand Down
4 changes: 2 additions & 2 deletions config/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"QUOTES_ENDPOINT": "0.0.0.0:3002",
"TRANSFERS_ENDPOINT": "0.0.0.0:3000",
"BULK_TRANSFERS_ENDPOINT": "",
"JWS_SIGN": false,
"JWS_SIGN": true,
"JWS_SIGNING_KEY": "./secrets/jwsSigningKey.key",
"WSO2_AUTH": {
"staticToken": "0706c62f-c022-3c42-8d14-8b5df128876d",
Expand All @@ -29,7 +29,7 @@
},
"TLS": {
"mutualTLS": {
"enabled": false
"enabled": true
},
"creds": {
"ca": "./secrets/client.crt",
Expand Down
Loading

0 comments on commit 1f046f9

Please sign in to comment.