-
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.
Merge pull request #1 from mrc-ide/mrc-6062
mrc-6062 Skeleton app
- Loading branch information
Showing
30 changed files
with
5,232 additions
and
130 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,20 @@ | ||
name: lint, | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- '*' | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22.x | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: lint | ||
run: npm run lint |
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,37 @@ | ||
name: test-and-push, | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- '*' | ||
env: | ||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
jobs: | ||
test-and-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22.x | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Login to GHCR (GitHub Packages) | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build docker image | ||
run: ./docker/build | ||
- name: Push SHA docker image | ||
run: ./docker/push | ||
- name: Run app in docker | ||
run: ./docker/run | ||
- name: Run unit and integration tests | ||
run: npm run test | ||
- name: Push branch docker tag | ||
run: ./docker/push_branch_tag | ||
|
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 |
---|---|---|
@@ -1,130 +1,3 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
node_modules | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
.idea |
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 |
---|---|---|
@@ -1,2 +1,30 @@ | ||
# grout | ||
Geo tile server | ||
Grout serves map tiles (mbtiles) data which can be consumed in web front ends by Leaflet etc. | ||
|
||
## Development | ||
|
||
Grout is implemented as an [express](https://expressjs.com/) server in Typescript. | ||
|
||
Developed with node v22. | ||
|
||
Run in dev mode with hot reloading: `npm run dev` | ||
|
||
Build for production: `npm run build` | ||
|
||
Run in production mode: `npm run prod` | ||
|
||
In both modes, local run is on port 5000. Port is configured in `config/grout.config.json` | ||
|
||
## Tests | ||
|
||
The server needs to be running for the integration tests to pass. | ||
|
||
Run unit and integration tests with `npm run test` | ||
|
||
# Lint | ||
|
||
Run lint with `npm run lint`. To do any possible automatic fixes run `npm run lint-fix`. | ||
|
||
## Docker | ||
See the `docker` folder for Dockerfile and scripts to build, push, run, stop, and push branch tag for the image. The run | ||
script always pulls. The image is pushed to the ghcr.io registry. |
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,5 @@ | ||
// we can also use `import`, but then | ||
// every export should be explicitly defined | ||
|
||
const { fs } = require("memfs"); | ||
module.exports = fs; |
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,3 @@ | ||
{ | ||
"port": 5000 | ||
} |
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 @@ | ||
FROM node:22 | ||
COPY src /src | ||
COPY config /config | ||
COPY package.json package-lock.json tsconfig.json ./ | ||
RUN npm ci | ||
RUN npm run build | ||
ENTRYPOINT ["npm", "run", "prod"] |
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,9 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
HERE=$(dirname $0) | ||
. $HERE/common | ||
|
||
docker build --pull \ | ||
--tag $TAG_SHA \ | ||
-f docker/Dockerfile \ | ||
. |
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,11 @@ | ||
REGISTRY=ghcr.io | ||
PACKAGE_ORG=mrc-ide | ||
PACKAGE_NAME=grout | ||
GIT_SHA=$(git -C "$PACKAGE_ROOT" rev-parse --short=7 HEAD) | ||
if [[ -v "BRANCH_NAME" ]]; then | ||
GIT_BRANCH=${BRANCH_NAME} | ||
else | ||
GIT_BRANCH=$(git symbolic-ref --short HEAD) | ||
fi | ||
TAG_SHA="${REGISTRY}/${PACKAGE_ORG}/${PACKAGE_NAME}:${GIT_SHA}" | ||
TAG_BRANCH="${REGISTRY}/${PACKAGE_ORG}/${PACKAGE_NAME}:${GIT_BRANCH}" |
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 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
HERE=$(dirname $0) | ||
. $HERE/common | ||
|
||
docker push $TAG_SHA |
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 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
HERE=$(dirname $0) | ||
. $HERE/common | ||
|
||
docker tag $TAG_SHA $TAG_BRANCH | ||
docker push $TAG_BRANCH |
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,10 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
HERE=$(dirname $0) | ||
. $HERE/common | ||
|
||
docker run -d --rm \ | ||
--pull=always \ | ||
-p 5000:5000 \ | ||
--name=$PACKAGE_NAME \ | ||
$TAG_SHA |
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 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
HERE=$(dirname $0) | ||
. $HERE/common | ||
|
||
docker rm -f $PACKAGE_NAME | ||
|
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,57 @@ | ||
import pluginJs from "@eslint/js"; | ||
import tseslint from "typescript-eslint"; | ||
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended"; | ||
|
||
/** @type {import('eslint').Linter.Config[]} */ | ||
export default [ | ||
pluginJs.configs.recommended, | ||
...tseslint.configs.recommended, | ||
eslintPluginPrettierRecommended, | ||
{ | ||
files: ["**/*.{js,mjs,cjs,ts}"] | ||
}, | ||
{ | ||
ignores: ["dist/*", "__mocks__/*"] | ||
}, | ||
{ | ||
rules: { | ||
quotes: ["error", "double", { avoidEscape: true }], | ||
"max-len": [2, 120, 4], | ||
"arrow-body-style": "off", | ||
"import/prefer-default-export": "off", | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
"no-plusplus": "off", | ||
"no-shadow": "off", | ||
"@typescript-eslint/no-shadow": ["off"], | ||
"no-underscore-dangle": "off", | ||
"no-unused-vars": "off", | ||
"@typescript-eslint/no-unused-vars": ["error"], | ||
"no-await-in-loop": "off", | ||
"no-useless-concat": "off", | ||
"prettier/prettier": [ | ||
"error", | ||
{ | ||
tabWidth: 4, | ||
semi: true, | ||
useTabs: false, | ||
singleQuote: false, | ||
bracketSpacing: true, | ||
endOfLine: "auto", | ||
arrowParens: "always", | ||
trailingComma: "none" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
files: ["**/*.{test,spec}.?(c|m)[jt]s?(x)"], | ||
rules: { | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/explicit-module-boundary-types": "off", | ||
"@typescript-eslint/no-unused-vars": "off", | ||
"@typescript-eslint/no-empty-function": "off", | ||
"max-classes-per-file": "off", | ||
"no-useless-constructor": "off" | ||
} | ||
} | ||
]; |
Oops, something went wrong.