Week 11

Deployment Strategies

Creating Docker Images

Multi-stage builds

Docker Compose

Container Registries

Deploying to the Cloud

Database Migrations

Practice

Assignment

Backend Track

Content

Let’s get practical

Exercise 1

Containerise your Week 7 project:

  1. Write a multi-stage Dockerfile and a .dockerignore.
  2. Build the image and tag it with your project's name.
  3. Run it with port mapping and open it in your browser or Postman.
  4. Watch the logs with docker logs -f while you send a request.
  5. Open a shell inside with docker exec and find your JAR.

Exercise 2

Add Docker Compose to your Week 7 project.

  1. Create a compose.yaml with your api (built from your Dockerfile) and a db (postgres:<version>): ports, environment variables and a named volume.
  2. Load your schema — by hand or with an init script.
  3. Run docker compose up --build and call an endpoint that uses the database. This time it works.
  4. Run docker compose down, then up again — confirm your data survived.
  5. Follow the logs with docker compose logs -f api while sending requests.
  6. Bonus: add the healthcheck so the API waits for the database.

Exercise 3

Publish your Week 7 project image.

  1. Tag your multi-stage image as <your-username>/<project>:1.0 and push it.
  2. Open hub.docker.com and admire your repository in the browser.
  3. Push the same tag again without changes — read the output. What happened to the layers?
  4. Team up with a classmate: in your compose.yaml, replace build: . with image: <classmate>/<project>:1.0 and run their backend on your machine. (Ask for their schema.sql too — their tables are not yours.)

Exercise 4

Take your Week 7 project live, end to end.

  1. Create a Neon project and load your schema.
  2. Push the Dockerfile and .dockerignore to GitHub and create a Render web service.
  3. Set the four environment variables and deploy.
  4. Add a /health endpoint and configure it as the Health Check Path.
  5. Run your Postman collection against the live URL — every endpoint, including the ones that hit the database.
  6. Now break it on purpose: change SPRING_DATASOURCE_PASSWORD to something wrong and redeploy. Watch it fail, find the evidence in the Logs tab, then fix it. This is the debugging you will do at work.

The HackYourFuture curriculum is licensed under CC BY-NC-SA 4.0 *https://hackyourfuture.net/*

CC BY-NC-SA 4.0 Icons

Built with ❤️ by the HackYourFuture community · Thank you, contributors

Found a mistake or have a suggestion? Let us know in the feedback form.