Skip to content

Commit 2e704c7

Browse files
cguarinosuclaude
andcommitted
build: Add DevContainer and Docker configuration
Set up VS Code DevContainer support with Python 3.13 and development tooling for consistent development environment across machines. DevContainer features: - Python 3.13 official devcontainer image - Automatic Poetry installation and dependency setup - Port forwarding for FastAPI (8000) - VS Code extensions pre-installed: * Python extension pack * Pylance (language server) * Ruff (linting/formatting) * mypy type checker Editor configuration: - Auto-format on save with Ruff - Organize imports on save - Enable all code actions - Consistent Python interpreter path Docker Compose: - Simplified configuration (removed PostgreSQL) - Python 3.13 base image - Volume mount for live code updates - Isolated network for future scalability - Sleep infinity for container persistence Benefits: - Zero-config setup for new developers - Consistent tooling across team - Isolated dependencies - Pre-configured linting and formatting - Works on any platform (Windows, Mac, Linux) Usage: 1. Open in VS Code 2. Install Dev Containers extension 3. Reopen in Container (F1 → "Dev Containers: Reopen in Container") 4. Everything installs automatically 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ae26c92 commit 2e704c7

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
3+
{
4+
"name": "FastAPI Todo App",
5+
6+
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
7+
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
8+
"dockerComposeFile": [
9+
"../docker-compose.yml",
10+
"docker-compose.yml"
11+
],
12+
13+
// The 'service' property is the name of the service for the container that VS Code should
14+
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
15+
"service": "app",
16+
17+
// The optional 'workspaceFolder' property is the path VS Code should open by default when
18+
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
19+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
20+
21+
// Features to add to the dev container. More info: https://containers.dev/features.
22+
"features": {
23+
"ghcr.io/devcontainers/features/python:1": {
24+
"version": "3.13",
25+
"installTools": true
26+
}
27+
},
28+
29+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
30+
"forwardPorts": [8000],
31+
32+
// Uncomment the next line if you want start specific services in your Docker Compose config.
33+
// "runServices": [],
34+
35+
// Uncomment the next line if you want to keep your containers running after VS Code shuts down.
36+
// "shutdownAction": "none",
37+
38+
// Install dependencies after container is created
39+
"postCreateCommand": "pip install poetry && poetry install",
40+
41+
// Configure tool-specific properties.
42+
"customizations": {
43+
"vscode": {
44+
"extensions": [
45+
"ms-python.python",
46+
"ms-python.vscode-pylance",
47+
"charliermarsh.ruff",
48+
"ms-python.mypy-type-checker"
49+
],
50+
"settings": {
51+
"python.defaultInterpreterPath": "/usr/local/bin/python",
52+
"python.linting.enabled": true,
53+
"python.formatting.provider": "none",
54+
"[python]": {
55+
"editor.defaultFormatter": "charliermarsh.ruff",
56+
"editor.formatOnSave": true,
57+
"editor.codeActionsOnSave": {
58+
"source.fixAll": "explicit",
59+
"source.organizeImports": "explicit"
60+
}
61+
},
62+
"ruff.enable": true,
63+
"mypy-type-checker.importStrategy": "fromEnvironment"
64+
}
65+
}
66+
}
67+
68+
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
69+
// "remoteUser": "devcontainer"
70+
}

.devcontainer/docker-compose.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '3.8'
2+
services:
3+
# Update this to the name of the service you want to work with in your docker-compose.yml file
4+
app:
5+
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
6+
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
7+
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
8+
# array). The sample below assumes your primary file is in the root of your project.
9+
#
10+
# build:
11+
# context: .
12+
# dockerfile: .devcontainer/Dockerfile
13+
14+
volumes:
15+
# Update this to wherever you want VS Code to mount the folder of your project
16+
- ..:/workspaces:cached
17+
18+
# Uncomment the next four lines if you will use a ptrace-based debugger like C++, Go, and Rust.
19+
# cap_add:
20+
# - SYS_PTRACE
21+
# security_opt:
22+
# - seccomp:unconfined
23+
24+
# Overrides default command so things don't shut down after the process ends.
25+
command: sleep infinity
26+

docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3.8'
2+
services:
3+
app:
4+
image: mcr.microsoft.com/devcontainers/python:1-3.13-bookworm
5+
volumes:
6+
- .:/workspaces/python-interview
7+
ports:
8+
- "8000:8000"
9+
command: sleep infinity
10+
working_dir: /workspaces/python-interview
11+
networks:
12+
- fastapi-network
13+
14+
networks:
15+
fastapi-network:
16+
driver: bridge

0 commit comments

Comments
 (0)