Skip to content

Commit 90897a2

Browse files
author
Hemanth-konduri
committed
feat(docker): add Docker and Docker Compose support with documentation
1 parent e351212 commit 90897a2

File tree

3 files changed

+97
-2
lines changed

3 files changed

+97
-2
lines changed

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use Python 3.12 slim image for smaller size
2+
FROM python:3.12-slim
3+
4+
# Set working directory
5+
WORKDIR /app
6+
7+
# Copy requirements first for better caching
8+
COPY requirements.txt .
9+
10+
# Install dependencies
11+
RUN pip install --no-cache-dir -r requirements.txt
12+
13+
# Copy application code
14+
COPY . .
15+
16+
# Expose port 9000
17+
EXPOSE 9000
18+
19+
# Run the Flask application
20+
CMD ["python", "-m", "flask", "run", "--host=0.0.0.0", "--port=9000"]

README.md

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,72 @@ Some things to try:
8888
- Click OK
8989
- Press <kbd>F1</kbd> and select the **Dev Containers: Rebuild Container** or **Codespaces: Rebuild Container** command so the modifications are picked up.
9090

91-
### More samples
91+
## Running with Docker
92+
93+
For users who prefer standard Docker over Dev Containers, this project now includes Docker support.
94+
95+
### Prerequisites
96+
- [Docker](https://docs.docker.com/get-docker/) installed on your system
97+
- [Docker Compose](https://docs.docker.com/compose/install/) (included with Docker Desktop)
98+
99+
### Quick Start with Docker Compose
100+
101+
```bash
102+
# Build and start the application
103+
docker compose up --build
104+
105+
# Stop the application
106+
docker compose down
107+
```
108+
109+
### Alternative: Using Docker directly
110+
111+
```bash
112+
# Build the image
113+
docker build -t vscode-remote-try-python .
114+
115+
# Run the container
116+
docker run --rm -p 9000:9000 vscode-remote-try-python
117+
```
118+
119+
### Docker Configuration
92120

93-
- [Tweeter App - Python and Django](https://github.com/Microsoft/python-sample-tweeterapp)
121+
**Base Image**: `python:3.12-slim` - Lightweight Python runtime
122+
123+
**Services**:
124+
- `web`: Flask application server
125+
126+
**Ports**:
127+
- `9000:9000` - Flask app accessible at http://localhost:9000
128+
129+
### Troubleshooting Docker
130+
131+
**Port already in use**:
132+
```bash
133+
# Change the host port (left side) in docker-compose.yml
134+
ports:
135+
- "9001:9000" # Now accessible at http://localhost:9001
136+
```
137+
138+
**Rebuild after dependency changes**:
139+
```bash
140+
docker compose build --no-cache
141+
docker compose up
142+
```
143+
144+
**Permission denied (Linux/macOS)**:
145+
```bash
146+
# Add user to docker group
147+
sudo usermod -aG docker $USER
148+
# Then log out and back in
149+
```
150+
151+
**View container logs**:
152+
```bash
153+
docker compose logs -f
154+
```
155+
156+
### More samples
94157

95158
## Contributing
96159

docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: '3.8'
2+
3+
services:
4+
web:
5+
build: .
6+
ports:
7+
- "9000:9000"
8+
environment:
9+
- FLASK_ENV=development
10+
volumes:
11+
- .:/app
12+
command: python -m flask run --host=0.0.0.0 --port=9000 --reload

0 commit comments

Comments
 (0)