-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KMS-510: cdk infrastructure code for deploying rdf4j (#2)
* KMS-510: cdk infrastructure code for deploying rdf4j --------- Co-authored-by: Christopher Gokey <christopher.d.gokey@nasa.gov>
- Loading branch information
Showing
18 changed files
with
1,137 additions
and
29 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,99 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: {} | ||
|
||
jobs: | ||
eslint: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: ['lts/hydrogen'] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Cache node modules | ||
uses: actions/cache@v4 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
# npm cache files are stored in `~/.npm` on Linux/macOS | ||
# not caching node_modules because `npm ci` removes it | ||
path: ~/.npm | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Run eslint | ||
run: npm run lint | ||
vitest: | ||
needs: [eslint] | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: ['lts/hydrogen'] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Cache node modules | ||
uses: actions/cache@v4 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
# npm cache files are stored in `~/.npm` on Linux/macOS | ||
# not caching node_modules because `npm ci` removes it | ||
path: ~/.npm | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Run Vitest tests | ||
run: npm run test | ||
- name: Upload coverage to codecov | ||
uses: codecov/codecov-action@v4 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
tests-passed: | ||
needs: [vitest] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: All Tests Have Passed | ||
run: 'echo true' | ||
|
||
sync: | ||
if: success() && github.ref == 'refs/heads/main' # only run on main success | ||
needs: [tests-passed] # only run after vitest and cypress jobs complete | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Install SSH key | ||
uses: shimataro/ssh-key-action@v2 | ||
with: | ||
key: ${{ secrets.SSH_KEY }} | ||
known_hosts: ${{ secrets.KNOWN_HOSTS }} | ||
- name: Push to ECC | ||
run: | | ||
git remote add ecc ssh://git@git.earthdata.nasa.gov:7999/kms/kms.git | ||
git fetch ecc "+refs/heads/*:refs/remotes/origin/*" | ||
git fetch --unshallow || true | ||
echo "GITHUB_COMMIT=$GITHUB_SHA" | ||
git push ecc $GITHUB_SHA:refs/heads/main |
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
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
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,4 @@ | ||
FROM node:18-bullseye | ||
COPY . /build | ||
WORKDIR /build | ||
RUN npm ci --omit=dev && npm run build |
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,26 @@ | ||
#!/bin/bash | ||
|
||
# Set variables | ||
REPO_NAME="rdf4j" | ||
REGION="us-east-1" | ||
DOCKER_FILE_PATH="../../docker" | ||
|
||
# Create ECR repository | ||
aws ecr create-repository --repository-name $REPO_NAME --region "us-east-1" | ||
|
||
# Get the repository URI | ||
REPO_URI=$(aws ecr describe-repositories --repository-names $REPO_NAME --region $REGION --query 'repositories[0].repositoryUri' --output text) | ||
|
||
# Authenticate Docker to ECR | ||
aws ecr get-login-password --region $REGION | docker login --username AWS --password-stdin $REPO_URI | ||
|
||
# Build Docker image | ||
docker build -t $REPO_NAME $DOCKER_FILE_PATH | ||
|
||
# Tag the image | ||
docker tag $REPO_NAME:latest $REPO_URI:latest | ||
|
||
# Push the image to ECR | ||
docker push $REPO_URI:latest | ||
|
||
echo "Docker image pushed to $REPO_URI:latest" |
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,44 @@ | ||
#!/usr/bin/env node | ||
const cdk = require('aws-cdk-lib') | ||
const { EcsStack } = require('../lib/ecs-stack') | ||
const { EfsStack } = require('../lib/efs-stack') | ||
const { IamStack } = require('../lib/iam-stack') | ||
|
||
async function main() { | ||
const app = new cdk.App() | ||
|
||
const env = { | ||
account: process.env.CDK_DEFAULT_ACCOUNT, | ||
region: process.env.CDK_DEFAULT_REGION | ||
} | ||
|
||
const vpcId = process.env.VPC_ID | ||
|
||
const iamStack = new IamStack(app, 'rdf4jIamStack', { | ||
env, | ||
vpcId | ||
}) | ||
const efsStack = new EfsStack(app, 'rdf4jEfsStack', { | ||
env, | ||
vpcId, | ||
efsTaskSecurityGroup: iamStack.efsTaskSecurityGroup | ||
}) | ||
|
||
const ecsStack = new EcsStack(app, 'rdf4jEcsStack', { | ||
env, | ||
vpcId, | ||
role: iamStack.role, | ||
ecsTasksSecurityGroup: efsStack.ecsTasksSecurityGroup, | ||
fileSystem: efsStack.fileSystem, | ||
accessPoint: efsStack.accessPoint | ||
}) | ||
|
||
// Add dependencies | ||
efsStack.addDependency(iamStack) | ||
ecsStack.addDependency(iamStack) | ||
ecsStack.addDependency(efsStack) | ||
|
||
app.synth() | ||
} | ||
|
||
main() |
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 @@ | ||
{ | ||
"app": "node bin/rdf4j-aws-deployment.js" | ||
} |
Oops, something went wrong.