Skip to content

Commit

Permalink
Merge pull request #1 from nasa/KMS-511
Browse files Browse the repository at this point in the history
KMS-511: Deploying basic serverless app to house KMS functionality
  • Loading branch information
cgokey authored Jan 30, 2025
2 parents bab03b5 + 67a2635 commit 790666b
Show file tree
Hide file tree
Showing 25 changed files with 22,468 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
.eslintrc
54 changes: 54 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
// Let eslint know were working as a browser to allow the standard globals (document, window, etc.)
"env": {
"browser": true,
"es2021": true,
"node": true,
"jest": true
},

"overrides": [
{
"files": [ "**/__tests__/**/*.js?(x)" ],
"extends": ["plugin:testing-library/react"]
}
],

"extends": [
"@edsc"
],

// Define version settings
"settings": {
"react": {
"pragma": "React",
"version": "detect"
},
"import/resolver": {
"alias": {
"map": [
[ "@", "./static/src" ]
],
"extensions": [
".js",
".jsx",
".json"
]
}
}
},

"parserOptions": {
"requireConfigFile": false,
"babelOptions": {
"presets": [
"@babel/preset-react"
]
}
},

// Define any global variables to avoid no-undef errors
"globals": {
"vi": "readonly"
}
}
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Project build files
.dockerignore
.DS_Store
.serverless
.esbuild
.vite
coverage
dist
doc
Dockerfile
node_modules
secret.config.json
tmp
.env

# VSCode Settings
.vscode

# CI Outputs
junit.xml

cmr
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/hydrogen
1 change: 1 addition & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs/**/*.css
36 changes: 36 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"customSyntax": "postcss-scss",
"extends": [
"stylelint-config-standard",
"stylelint-config-idiomatic-order"
],
"plugins": [
"stylelint-scss"
],
"rules": {
"at-rule-no-unknown": null,
"import-notation": "string",
"keyframes-name-pattern": "[a-zA-Z]",
"no-invalid-position-at-import-rule": null,
"property-no-unknown": [
true,
{
"ignoreProperties": ["composes", "compose-with"]
}
],
"scss/at-rule-no-unknown": true,
"selector-class-pattern": "[a-zA-Z]",
"selector-pseudo-class-no-unknown": [
true,
{
"ignorePseudoClasses": ["global"]
}
],
"value-keyword-case": [
"lower",
{
"ignoreKeywords": ["/[a-zA-Z]/"]
}
]
}
}
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
Simple README for deploying KMS
# KMS 2.0

Keyword Management System (KMS) is a application for maintaining keywords (science keywords, platforms, instruments, data centers, locations, projects, services, resolution, etc.) in the earthdata/IDN system.

## Links

## Getting Started

### Requirements

- [Node](https://nodejs.org/) (check .nvmrc for correct version)
- [nvm](https://github.com/nvm-sh/nvm) is highly recommended

### Setup

To install the necessary components, run:

```bash
npm install
```

### Usage

In order to run KMS locally, you first need to setup a RDF database.

#### Running Serverless Offline (API Gateway/Lambdas)

In order to run serverless-offline, which is used for mimicking API Gateway to call lambda functions, run:

```bash
npm run offline
```

## Local Testing

To run the test suite, run:

```bash
npm run test
```

59 changes: 59 additions & 0 deletions bin/deploy-bamboo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# Bail on unset variables, errors and trace execution
set -eux

# Set up Docker image
#####################

cat <<EOF > .dockerignore
node_modules
.DS_Store
.git
.github
.serverless
cmr
coverage
dist
node_modules
tmp
EOF

cat <<EOF > Dockerfile
FROM node:18-bullseye
COPY . /build
WORKDIR /build
RUN npm ci --omit=dev && npm run build
EOF
export bamboo_STAGE_NAME=sit
dockerTag=kms-$bamboo_STAGE_NAME
docker build -t $dockerTag .

# Convenience function to invoke `docker run` with appropriate env vars instead of baking them into image
dockerRun() {
docker run \
--env "AWS_ACCESS_KEY_ID=$bamboo_AWS_ACCESS_KEY_ID" \
--env "AWS_SECRET_ACCESS_KEY=$bamboo_AWS_SECRET_ACCESS_KEY" \
--env "AWS_SESSION_TOKEN=$bamboo_AWS_SESSION_TOKEN" \
--env "LAMBDA_TIMEOUT=$bamboo_LAMBDA_TIMEOUT" \
--env "NODE_ENV=sit" \
--env "NODE_OPTIONS=--max_old_space_size=4096" \
--env "SUBNET_ID_A=$bamboo_SUBNET_ID_A" \
--env "SUBNET_ID_B=$bamboo_SUBNET_ID_B" \
--env "SUBNET_ID_C=$bamboo_SUBNET_ID_C" \
--env "VPC_ID=$bamboo_VPC_ID" \
$dockerTag "$@"
}

# Execute serverless commands in Docker
#######################################

stageOpts="--stage $bamboo_STAGE_NAME"

# Deploy AWS Infrastructure Resources
echo 'Deploying AWS Infrastructure Resources...'
dockerRun npx serverless deploy $stageOpts --config serverless-infrastructure.yml

# Deploy AWS Application Resources
echo 'Deploying AWS Application Resources...'
dockerRun npx serverless deploy $stageOpts
Loading

0 comments on commit 790666b

Please sign in to comment.