Skip to content

Commit 0f2e3e1

Browse files
committed
Created container deploy script
1 parent 6bfe3a5 commit 0f2e3e1

7 files changed

Lines changed: 85 additions & 7 deletions

File tree

.github/workflows/container.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: deploy-container
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
path:
8+
- 'packages/container/**'
9+
10+
defaults:
11+
run:
12+
working-directory: packages/container
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
- run: npm install
21+
- run: npm run build
22+
23+
- uses: shinyinc/action-aws-cli@v1.2
24+
- run: aws s3 sync dist s3://${{ secrets.AWS_S3_BUCKET_NAME }}/container/latest
25+
env:
26+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
27+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
28+
AWS_DEFAULT_REGION: ""

packages/container/config/webpack.common.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const HtmlWebpackPlugin = require('html-webpack-plugin')
12
module.exports = {
23
module: {
34
rules: [
@@ -13,5 +14,10 @@ module.exports = {
1314
}
1415
}
1516
]
16-
}
17+
},
18+
plugins: [
19+
new HtmlWebpackPlugin({
20+
template: './public/index.html'
21+
})
22+
]
1723
}

packages/container/config/webpack.dev.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const { merge } = require('webpack-merge')
2-
const HtmlWebpackPlugin = require('html-webpack-plugin')
32
const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin')
43
const commonConfig = require('./webpack.common')
54
const packageJson = require('../package.json')
@@ -22,9 +21,7 @@ const devConfig = {
2221
},
2322
shared: packageJson.dependencies,
2423
}),
25-
new HtmlWebpackPlugin({
26-
template: './public/index.html'
27-
})
24+
2825
]
2926
}
3027

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const { merge } = require('webpack-merge')
2+
const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin')
3+
const commonConfig = require('./webpack.common')
4+
const packageJson = require('../package.json')
5+
6+
const domain = process.env.PRODUCTION_DOMAIN
7+
8+
const prodConfig = {
9+
mode: "production",
10+
output: {
11+
filename: '[name].[contenthash].js'
12+
},
13+
plugins: [
14+
new ModuleFederationPlugin({
15+
name: 'container',
16+
remotes: {
17+
marketingPage: `marketing@${domain}/marketing/remoteEntry.js`
18+
},
19+
shared: packageJson.dependencies
20+
})
21+
]
22+
}
23+
module.exports = merge(commonConfig, prodConfig)

packages/container/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "container",
33
"version": "1.0.0",
44
"scripts": {
5-
"start": "webpack serve --config config/webpack.dev.js"
5+
"start": "webpack serve --config config/webpack.dev.js",
6+
"build": "webpack --config config/webpack.prod.js"
67
},
78
"dependencies": {
89
"@material-ui/core": "^4.11.0",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const { merge } = require('webpack-merge')
2+
const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin')
3+
const commonConfig = require('./webpack.common')
4+
const packageJson = require('../package.json')
5+
6+
const prodConfig = {
7+
mode: 'production',
8+
output: {
9+
filename: '[name].[contenthash].js'
10+
},
11+
plugins: [
12+
new ModuleFederationPlugin({
13+
name: 'marketing',
14+
filename: 'remoteEntry.js',
15+
exposes: {
16+
'./MarketingApp': './src/bootstrap'
17+
},
18+
shared: packageJson.dependencies
19+
})
20+
]
21+
}
22+
module.exports = merge(commonConfig, prodConfig)

packages/marketing/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "marketing",
33
"version": "1.0.0",
44
"scripts": {
5-
"start": "webpack serve --config config/webpack.dev.js"
5+
"start": "webpack serve --config config/webpack.dev.js",
6+
"build": "webpack --config config/webpack.prod.js"
67
},
78
"dependencies": {
89
"@material-ui/core": "^4.11.0",

0 commit comments

Comments
 (0)