@cdklabs/deploy-time-build 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +2 -2
- package/lib/container-image-build.js +1 -1
- package/lib/nodejs-build.js +1 -1
- package/lib/soci-index-build.js +1 -1
- package/lib/soci-index-v2-build.js +1 -1
- package/package.json +1 -1
- package/example/README.md +0 -18
- package/example/cdk.json +0 -3
- package/example/example-app/index.html +0 -12
- package/example/example-app/package-lock.json +0 -1804
- package/example/example-app/package.json +0 -21
- package/example/example-app/src/App.css +0 -42
- package/example/example-app/src/App.tsx +0 -43
- package/example/example-app/src/index.css +0 -13
- package/example/example-app/src/main.tsx +0 -10
- package/example/example-app/src/vite.env.d.ts +0 -1
- package/example/example-app/tsconfig.json +0 -21
- package/example/example-app/tsconfig.node.json +0 -8
- package/example/example-app/vite.config.ts +0 -7
- package/example/example-image/Dockerfile +0 -6
- package/example/index.ts +0 -156
- package/imgs/architecture.png +0 -0
- package/imgs/demo.png +0 -0
- package/imgs/soci-architecture.png +0 -0
- package/lambda/trigger-codebuild/package-lock.json +0 -2904
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "example-app",
|
|
3
|
-
"private": true,
|
|
4
|
-
"version": "0.0.0",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"dev": "vite",
|
|
7
|
-
"build": "tsc && vite build",
|
|
8
|
-
"preview": "vite preview"
|
|
9
|
-
},
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"react": "^18.0.0",
|
|
12
|
-
"react-dom": "^18.0.0"
|
|
13
|
-
},
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"@types/react": "^18.0.0",
|
|
16
|
-
"@types/react-dom": "^18.0.0",
|
|
17
|
-
"@vitejs/plugin-react": "^5",
|
|
18
|
-
"typescript": "^5",
|
|
19
|
-
"vite": "^7"
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
.App {
|
|
2
|
-
text-align: center;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.App-logo {
|
|
6
|
-
height: 40vmin;
|
|
7
|
-
pointer-events: none;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
@media (prefers-reduced-motion: no-preference) {
|
|
11
|
-
.App-logo {
|
|
12
|
-
animation: App-logo-spin infinite 20s linear;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.App-header {
|
|
17
|
-
background-color: #282c34;
|
|
18
|
-
min-height: 100vh;
|
|
19
|
-
display: flex;
|
|
20
|
-
flex-direction: column;
|
|
21
|
-
align-items: center;
|
|
22
|
-
justify-content: center;
|
|
23
|
-
font-size: calc(10px + 2vmin);
|
|
24
|
-
color: white;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.App-link {
|
|
28
|
-
color: #61dafb;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@keyframes App-logo-spin {
|
|
32
|
-
from {
|
|
33
|
-
transform: rotate(0deg);
|
|
34
|
-
}
|
|
35
|
-
to {
|
|
36
|
-
transform: rotate(360deg);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
button {
|
|
41
|
-
font-size: calc(10px + 2vmin);
|
|
42
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react'
|
|
2
|
-
import './App.css'
|
|
3
|
-
|
|
4
|
-
function App() {
|
|
5
|
-
const [count, setCount] = useState(0)
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
<div className="App">
|
|
9
|
-
<header className="App-header">
|
|
10
|
-
<p>Hello Vite + React!</p>
|
|
11
|
-
<p>
|
|
12
|
-
<button type="button" onClick={() => setCount((count) => count + 1)}>
|
|
13
|
-
count is: {count}
|
|
14
|
-
</button>
|
|
15
|
-
</p>
|
|
16
|
-
<p>
|
|
17
|
-
Your API endpoint: <code>{import.meta.env.VITE_API_ENDPOINT ?? 'undefined'}</code>
|
|
18
|
-
</p>
|
|
19
|
-
<p>
|
|
20
|
-
<a
|
|
21
|
-
className="App-link"
|
|
22
|
-
href="https://reactjs.org"
|
|
23
|
-
target="_blank"
|
|
24
|
-
rel="noopener noreferrer"
|
|
25
|
-
>
|
|
26
|
-
Learn React
|
|
27
|
-
</a>
|
|
28
|
-
{' | '}
|
|
29
|
-
<a
|
|
30
|
-
className="App-link"
|
|
31
|
-
href="https://vitejs.dev/guide/features.html"
|
|
32
|
-
target="_blank"
|
|
33
|
-
rel="noopener noreferrer"
|
|
34
|
-
>
|
|
35
|
-
Vite Docs
|
|
36
|
-
</a>
|
|
37
|
-
</p>
|
|
38
|
-
</header>
|
|
39
|
-
</div>
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default App
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
body {
|
|
2
|
-
margin: 0;
|
|
3
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
4
|
-
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
5
|
-
sans-serif;
|
|
6
|
-
-webkit-font-smoothing: antialiased;
|
|
7
|
-
-moz-osx-font-smoothing: grayscale;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
code {
|
|
11
|
-
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
|
12
|
-
monospace;
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
6
|
-
"allowJs": false,
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
"esModuleInterop": false,
|
|
9
|
-
"allowSyntheticDefaultImports": true,
|
|
10
|
-
"strict": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"module": "ESNext",
|
|
13
|
-
"moduleResolution": "Node",
|
|
14
|
-
"resolveJsonModule": true,
|
|
15
|
-
"isolatedModules": true,
|
|
16
|
-
"noEmit": true,
|
|
17
|
-
"jsx": "react-jsx"
|
|
18
|
-
},
|
|
19
|
-
"include": ["src"],
|
|
20
|
-
"references": [{ "path": "./tsconfig.node.json" }]
|
|
21
|
-
}
|
package/example/index.ts
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { App, CfnOutput, Stack, StackProps } from 'aws-cdk-lib';
|
|
2
|
-
import { MockIntegration, RestApi } from 'aws-cdk-lib/aws-apigateway';
|
|
3
|
-
import { AllowedMethods, Distribution, OriginRequestPolicy, SecurityPolicyProtocol, SSLMethod, ViewerProtocolPolicy } from 'aws-cdk-lib/aws-cloudfront';
|
|
4
|
-
import { S3BucketOrigin } from 'aws-cdk-lib/aws-cloudfront-origins';
|
|
5
|
-
import { SubnetType, Vpc } from 'aws-cdk-lib/aws-ec2';
|
|
6
|
-
import { DockerImageAsset, Platform } from 'aws-cdk-lib/aws-ecr-assets';
|
|
7
|
-
import { AwsLogDriver, Cluster, ContainerImage, CpuArchitecture, FargateTaskDefinition } from 'aws-cdk-lib/aws-ecs';
|
|
8
|
-
import { DockerImageFunction } from 'aws-cdk-lib/aws-lambda';
|
|
9
|
-
import { BlockPublicAccess, Bucket, BucketEncryption } from 'aws-cdk-lib/aws-s3';
|
|
10
|
-
import { Construct } from 'constructs';
|
|
11
|
-
import { ContainerImageBuild, NodejsBuild, SociIndexBuild, SociIndexV2Build } from '../src/';
|
|
12
|
-
|
|
13
|
-
class NodejsTestStack extends Stack {
|
|
14
|
-
constructor(scope: Construct, id: string, props: StackProps = {}) {
|
|
15
|
-
super(scope, id, props);
|
|
16
|
-
|
|
17
|
-
const api = new RestApi(this, 'ExampleApi');
|
|
18
|
-
api.root.addMethod(
|
|
19
|
-
'ANY',
|
|
20
|
-
new MockIntegration({
|
|
21
|
-
integrationResponses: [{ statusCode: '200' }],
|
|
22
|
-
requestTemplates: {
|
|
23
|
-
'application/json': '{ "statusCode": 200 }',
|
|
24
|
-
},
|
|
25
|
-
}),
|
|
26
|
-
{
|
|
27
|
-
methodResponses: [{ statusCode: '200' }],
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
const dstBucket = new Bucket(this, 'DstBucket', {
|
|
32
|
-
// autoDeleteObjects: true,
|
|
33
|
-
// removalPolicy: RemovalPolicy.DESTROY,
|
|
34
|
-
blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
|
|
35
|
-
encryption: BucketEncryption.S3_MANAGED,
|
|
36
|
-
});
|
|
37
|
-
const dstPath = '/';
|
|
38
|
-
|
|
39
|
-
const distribution = new Distribution(this, "distribution", {
|
|
40
|
-
defaultRootObject: "index.html",
|
|
41
|
-
defaultBehavior: {
|
|
42
|
-
origin: S3BucketOrigin.withOriginAccessControl(dstBucket),
|
|
43
|
-
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
44
|
-
allowedMethods: AllowedMethods.ALLOW_ALL,
|
|
45
|
-
originRequestPolicy: OriginRequestPolicy.CORS_S3_ORIGIN,
|
|
46
|
-
},
|
|
47
|
-
minimumProtocolVersion: SecurityPolicyProtocol.TLS_V1_2_2021,
|
|
48
|
-
sslSupportMethod: SSLMethod.SNI,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
new CfnOutput(this, 'DistributionUrl', {
|
|
52
|
-
value: `https://${distribution.distributionDomainName}`,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
new NodejsBuild(this, 'ExampleBuild', {
|
|
56
|
-
assets: [
|
|
57
|
-
{
|
|
58
|
-
path: 'example-app',
|
|
59
|
-
exclude: ['dist', 'node_modules'],
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
destinationBucket: dstBucket,
|
|
63
|
-
destinationKeyPrefix: dstPath,
|
|
64
|
-
outputSourceDirectory: 'dist',
|
|
65
|
-
distribution,
|
|
66
|
-
buildCommands: ['npm ci', 'npm run build'],
|
|
67
|
-
buildEnvironment: {
|
|
68
|
-
VITE_API_ENDPOINT: api.url,
|
|
69
|
-
AAA: 'asdf',
|
|
70
|
-
BBB: dstBucket.bucketName,
|
|
71
|
-
},
|
|
72
|
-
nodejsVersion: 20,
|
|
73
|
-
outputEnvFile: true,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
class SociIndexTestStack extends Stack {
|
|
79
|
-
constructor(scope: Construct, id: string, props: StackProps = {}) {
|
|
80
|
-
super(scope, id, props);
|
|
81
|
-
|
|
82
|
-
const asset = new DockerImageAsset(this, 'Image', { directory: 'example-image', platform: Platform.LINUX_AMD64 });
|
|
83
|
-
|
|
84
|
-
new SociIndexBuild(this, 'Index', { imageTag: asset.assetHash, repository: asset.repository });
|
|
85
|
-
|
|
86
|
-
new Cluster(this, 'Cluster', {
|
|
87
|
-
vpc: new Vpc(this, 'Vpc', {
|
|
88
|
-
maxAzs: 1,
|
|
89
|
-
subnetConfiguration: [
|
|
90
|
-
{
|
|
91
|
-
cidrMask: 24,
|
|
92
|
-
name: 'public',
|
|
93
|
-
subnetType: SubnetType.PUBLIC,
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
}),
|
|
97
|
-
});
|
|
98
|
-
new FargateTaskDefinition(this, 'TaskDefinition', {}).addContainer('main', {
|
|
99
|
-
image: ContainerImage.fromEcrRepository(asset.repository, asset.assetHash),
|
|
100
|
-
|
|
101
|
-
logging: new AwsLogDriver({ streamPrefix: 'main' }),
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
const v2 = SociIndexV2Build.fromDockerImageAsset(this, 'IndexV2', asset);
|
|
105
|
-
|
|
106
|
-
new FargateTaskDefinition(this, 'TaskDefinitionV2', {}).addContainer('main', {
|
|
107
|
-
image: v2.toEcsDockerImageCode(),
|
|
108
|
-
logging: new AwsLogDriver({ streamPrefix: 'main' }),
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
class ContainerImageTestStack extends Stack {
|
|
114
|
-
constructor(scope: Construct, id: string, props: StackProps = {}) {
|
|
115
|
-
super(scope, id, props);
|
|
116
|
-
|
|
117
|
-
const image = new ContainerImageBuild(this, 'Build', { directory: 'example-image', buildArgs: { DUMMY_FILE_SIZE_MB: '15' } });
|
|
118
|
-
const armImage = new ContainerImageBuild(this, 'BuildArm', {
|
|
119
|
-
directory: 'example-image',
|
|
120
|
-
platform: Platform.LINUX_ARM64,
|
|
121
|
-
repository: image.repository,
|
|
122
|
-
zstdCompression: true,
|
|
123
|
-
});
|
|
124
|
-
new DockerImageFunction(this, 'Function', {
|
|
125
|
-
code: image.toLambdaDockerImageCode(),
|
|
126
|
-
});
|
|
127
|
-
new Cluster(this, 'Cluster', {
|
|
128
|
-
vpc: new Vpc(this, 'Vpc', {
|
|
129
|
-
maxAzs: 1,
|
|
130
|
-
subnetConfiguration: [
|
|
131
|
-
{
|
|
132
|
-
cidrMask: 24,
|
|
133
|
-
name: 'public',
|
|
134
|
-
subnetType: SubnetType.PUBLIC,
|
|
135
|
-
},
|
|
136
|
-
],
|
|
137
|
-
}),
|
|
138
|
-
});
|
|
139
|
-
new FargateTaskDefinition(this, 'TaskDefinition', { runtimePlatform: { cpuArchitecture: CpuArchitecture.ARM64 } }).addContainer('main', {
|
|
140
|
-
image: armImage.toEcsDockerImageCode(),
|
|
141
|
-
logging: new AwsLogDriver({ streamPrefix: 'main' }),
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
class TestApp extends App {
|
|
147
|
-
constructor() {
|
|
148
|
-
super();
|
|
149
|
-
|
|
150
|
-
new NodejsTestStack(this, 'NodejsTestStack');
|
|
151
|
-
new SociIndexTestStack(this, 'SociIndexTestStack');
|
|
152
|
-
new ContainerImageTestStack(this, 'ContainerImageTestStack');
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
new TestApp().synth();
|
package/imgs/architecture.png
DELETED
|
Binary file
|
package/imgs/demo.png
DELETED
|
Binary file
|
|
Binary file
|