Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use Python 3.12 slim image for smaller size
FROM python:3.12-slim

# Set working directory
WORKDIR /app

# Copy requirements first for better caching
COPY requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY . .

# Expose port 9000
EXPOSE 9000

# Run the Flask application
CMD ["python", "-m", "flask", "run", "--host=0.0.0.0", "--port=9000"]
67 changes: 65 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,72 @@ Some things to try:
- Click OK
- Press <kbd>F1</kbd> and select the **Dev Containers: Rebuild Container** or **Codespaces: Rebuild Container** command so the modifications are picked up.

### More samples
## Running with Docker

For users who prefer standard Docker over Dev Containers, this project now includes Docker support.

### Prerequisites
- [Docker](https://docs.docker.com/get-docker/) installed on your system
- [Docker Compose](https://docs.docker.com/compose/install/) (included with Docker Desktop)

### Quick Start with Docker Compose

```bash
# Build and start the application
docker compose up --build

# Stop the application
docker compose down
```

### Alternative: Using Docker directly

```bash
# Build the image
docker build -t vscode-remote-try-python .

# Run the container
docker run --rm -p 9000:9000 vscode-remote-try-python
```

### Docker Configuration

- [Tweeter App - Python and Django](https://github.com/Microsoft/python-sample-tweeterapp)
**Base Image**: `python:3.12-slim` - Lightweight Python runtime

**Services**:
- `web`: Flask application server

**Ports**:
- `9000:9000` - Flask app accessible at http://localhost:9000

### Troubleshooting Docker

**Port already in use**:
```bash
# Change the host port (left side) in docker-compose.yml
ports:
- "9001:9000" # Now accessible at http://localhost:9001
```

**Rebuild after dependency changes**:
```bash
docker compose build --no-cache
docker compose up
```

**Permission denied (Linux/macOS)**:
```bash
# Add user to docker group
sudo usermod -aG docker $USER
# Then log out and back in
```

**View container logs**:
```bash
docker compose logs -f
```

### More samples

## Contributing

Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: '3.8'

services:
web:
build: .
ports:
- "9000:9000"
environment:
- FLASK_ENV=development
volumes:
- .:/app
command: python -m flask run --host=0.0.0.0 --port=9000 --reload