Project · Beginner · about 10 hours

Containerise a service and ship it through CI

Package the orders API in a small, secure container image, run it with its database in Docker Compose, and build, test and scan it on every pull request.

Skills:CI/CD, Git and GitHub, Docker and containers, Automated testing

Part of: Software Engineer (Backend), DevOps / Platform Engineer

Data and licences

Brief

Use the orders API from the Spring Boot project (or any small API you have built over the Olist data). A teammate should be able to run the whole stack with one command, and nothing should reach the main branch without passing tests.

What to build

  1. Write a multi-stage Dockerfile: build in one stage, copy only the artifact into a slim runtime image, run as a non-root user.

  2. Record the image size of a naive single-stage build and of your final build.

  3. Compose file with PostgreSQL (with a volume and a health check), a one-off loader job and the API, which waits for the database to be healthy.

  4. GitHub Actions: on pull requests run lint and tests, build the image, scan it (for example with Trivy) and fail on high-severity findings. On main, push the image to a registry with the commit SHA as the tag.

  5. Protect the main branch so merges require the workflow to pass.

Deliverables

  • Repository with Dockerfile, compose.yaml, .github/workflows/ci.yml and README.md

How it is graded

Reviewers clone the repository, run docker compose up, and open a pull request that breaks a test to see CI block it.

Stretch

Add a dependency update bot and a workflow that runs the image with a smoke test before pushing it.

Deliverables

  • A multi-stage Dockerfile producing a small image that runs as a non-root user
  • A Docker Compose file with the API, PostgreSQL, a data loader and health checks
  • A GitHub Actions workflow that lints, tests, builds the image and scans it for known vulnerabilities
  • A README with one-command local setup and the image size before and after optimisation

How a reviewer grades it

CriterionWeightWhat good looks like
Image is small, reproducible, non-root and has no secrets baked in25%
Compose setup starts cleanly with health checks and dependency order20%
CI runs on pull requests, fails on test or scan failures, and caches dependencies35%
README lets a new teammate run everything in minutes20%