Demo app using the Deep Dive Bootcamp toolkit.
React Spinup must be completed by one member of the team but it is recommended that it is done as a group with the rest of the team members watching/looking for missing semi colons.
- cd into the project and run
npx create-react-app app - add the following packages to package.json under "dependencies"
"@fortawesome/fontawesome-svg-core": "^1.2.17",
"@fortawesome/free-brands-svg-icons": "^5.12.1",
"@fortawesome/free-regular-svg-icons": "^5.12.1",
"@fortawesome/free-solid-svg-icons": "^5.8.1",
"@fortawesome/react-fontawesome": "^0.1.4",
"@reduxjs/toolkit": "^1.3.6",
"axios": "^0.18.0",
"bootstrap": "^4.3.1",
"formik": "^1.5.4",
"http-proxy-middleware": "^0.19.1",
"jwt-decode": "^2.2.0",
"lodash": "^4.17.15",
"react": "^16.9.0",
"react-bootstrap": "^1.0.0-beta.10",
"react-dom": "^16.9.0",
"react-redux": "^7.1.0",
"react-router": "^5.0.1",
"react-router-bootstrap": "^0.25.0",
"react-router-dom": "^5.0.0",
"react-scripts": "^3.1.1",
"redux": "^4.0.4",
"redux-thunk": "^2.3.0",
"yup": "^0.27.0"
- run
npm installin the /app directory - delete every file in
app/src - create a new file called
app/src/index.jsand add the content below:
import React from 'react';
import ReactDOM from 'react-dom'
import 'bootstrap/dist/css/bootstrap.css';
const App = () => ( <h1 className="text-info">hello world</h1> );
ReactDOM.render(<App/>, document.querySelector('#root'));
- Optional run
npm startin/appto see if the setup was successful
- Create a new Component file called Home.js in
/app/src/pages - Add the content below to the file:
import React from "react"
export const Home = () => {
return (
<>
<h1>Home</h1>
</>
)
}
- create a new Component file called FourOhFour.js in
/app/src/pagesadd the content below to the file:
import React from "react"
export const FourOhFour = () => {
return (
<>
<h1>Y U NO FIND</h1>
</>
)
};
- Inside app/src/index.js replace the following...
import React from 'react';
import ReactDOM from 'react-dom'
import 'bootstrap/dist/css/bootstrap.css';
const App = () => (<h1 className="text-info">hello world</h1>);
ReactDOM.render(<App/>, document.querySelector('#root'));
with this:
import React from 'react';
import ReactDOM from 'react-dom'
import 'bootstrap/dist/css/bootstrap.css';
import {BrowserRouter} from "react-router-dom";
import {Route, Switch} from "react-router";
import {FourOhFour} from "./pages/FourOhFour";
import {Home} from "./pages/Home";
const Routing = () => (
<>
<BrowserRouter>
<Switch>
<Route exact path="/" component={Home}/>
<Route component={FourOhFour}/>
</Switch>
</BrowserRouter>
</>
);
ReactDOM.render(<Routing/>, document.querySelector('#root'));
- Add Dockerfile to /sql directory
- Add .env, .dockerignore, docker-compose.yml files to project root. Update your .gitignore
- Create an /apis directory, add the Dockerfile. This will be the location of your express back end, apis, etc.
- Add the package.json and tsconfig.json to /apis
- Add index.ts, database.ts, and App.ts to apis/src/
- npm install locally so everything resolves in IDE
- You can run this App locally: cd into /apis and npm run dev
- Upload all to your remote host and docker-compose up
- Add and update the staging (http)
nginx.conffile to /app found here - Add and update the staging (http)
docker-compose.ymlfile to the project root found here
- In your project run
docker-compose up -d - Run the command below
sudo docker container run -it --rm \
-v /docker-volumes/<YOUR_PROJECT_NAME>/etc/letsencrypt:/etc/letsencrypt \
-v /docker-volumes/<YOUR_PROJECT_NAME>/etc/lib/letsencrypt:/var/lib/letsencrypt \
-v $(pwd)/app/public:/data/letsencrypt \
-v "/docker-volumes/<YOUR_PROJECT_NAME>/var/log/:/var/log/letsencrypt" \
certbot/certbot \
certonly --webroot \
--register-unsafely-without-email --agree-tos \
--webroot-path=/data/letsencrypt \
--staging \
-d <YOUR_DOMAIN_NAME.COM> -d <WWW.YOUR_DOMAIN_NAME.COM>
-v /docker-volumes/<YOUR_PROJECT_NAME>/etc/letsencrypt:/etc/letsencrypt \- Binds the
/etc/letsenscryptdirectory where the key is generated in the certbot container to the localhost'sdocker-volumes/<YOUR_PROJECT_NAME>/etc/letsencrypt
- Binds the
-v /docker-volumes/<YOUR_PROJECT_NAME>/etc/lib/letsencrypt:/var/lib/letsencrypt \- binds
/var/lib/letsencryptin the certbot container to the localhost's/docker-volumes/<YOUR_PROJECT_NAME>/etc/lib/letsencrypt
- binds
-v $(pwd)/app/public:/data/letsencrypt \$(pwd)uses the current file location generated by pwd to run a command- binds
/data/letsencryptin the certbot container to the localhost's/home/user/app/publicso that the ACME challenge can pass.
-v "/docker-volumes/<YOUR_PROJECT_NAME>/var/log/:/var/log/letsencrypt" \- binds the
/var/log/letsencrypt" \in the certbot container to the localhost's/docker-volumes/<YOUR_PROJECT_NAME>/var/log/so that debugging logs from the certbot container can be preserved.
- binds the
certbot/certbot- is the container that is going to be used.
certonly --webroot \sets the webroot to/--register-unsafely-without-email --agree-tos \- register unsafely for staging purposes and agree to the terms of service
--webroot-path=/data/letsencrypt \- sets the webroot-path to
/data/letsencryptinside of the certbot container
- sets the webroot-path to
--staging \- issues the ssl certificate for staging purposes
-d <YOUR_DOMAIN_NAME.COM>- specifies the domain/domains to verify for the ssl certificate
- If the command from the previous step is successful run
sudo rm -rf /docker-volumes/<YOUR_PROJECT_NAME> - run large command from before but this time without the staging flag and make sure add an email for reminders on when to reissue the certificate (see below)
sudo docker container run -it --rm \
-v /docker-volumes/<YOUR_PROJECT_NAME>/etc/letsencrypt:/etc/letsencrypt \
-v /docker-volumes/<YOUR_PROJECT_NAME>/etc/lib/letsencrypt:/var/lib/letsencrypt \
-v $(pwd)/app/public:/data/letsencrypt \
-v "/docker-volumes/<YOUR_PROJECT_NAME>/var/log/:/var/log/letsencrypt" \
certbot/certbot \
certonly --webroot \
--webroot-path=/data/letsencrypt \
--agree-tos \
--email <YOUR_EMAIL> \
-d <YOUR_DOMAIN_NAME.COM> -d <WWW.YOUR_DOMAIN_NAME.COM>
- Update the production
nginx.conffile with the content found here - Update
docker-compose.ymlwith the content found here - run
mkdir dh-paramin your project root on the host machine. - run
sudo openssl dhparam -out dh-param/dhparam-2048.pem 2048in your project on the host machine. - run
docker-compose up -d