Skip to content

Commit

Permalink
add cdk files
Browse files Browse the repository at this point in the history
  • Loading branch information
gugzkumar committed Apr 12, 2019
1 parent 10c1f77 commit 8be0bd9
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 0 deletions.
44 changes: 44 additions & 0 deletions client-ui/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc

# dependencies
/node_modules

# profiling files
chrome-profiler-events.json
speed-measure-plugin.json

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db
19 changes: 19 additions & 0 deletions client-ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:10.15.0-alpine
ENV HOME=/usr/src/app

# Create simple server that hosts compiled Angular Resources
WORKDIR $HOME
COPY ./package.json $HOME/
RUN npm install --quiet
RUN node simple-server.js &

#Set up angular code and dependencies
WORKDIR $HOME/angular-code
COPY ./angular-code/package.json $HOME/angular-code
RUN npm install --quiet
COPY . $HOME
EXPOSE 4200
WORKDIR $HOME/angular-code

# Main container process builds angular code to angular-output/ folder
CMD node ../simple-server.js & npm run build
34 changes: 34 additions & 0 deletions client-ui/client-ui-construct.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import cdk = require('@aws-cdk/cdk');
import s3 = require('@aws-cdk/aws-s3');
import s3Deploy = require('@aws-cdk/aws-s3-deployment');
import {CloudFrontWebDistribution} from '@aws-cdk/aws-cloudfront';

export class ClientUIConstruct extends cdk.Construct {
constructor(parent: cdk.Construct, name: string) {
super(parent, name);
const clientUIAssetsBucket = new s3.Bucket(this, 'Client UI Assets Bucket', {
websiteIndexDocument: 'index.html',
websiteErrorDocument: 'error.html',
removalPolicy: cdk.RemovalPolicy.Destroy
});
clientUIAssetsBucket.grantPublicAccess('*', 's3:GetObject');

new s3Deploy.BucketDeployment(this, 'Client UI Deployment', {
source: s3Deploy.Source.asset('client-ui/assets'),
destinationBucket: clientUIAssetsBucket
});

new CloudFrontWebDistribution(this, 'Client UI CDN Distribution', {
originConfigs: [
{
s3OriginSource: {
s3BucketSource: clientUIAssetsBucket
},
behaviors : [ {isDefaultBehavior: true}],

}
]
});

}
}
15 changes: 15 additions & 0 deletions client-ui/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "simple-server.js",
"dependencies": {
"express": "^4.16.4"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
4 changes: 4 additions & 0 deletions client-ui/simple-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var express = require('express');
var app = express();
app.use(express.static('../angular-output'));
app.listen(4200);

0 comments on commit 8be0bd9

Please sign in to comment.