forked from GoogleContainerTools/skaffold
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement port forwarding for Docker deployer (GoogleContainerTools#6303
- Loading branch information
Showing
26 changed files
with
538 additions
and
137 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
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,17 @@ | ||
### Example: React app with hot-reload | ||
|
||
Simple React app demonstrating the file synchronization mode in conjunction with webpack hot module reload. | ||
|
||
#### Init | ||
|
||
```bash | ||
skaffold dev | ||
``` | ||
|
||
#### Workflow | ||
|
||
* Make some changes to `HelloWorld.js`: | ||
* The file will be synchronized to the cluster | ||
* `webpack` will perform hot module reloading | ||
* Make some changes to `package.json`: | ||
* The full build/push/deploy process will be triggered, fetching dependencies from `npm` |
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,6 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-env", | ||
"@babel/preset-react" | ||
] | ||
} |
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,2 @@ | ||
node_modules | ||
*.swp |
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,2 @@ | ||
/node_modules/ | ||
package-lock.json |
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,10 @@ | ||
FROM node:14.9-alpine | ||
|
||
WORKDIR /app | ||
EXPOSE 8080 | ||
CMD ["npm", "run", "dev"] | ||
|
||
COPY package* ./ | ||
# examples don't use package-lock.json to minimize updates | ||
RUN npm install --no-package-lock | ||
COPY . . |
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 @@ | ||
{ | ||
"name": "react-reload", | ||
"version": "1.0.0", | ||
"description": "A React demo application for skaffold", | ||
"main": "index.js", | ||
"scripts": { | ||
"dev": "webpack-dev-server --mode development --hot" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.11.6", | ||
"@babel/preset-env": "^7.11.5", | ||
"@babel/preset-react": "^7.10.4", | ||
"babel-loader": "^8.1.0", | ||
"css-loader": "^2.1.1", | ||
"html-webpack-plugin": "^3.2.0", | ||
"style-loader": "^0.23.1", | ||
"webpack": "^4.44.1", | ||
"webpack-cli": "^3.3.12", | ||
"webpack-dev-server": "^3.11.0" | ||
}, | ||
"dependencies": { | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1" | ||
}, | ||
"browserslist": "> 2%, not dead" | ||
} |
8 changes: 8 additions & 0 deletions
8
integration/examples/react-reload-docker/app/src/components/HelloWorld.js
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,8 @@ | ||
import React from 'react'; | ||
import '../styles/HelloWorld.css'; | ||
|
||
export const HelloWorld = () => ( | ||
<div> | ||
<h1>Hello world!</h1> | ||
</div> | ||
); |
11 changes: 11 additions & 0 deletions
11
integration/examples/react-reload-docker/app/src/index.html
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,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>React demo app for skaffold</title> | ||
</head> | ||
<body> | ||
<div id="root"/> | ||
</body> | ||
</html> |
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,5 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { HelloWorld } from './components/HelloWorld.js'; | ||
|
||
ReactDOM.render( < HelloWorld/>, document.getElementById( 'root' ) ); |
6 changes: 6 additions & 0 deletions
6
integration/examples/react-reload-docker/app/src/styles/HelloWorld.css
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,6 @@ | ||
h1 { | ||
color: #27aedb; | ||
text-align: center; | ||
margin-top: 40vh; | ||
font-size: 120pt; | ||
} |
27 changes: 27 additions & 0 deletions
27
integration/examples/react-reload-docker/app/webpack.config.js
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,27 @@ | ||
const path = require( 'path' ); | ||
const HtmlWebpackPlugin = require( 'html-webpack-plugin' ); | ||
|
||
module.exports = { | ||
entry: './src/main.js', | ||
output: { | ||
path: path.join( __dirname, '/dist' ), | ||
filename: 'main.js' | ||
}, | ||
devServer:{ | ||
host: '0.0.0.0' | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: [ 'babel-loader' ] | ||
}, | ||
{ | ||
test: /\.css$/, | ||
use: [ 'style-loader', 'css-loader' ] | ||
} | ||
] | ||
}, | ||
plugins: [ new HtmlWebpackPlugin( { template: './src/index.html' } ) ] | ||
}; |
29 changes: 29 additions & 0 deletions
29
integration/examples/react-reload-docker/k8s/deployment.yaml
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,29 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: node | ||
spec: | ||
ports: | ||
- port: 8080 | ||
type: LoadBalancer | ||
selector: | ||
app: node | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: node | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: node | ||
template: | ||
metadata: | ||
labels: | ||
app: node | ||
spec: | ||
containers: | ||
- name: react | ||
image: react-reload-docker | ||
ports: | ||
- containerPort: 8080 |
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,16 @@ | ||
apiVersion: skaffold/v2beta20 | ||
kind: Config | ||
build: | ||
local: | ||
push: false | ||
artifacts: | ||
- image: react-reload-docker | ||
context: app | ||
deploy: | ||
docker: | ||
images: [react-reload-docker] | ||
portForward: | ||
- resourceType: Container | ||
resourceName: react-reload-docker | ||
port: 8080 | ||
localPort: 9000 |
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
Oops, something went wrong.