A web deployment lab: Git, a free host and environment settings

Put a small web project online on a free hosting tier from your own computer: push it to a Git repository, connect a host, set configuration in the host's environment instead of the code, check a health endpoint, and know how to roll back.

  • Time: 45 to 60 minutes
  • Cost: free software, your own computer

What you need

Everything in the full-stack course runs in your browser, but the point of a web app is that other people can use it. Putting a project online teaches the part that is not code: how a change travels from your computer to a server, where secrets live, and what to do when a release goes wrong.

You need:

  • The developer workstation (editor, Git and Node.js) from its guide.
  • A free account on a Git hosting service (a place that stores your repository online).
  • A free account on a hosting service that can run a small web project. Several services offer a free tier for small projects; their limits and terms change, so check the current terms and limits before you rely on one, and choose one that does not ask for payment details you do not want to give.
  • A small project that builds and runs locally, such as the handler from the capstone behind a tiny server or a framework of your choice.

Set it up

  1. In your project folder make sure the project runs locally and that a file named .gitignore lists node_modules, build output and any file that holds settings or secrets (such as .env).
  2. Put the project under version control and make the first commit:
git init
git add .
git commit -m "First version"
  1. Create an empty repository on your Git hosting service, add it as the remote the service shows you, and push:
git remote add origin <the address your service gives you>
git branch -M main
git push -u origin main
  1. On the hosting service, create a new project from that repository. It usually detects the framework, asks for a build command (for example npm run build) and shows where the output goes. Accept the defaults and deploy.
  2. In the hosting service’s settings, find the environment variables and add every setting your app needs (your session secret, the database address, the log level). Never put them in the repository. Redeploy so the app picks them up.

Check that it works

Open the address the host gives you. Then check these three things, which are what the course’s cases are about:

  • A health check. Visit your health route (for example /health) and see it answer. Point a free uptime monitor at it if you like.
  • Fail fast. Remove one required setting in the host’s environment and redeploy. The app should refuse to start and the logs should name what is missing. Put it back.
  • No secrets in the code. Search your repository for a key or password you used (git grep finds text in every file). If one ever reached the repository, treat it as leaked: change it at its source.

Practise safely

  • Use only invented data on a public site. Never put real customer or staff records in a project you deploy while you are learning.
  • Never commit secrets. If you do by mistake, rotate the secret straight away: deleting the file does not remove it from the history.
  • Use a different secret for each environment, and keep your real production secrets out of anything you share.
  • Read what permissions a hosting service asks for before you connect it to your repository, and give it access to only the repository it needs.
  • Keep an eye on usage limits on a free tier, and turn off projects you no longer need.

Go further

  • Add a pipeline that compiles and tests every change before it is deployed (see the DevOps course), so a broken change never reaches the site.
  • Learn how your host handles rollbacks: deploy a deliberately broken change and practise returning to the previous version in one step.
  • Add a custom domain and https (most hosts give you a certificate automatically), and check that your cookies carry the Secure flag.
  • Put a content delivery network in front of the project and watch your cache headers decide what it stores.
  • Read your host’s logs after a few visits and find your request ids in them.

Courses that use this lab

Other lab guides

Software changes quickly. Menu names and version numbers may differ a little from what you see; the ideas and the check at the end of each section stay the same. Always download from the project's own website, and read the licence terms for your situation.