This repository contains two main examples:
-
BasicApp
A simple Python (Flask) application containerized with Docker. -
ComposeApp
A full stack using Docker Compose with:- A Python (Flask) backend (
back
). - A React/Vite frontend (
front
).
- A Python (Flask) backend (
.
├── BasicApp
│ ├── app.py
│ ├── requirements.txt
│ └── Dockerfile (example: single-container Python app)
├── ComposeApp
│ ├── back
│ │ ├── app.py
│ │ ├── requirements.txt
│ │ └── Dockerfile (backend Dockerfile)
│ ├── front
│ │ ├── src
│ │ │ ├── App.css
│ │ │ ├── App.tsx
│ │ │ └── ...
│ │ ├── public
│ │ ├── package.json
│ │ └── Dockerfile (frontend Dockerfile)
│ └── docker-compose.yml
└── Solutions (additional solutions or examples)
-
Navigate to the
BasicApp
directory. -
Build the Docker image:
docker build -t basic-app .
-
Run the container:
docker run -p 5000:5000 basic-app
-
Access the app at http://localhost:5000/hello-world.
-
Navigate to the
ComposeApp
directory. -
Build and run the containers using Docker Compose:
docker compose up -d --build
This command will build images (if needed) and run the services in detached mode.
-
If you only changed a single service and want to rebuild just that service without touching the others, you can run:
docker compose up -d --no-deps --build <service-name>
For example:
docker compose up -d --no-deps --build back
- The backend listens on port
5000
(e.g., http://localhost:5000/hello-world). - The frontend listens on port
3000
or80
(depending on your Dockerfile/Compose configuration).
-
To view logs:
docker compose logs -f
-
To stop the services:
docker compose down
- BasicApp: Update
app.py
orrequirements.txt
as needed, then rebuild the image. - ComposeApp: Adjust Dockerfile settings for both the backend and frontend, as well as
docker-compose.yml
, to customize your stack. Rebuild only the changed service with--no-deps --build
if you want faster rebuilds.
This project is distributed under the MIT License. See LICENSE
for details.