INFO 30005
Web Information Technologies
Deploy your
Copyright By PowCoder代写 加微信 powcoder
Development environment
Production environment
developers
Need to separate DEV from PROD.
(Don’t code on the live server!)
DTAP – dev, test, acceptance, prod.
Automated build/test/release/monitor. DevOps, Continuous Delivery, containerisation.
Development
Production
server database browsers
browser server
Demo: “FoodBuddy”
edit some files … git add, commit
push to GitHub and Heroku
update (some of) the database via import file (what should we update in the live database?)
server database browsers
Preparing for deployment
WHAT YOU NEED: Heroku account
install Heroku CLI locally
local software repo remote repo on GitHub
(if using a database …)
install MongoDB locally MongoDB Atlas account
install MongoDB Compass locally
Set up a demo Express app
mkdir deploy-demo
cd deploy-demo
npm init –y
npm install express
npm install express-handlebars git init
echo node_modules > .gitignore mkdir views
mkdir views/layouts
mkdir public
mkdir public/css
in Code, create /public/css/styles.css with a BODY style (color, background-color, font-family)
in Code, create /views/layouts/main.hbs – change title, add H1, {{{body}}}, in Code, create /views/layouts/index.hbs, with one paragraph “this is the home page of Deploy Demo”
in Code, create /src/app.js (copy in the starter file)
test at command prompt, run ‘node src/app.js’ and open localhost in browser git status, git add ., git commit –m “first commit”
Deploy demo app to Heroku
Set up remote repo on GitHub – new repo deploy-demo, follow instructions to do first push, show code in GitHub “heroku create info30005-deploy-demo” – sets up website and Heroku git repo
“git remote” to show that we now have two remote repos
browser to http://info30005-deploy-demo.herokuapp.com/ to see welcome message
“git push Heroku” – see the app build, then refresh the remote website – error! – needs two changes:
• extra line in package.json: “”start”: “node src/app.js””
• and in app.js: const port = process.env.PORT || 8080 – these make app run local and Heroku
Commit and push to Heroku – refresh and remote / live website is working
run locally as “npm run start” – browse to localhost
change the background-color – “git push Heroku”, this is independent of pushing to GitHub
We will cover Atlas in the MongoDB lecture.
(Partially) automated deployment
Our process is:
1. make changes to code
2. test code is working
3. git commit
4. git push heroku
server database browsers
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com