This guide explains how to deploy the tiny-bank-server application and its database using a pre-built image from Docker Hub and a single docker-compose.yml file. The API container will automatically handle database migrations on startup.
- Docker and Docker Compose must be installed and running on your system.
-
Create a new, empty folder for your deployment (e.g.,
~/server-deployment). -
Inside that folder, create a file named
docker-compose.yml. -
Copy the content from the
docker-compose.ymland paste it into this new file. -
Important: Edit the
environmentsection within thedocker-compose.ymlfile to replace the placeholder passwords and secrets with your actual production values.
Your final directory structure is extremely simple:
~/server-deployment/
|-- docker-compose.yml
Now you can start the entire application stack with a single command.
-
Open a terminal.
-
Navigate to your deployment directory (e.g.,
cd ~/server-deployment). -
Run the
upcommand:
docker-compose up -d
up: This command starts all the services defined in your docker-compose.yml file.\-d: This flag runs the containers in "detached" mode (in the background).
Docker will now pull your API image from Docker Hub, pull the PostgreSQL image, and start both containers. The API container will wait for the database, run any necessary migrations automatically, and then start the server.
Your server is now running and publicly accessible on your machine.
-
Open your web browser and navigate to the interactive API documentation:http://localhost:3000/swagger-ui
-
Use the Swagger UI or Postman to send requests to
http://localhost:3000/registerto test the full functionality.
- To view live logs from both services:
docker-compose logs -f
- To stop and remove the containers:
docker-compose down
(Your database data will be safely stored in a Docker volume and will be available the next time you run docker-compose up).