Browse Source

[+Ina] Adds Docker for prod only

Camilla 2 years ago
parent
commit
9ddaab01c2

+ 12 - 1
docker/README.md

@@ -46,6 +46,16 @@ docker image rm -f [image-name-or-id]
46 46
 docker rm -f [container-id]
47 47
 ```
48 48
 
49
+- Navigate into container
50
+```
51
+docker exec -it [container-id] bash
52
+```
53
+
54
+- Inspect a container
55
+```
56
+docker inspect [container-id]
57
+```
58
+
49 59
 ## Create your own image
50 60
 
51 61
 ```
@@ -90,6 +100,7 @@ docker-compose logs -f [service]
90 100
 ```
91 101
 
92 102
 ## Resources
93
-- [Create-react-app and Docker](http://start.jcolemorrison.com/no-eject-create-react-app-with-sass-storybook-and-yarn-in-a-docker-environment/)
103
+- [React and Docker only in production](https://medium.com/@patriciolpezjuri/using-create-react-app-with-react-router-express-js-8fa658bf892d)
104
+- [Create-react-app and Docker in dev/production](http://start.jcolemorrison.com/no-eject-create-react-app-with-sass-storybook-and-yarn-in-a-docker-environment/)
94 105
 - [Webpack and Docker](https://medium.com/@andyccs/webpack-and-docker-for-development-and-deployment-ae0e73243db4)
95 106
 - [Docker Volumes](http://container-solutions.com/understanding-volumes-docker/)

docker/create-react-app-docker/Dockerfile → docker/docker-for-dev/Dockerfile


docker/create-react-app-docker/app/.gitignore → docker/docker-for-dev/app/.gitignore


docker/create-react-app-docker/app/README.md → docker/docker-for-dev/app/README.md


docker/create-react-app-docker/app/package.json → docker/docker-for-dev/app/package.json


docker/create-react-app-docker/app/public/favicon.ico → docker/docker-for-dev/app/public/favicon.ico


docker/create-react-app-docker/app/public/index.html → docker/docker-for-dev/app/public/index.html


docker/create-react-app-docker/app/src/App.css → docker/docker-for-dev/app/src/App.css


docker/create-react-app-docker/app/src/App.js → docker/docker-for-dev/app/src/App.js


docker/create-react-app-docker/app/src/App.test.js → docker/docker-for-dev/app/src/App.test.js


docker/create-react-app-docker/app/src/index.css → docker/docker-for-dev/app/src/index.css


docker/create-react-app-docker/app/src/index.js → docker/docker-for-dev/app/src/index.js


docker/create-react-app-docker/app/src/logo.svg → docker/docker-for-dev/app/src/logo.svg


docker/create-react-app-docker/app/yarn.lock → docker/docker-for-dev/app/yarn.lock


docker/create-react-app-docker/docker-compose.yml → docker/docker-for-dev/docker-compose.yml


+ 18 - 0
docker/docker-for-prod-only/.gitignore

@@ -0,0 +1,18 @@
1
+# See https://help.github.com/ignore-files/ for more about ignoring files.
2
+
3
+# dependencies
4
+/node_modules
5
+
6
+# testing
7
+/coverage
8
+
9
+# production
10
+/build
11
+
12
+# misc
13
+.DS_Store
14
+.env
15
+npm-debug.log*
16
+yarn-debug.log*
17
+yarn-error.log*
18
+

+ 24 - 0
docker/docker-for-prod-only/Dockerfile

@@ -0,0 +1,24 @@
1
+# Dockerfile
2
+FROM node:6
3
+
4
+# Install Http-server globally
5
+RUN npm install http-server -g
6
+
7
+# Create app directory
8
+RUN mkdir -p /usr/src/app
9
+WORKDIR /usr/src/app
10
+
11
+# Install app dependencies
12
+COPY package.json /usr/src/app/
13
+RUN npm install
14
+
15
+# Bundle app source
16
+COPY . /usr/src/app
17
+
18
+# Build and optimize react app
19
+RUN npm run build
20
+
21
+EXPOSE 8080
22
+
23
+# defined in package.json
24
+CMD [ "npm", "run", "start:server" ]

File diff suppressed because it is too large
+ 1623 - 0
docker/docker-for-prod-only/README.md


+ 19 - 0
docker/docker-for-prod-only/package.json

@@ -0,0 +1,19 @@
1
+{
2
+  "name": "react-app-prod",
3
+  "version": "0.1.0",
4
+  "private": true,
5
+  "devDependencies": {
6
+    "react-scripts": "0.9.5"
7
+  },
8
+  "dependencies": {
9
+    "react": "^15.5.4",
10
+    "react-dom": "^15.5.4"
11
+  },
12
+  "scripts": {
13
+    "start": "react-scripts start",
14
+    "start:server": "http-server build/",
15
+    "build": "react-scripts build",
16
+    "test": "react-scripts test --env=jsdom",
17
+    "eject": "react-scripts eject"
18
+  }
19
+}

BIN
docker/docker-for-prod-only/public/favicon.ico


+ 31 - 0
docker/docker-for-prod-only/public/index.html

@@ -0,0 +1,31 @@
1
+<!doctype html>
2
+<html lang="en">
3
+  <head>
4
+    <meta charset="utf-8">
5
+    <meta name="viewport" content="width=device-width, initial-scale=1">
6
+    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
7
+    <!--
8
+      Notice the use of %PUBLIC_URL% in the tag above.
9
+      It will be replaced with the URL of the `public` folder during the build.
10
+      Only files inside the `public` folder can be referenced from the HTML.
11
+
12
+      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
13
+      work correctly both with client-side routing and a non-root public URL.
14
+      Learn how to configure a non-root public URL by running `npm run build`.
15
+    -->
16
+    <title>React App</title>
17
+  </head>
18
+  <body>
19
+    <div id="root"></div>
20
+    <!--
21
+      This HTML file is a template.
22
+      If you open it directly in the browser, you will see an empty page.
23
+
24
+      You can add webfonts, meta tags, or analytics to this file.
25
+      The build step will place the bundled scripts into the <body> tag.
26
+
27
+      To begin the development, run `npm start`.
28
+      To create a production bundle, use `npm run build`.
29
+    -->
30
+  </body>
31
+</html>

+ 24 - 0
docker/docker-for-prod-only/src/App.css

@@ -0,0 +1,24 @@
1
+.App {
2
+  text-align: center;
3
+}
4
+
5
+.App-logo {
6
+  animation: App-logo-spin infinite 20s linear;
7
+  height: 80px;
8
+}
9
+
10
+.App-header {
11
+  background-color: #222;
12
+  height: 150px;
13
+  padding: 20px;
14
+  color: white;
15
+}
16
+
17
+.App-intro {
18
+  font-size: large;
19
+}
20
+
21
+@keyframes App-logo-spin {
22
+  from { transform: rotate(0deg); }
23
+  to { transform: rotate(360deg); }
24
+}

+ 21 - 0
docker/docker-for-prod-only/src/App.js

@@ -0,0 +1,21 @@
1
+import React, { Component } from 'react';
2
+import logo from './logo.svg';
3
+import './App.css';
4
+
5
+class App extends Component {
6
+  render() {
7
+    return (
8
+      <div className="App">
9
+        <div className="App-header">
10
+          <img src={logo} className="App-logo" alt="logo" />
11
+          <h2>Welcome to React</h2>
12
+        </div>
13
+        <p className="App-intro">
14
+          To get started, edit <code>src/App.js</code> and save to reload.
15
+        </p>
16
+      </div>
17
+    );
18
+  }
19
+}
20
+
21
+export default App;

+ 8 - 0
docker/docker-for-prod-only/src/App.test.js

@@ -0,0 +1,8 @@
1
+import React from 'react';
2
+import ReactDOM from 'react-dom';
3
+import App from './App';
4
+
5
+it('renders without crashing', () => {
6
+  const div = document.createElement('div');
7
+  ReactDOM.render(<App />, div);
8
+});

+ 5 - 0
docker/docker-for-prod-only/src/index.css

@@ -0,0 +1,5 @@
1
+body {
2
+  margin: 0;
3
+  padding: 0;
4
+  font-family: sans-serif;
5
+}

+ 9 - 0
docker/docker-for-prod-only/src/index.js

@@ -0,0 +1,9 @@
1
+import React from 'react';
2
+import ReactDOM from 'react-dom';
3
+import App from './App';
4
+import './index.css';
5
+
6
+ReactDOM.render(
7
+  <App />,
8
+  document.getElementById('root')
9
+);

File diff suppressed because it is too large
+ 7 - 0
docker/docker-for-prod-only/src/logo.svg


File diff suppressed because it is too large
+ 5350 - 0
docker/docker-for-prod-only/yarn.lock


+ 0 - 3
docker/dockertutorial/Dockerfile

@@ -1,3 +0,0 @@
1
-FROM docker/whalesay:latest
2
-RUN apt-get -y update && apt-get install -y fortunes
3
-CMD /usr/games/fortune -a | cowsay