generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial commit * 🎉 Initial drop of code * 🎨 Small tidy up * Adding circle build and updating node to v14 * Adding helm config * Fix wiremock port and update package.json Co-authored-by: Jon Brighton <[email protected]> Co-authored-by: Jon Brighton <[email protected]>
- Loading branch information
1 parent
2f73e58
commit c89f6f8
Showing
97 changed files
with
15,650 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
version: 2.1 | ||
|
||
orbs: | ||
hmpps: ministryofjustice/[email protected] | ||
|
||
executors: | ||
integration-tests: | ||
docker: | ||
- image: circleci/node:14-buster-browsers | ||
- image: circleci/redis:buster | ||
working_directory: ~/app | ||
builder: | ||
docker: | ||
- image: 'circleci/node:14-buster-browsers' | ||
working_directory: ~/app | ||
|
||
|
||
jobs: | ||
build: | ||
executor: builder | ||
steps: | ||
- checkout | ||
- run: | ||
name: Update npm | ||
command: 'sudo npm install -g npm@latest' | ||
- restore_cache: | ||
key: dependency-cache-{{ checksum "package-lock.json" }} | ||
- run: | ||
name: Install Dependencies | ||
command: npm ci --no-audit | ||
- save_cache: | ||
key: dependency-cache-{{ checksum "package-lock.json" }} | ||
paths: | ||
- node_modules | ||
- ~/.cache | ||
- run: | ||
command: | | ||
npm run build | ||
DATE=$(date '+%Y-%m-%d') | ||
export BUILD_NUMBER=${DATE}.${CIRCLE_BUILD_NUM} | ||
export GIT_REF="$CIRCLE_SHA1" | ||
npm run record-build-info | ||
- run: # Run linter after build because the integration test code depend on compiled typescript... | ||
name: Linter check | ||
command: npm run lint | ||
- persist_to_workspace: | ||
root: . | ||
paths: | ||
- node_modules | ||
- build-info.json | ||
- build | ||
- dist | ||
- .cache/Cypress | ||
|
||
unit_test: | ||
executor: builder | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
key: dependency-cache-{{ checksum "package-lock.json" }} | ||
- run: | ||
name: unit tests | ||
command: npm run test | ||
- store_test_results: | ||
path: test-results | ||
- store_artifacts: | ||
path: test-results/unit-test-reports.html | ||
|
||
integration_test: | ||
executor: integration-tests | ||
steps: | ||
- checkout | ||
- attach_workspace: | ||
at: ~/app | ||
- run: | ||
name: Install missing OS dependency | ||
command: sudo apt-get install libxss1 | ||
- run: | ||
name: Get wiremock | ||
command: curl -o wiremock.jar https://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-standalone/2.27.1/wiremock-standalone-2.27.1.jar | ||
- run: | ||
name: Run wiremock | ||
command: java -jar wiremock.jar --port 9091 | ||
background: true | ||
- run: | ||
name: Run the node app. | ||
command: npm run start-feature | ||
background: true | ||
- run: | ||
name: Wait for node app to start | ||
command: sleep 5 | ||
- restore_cache: | ||
key: dependency-cache-{{ checksum "package-lock.json" }} | ||
- run: | ||
name: integration tests | ||
command: npm run int-test | ||
- store_test_results: | ||
path: test-results | ||
- store_artifacts: | ||
path: integration-tests/videos | ||
- store_artifacts: | ||
path: integration-tests/screenshots | ||
|
||
workflows: | ||
version: 2 | ||
build-test-and-deploy: | ||
jobs: | ||
- build: | ||
filters: | ||
tags: | ||
ignore: /.*/ | ||
- unit_test: | ||
requires: | ||
- build | ||
- integration_test: | ||
requires: | ||
- build | ||
- hmpps/helm_lint: | ||
name: helm_lint | ||
- hmpps/build_docker: | ||
name: build_docker | ||
filters: | ||
branches: | ||
only: | ||
- main | ||
- hmpps/deploy_env: | ||
name: deploy_dev | ||
env: "dev" | ||
filters: | ||
branches: | ||
only: | ||
- main | ||
requires: | ||
- helm_lint | ||
- unit_test | ||
- integration_test | ||
- build_docker | ||
|
||
scheduled: | ||
triggers: | ||
- schedule: | ||
cron: "0 7 * * 1-5" | ||
filters: | ||
branches: | ||
only: | ||
- main | ||
jobs: | ||
- hmpps/npm_security_audit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
dist | ||
kubectl_deploy* | ||
helm_deploy* | ||
README.md | ||
node_modules | ||
npm-debug.log | ||
README.md | ||
.* | ||
**/*.test.js | ||
scss-report.txt | ||
eslint-report.html | ||
test-report.html | ||
docker-compose.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
public | ||
assets | ||
cypress.json | ||
reporter-config.json | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"node": true, | ||
"jest": true | ||
}, | ||
|
||
"plugins": ["import"], | ||
|
||
"settings": { | ||
"import/parsers": { | ||
"@typescript-eslint/parser": [".ts", ".tsx"] | ||
}, | ||
"import/resolver": { | ||
"typescript": { | ||
"alwaysTryTypes": true | ||
}, | ||
"node": { | ||
"extensions": [".js", ".jsx", ".ts", ".tsx", ".json"] | ||
} | ||
} | ||
}, | ||
|
||
"overrides": [ | ||
{ | ||
"plugins": ["@typescript-eslint"], | ||
"parser": "@typescript-eslint/parser", | ||
"files": ["**/*.ts"], | ||
"excludedFiles": "*.js", | ||
"extends": [ | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier/@typescript-eslint", | ||
"plugin:prettier/recommended" | ||
], | ||
"rules": { | ||
"@typescript-eslint/no-use-before-define": 0, | ||
"class-methods-use-this": 0, | ||
"no-useless-constructor": 0, | ||
"@typescript-eslint/no-unused-vars": [ | ||
1, | ||
{ | ||
"argsIgnorePattern": "res|next|^err|_", | ||
"ignoreRestSiblings": true | ||
} | ||
], | ||
"@typescript-eslint/semi": 0, | ||
"import/no-unresolved": "error", | ||
"prettier/prettier": [ | ||
"error", | ||
{ | ||
"trailingComma": "es5", | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"semi": false, | ||
"arrowParens": "avoid" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
|
||
"extends": ["airbnb-base", "plugin:prettier/recommended"], | ||
|
||
"rules": { | ||
"no-unused-vars": [ | ||
1, | ||
{ | ||
"argsIgnorePattern": "res|next|^err|_", | ||
"ignoreRestSiblings": true | ||
} | ||
], | ||
"no-use-before-define": 0, | ||
"semi": 0, | ||
"import/no-unresolved": "error", | ||
"import/extensions": [ | ||
"error", | ||
"ignorePackages", | ||
{ | ||
"js": "never", | ||
"mjs": "never", | ||
"jsx": "never", | ||
"ts": "never", | ||
"tsx": "never" | ||
} | ||
], | ||
"comma-dangle": [ | ||
"error", | ||
{ | ||
"arrays": "always-multiline", | ||
"objects": "always-multiline", | ||
"imports": "always-multiline", | ||
"exports": "always-multiline", | ||
"functions": "never" | ||
} | ||
], | ||
"import/no-extraneous-dependencies": ["error", { "devDependencies": ["**/*.test.js", "**/*.test.ts"] }], | ||
"prettier/prettier": [ | ||
"error", | ||
{ | ||
"trailingComma": "es5", | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"semi": false, | ||
"arrowParens": "avoid" | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.sass-cache | ||
.DS_Store | ||
.start.pid | ||
.port.tmp | ||
public | ||
assets/stylesheets/*.css | ||
lib/govuk_template.html | ||
govuk_modules | ||
node_modules/* | ||
.tmuxp.* | ||
.idea | ||
.vscode | ||
npm-debug.log | ||
build/* | ||
uploads/* | ||
test-results.xml | ||
build-info.json | ||
.env | ||
yarn-error.log | ||
.eslintcache | ||
dist/ | ||
test_results/ | ||
integration_tests/videos/ | ||
integration_tests/screenshots/ | ||
.localstack | ||
*/*.iml | ||
*secrets*.yaml | ||
!secrets-example.yaml | ||
!**/templates/secrets.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"semi": false, | ||
"arrowParens": "avoid" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Build stage 1. | ||
ARG BUILD_NUMBER | ||
ARG GIT_REF | ||
|
||
FROM node:14-buster-slim as base | ||
|
||
LABEL maintainer="HMPPS Digital Studio <[email protected]>" | ||
|
||
ENV TZ=Europe/London | ||
RUN ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone | ||
|
||
RUN addgroup --gid 2000 --system appgroup && \ | ||
adduser --uid 2000 --system appuser --gid 2000 | ||
|
||
WORKDIR /app | ||
|
||
RUN apt-get update && \ | ||
apt-get upgrade -y | ||
|
||
# Build stage 2. | ||
FROM base as build | ||
ARG BUILD_NUMBER | ||
ARG GIT_REF | ||
|
||
RUN apt-get install -y make python g++ | ||
|
||
COPY . . | ||
|
||
ENV BUILD_NUMBER ${BUILD_NUMBER:-1_0_0} | ||
ENV GIT_REF ${GIT_REF:-dummy} | ||
|
||
RUN CYPRESS_INSTALL_BINARY=0 npm ci --no-audit && npm run build && \ | ||
export BUILD_NUMBER=${BUILD_NUMBER} && \ | ||
export GIT_REF=${GIT_REF} && \ | ||
npm run record-build-info | ||
|
||
# Build stage 3. | ||
FROM base | ||
|
||
RUN apt-get autoremove -y && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=build --chown=appuser:appgroup \ | ||
/app/package.json \ | ||
/app/package-lock.json \ | ||
/app/dist \ | ||
/app/build-info.json \ | ||
./ | ||
|
||
COPY --from=build --chown=appuser:appgroup \ | ||
/app/build ./build | ||
|
||
COPY --from=build --chown=appuser:appgroup \ | ||
/app/node_modules ./node_modules | ||
|
||
COPY --from=build --chown=appuser:appgroup \ | ||
/app/views ./views | ||
|
||
RUN npm prune --production | ||
|
||
EXPOSE 3000 | ||
USER 2000 | ||
|
||
CMD [ "npm", "start" ] |
Oops, something went wrong.