================================================================ LAB 8 — Docker, CI/CD & Deployment ================================================================ Course: Web Technologies Topic: Lecture 10 (Deployment & DevOps) Time: 3 hours lab + 4 hours self-study ---------------------------------------------------------------- LEARNING GOALS ---------------------------------------------------------------- - Containerise a multi-service web app - Run an app + database with Docker Compose - Set up CI with GitHub Actions - Deploy a container to a free public host ---------------------------------------------------------------- PROJECT ---------------------------------------------------------------- Take your Lab 6 (or Lab 7) backend, plus your Lab 4 React frontend. Containerise both and deploy. ---------------------------------------------------------------- TASKS ---------------------------------------------------------------- TASK 1 — Dockerfile for the API - Multi-stage build (build + runtime) - Final image based on a slim/Alpine JRE (or node:alpine, python:slim) - Expose the right port - Image size < 500 MB TASK 2 — Dockerfile for the frontend - Build with Node, serve static files with nginx:alpine - Final image < 100 MB TASK 3 — docker-compose.yml Services: api (your backend, depends_on db) db (postgres:16, with named volume for data) web (your frontend, depends_on api) Ports: web -> 8080 api -> 8081 db -> not exposed publicly Use environment variables for secrets (DB password, JWT secret). Provide a .env.example committed; .env in .gitignore. TASK 4 — GitHub Actions CI Workflow .github/workflows/ci.yml that: - Runs on push and pull_request - Installs deps, runs tests for backend and frontend - Builds both Docker images - On main branch, pushes images to ghcr.io TASK 5 — Deploy Pick one free host: Render, Fly.io, or Railway. Deploy the api + a Postgres add-on. Deploy the web frontend (Vercel / Netlify / same provider). Confirm: - Frontend reaches the API - You can sign up + log in (from Lab 7) ---------------------------------------------------------------- DELIVERABLES ---------------------------------------------------------------- - GitHub repo with both Dockerfiles, docker-compose.yml, ci.yml - Live URLs for frontend + API in README - Screenshot of green CI run ---------------------------------------------------------------- GRADING (10 marks) ---------------------------------------------------------------- Dockerfiles work (build + run) .... 3 docker-compose brings up all 3 .... 2 CI runs tests on every push ....... 2 Live deployment reachable ......... 3