Skip to content

Commit 9a822c1

Browse files
committed
add dev container
1 parent 5e0c472 commit 9a822c1

File tree

5 files changed

+134
-0
lines changed

5 files changed

+134
-0
lines changed

Diff for: .devcontainer/Dockerfile_dev

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM mcr.microsoft.com/devcontainers/python:3.12-bullseye
2+
3+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
4+
&& apt-get -y install --no-install-recommends default-mysql-server \
5+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
6+
7+
8+
COPY requirements-dev.txt requirements-dev.txt
9+
COPY src/requirements.txt src/requirements.txt
10+
RUN python -m pip install --upgrade pip
11+
RUN python -m pip install -r requirements-dev.txt

Diff for: .devcontainer/devcontainer.json

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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": "azure_django_mysql_flexible_appservice",
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": "docker-compose_dev.yml",
9+
// The 'service' property is the name of the service for the container that VS Code should
10+
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
11+
"service": "app",
12+
"shutdownAction": "stopCompose",
13+
"workspaceFolder": "/workspace",
14+
"forwardPorts": [8000, 3306],
15+
"portsAttributes": {
16+
"8000": {"label": "Web port", "onAutoForward": "notify"},
17+
"3306": {"label": "MySQL Port", "onAutoForward": "silent"}
18+
},
19+
"customizations": {
20+
"vscode": {
21+
"extensions": [
22+
"ms-azuretools.vscode-bicep",
23+
"charliermarsh.ruff",
24+
"ms-python.python",
25+
"bierner.github-markdown-preview"
26+
],
27+
"settings": {
28+
"python.defaultInterpreterPath": "/usr/local/bin/python",
29+
"python.testing.pytestEnabled": true,
30+
"python.testing.unittestEnabled": false,
31+
"files.exclude": {
32+
".coverage": true,
33+
".pytest_cache": true,
34+
"__pycache__": true,
35+
".ruff_cache": true
36+
},
37+
"[python]": {
38+
"editor.formatOnSave": true,
39+
"editor.defaultFormatter": "charliermarsh.ruff",
40+
"editor.codeActionsOnSave": {
41+
"source.organizeImports": true,
42+
"source.fixAll": true
43+
}
44+
}
45+
}
46+
}
47+
},
48+
"features": {
49+
"ghcr.io/azure/azure-dev/azd:latest": {}
50+
},
51+
"postCreateCommand": "playwright install chromium --with-deps && python src/manage.py migrate && python src/manage.py loaddata src/seed_data.json"
52+
}

Diff for: .devcontainer/docker-compose_dev.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
version: '3'
2+
services:
3+
db:
4+
image: mysql:latest
5+
6+
environment:
7+
MYSQL_ROOT_PASSWORD: mysql
8+
MYSQL_DATABASE: relecloud
9+
10+
restart: unless-stopped
11+
12+
volumes:
13+
- mysql-data:/var/lib/mysql
14+
15+
healthcheck:
16+
test: ["CMD-SHELL", "mysqladmin ping"]
17+
interval: 10s
18+
timeout: 5s
19+
retries: 5
20+
21+
app:
22+
build:
23+
context: ..
24+
dockerfile: ./.devcontainer/Dockerfile_dev
25+
depends_on:
26+
db:
27+
condition: service_healthy
28+
network_mode: service:db
29+
environment:
30+
MYSQL_HOST: db
31+
MYSQL_USER: root
32+
MYSQL_PASS: mysql
33+
MYSQL_DATABASE: relecloud
34+
35+
command: sleep infinity
36+
37+
volumes:
38+
- ..:/workspace:cached
39+
40+
volumes:
41+
mysql-data:

Diff for: pyproject.toml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[tool.ruff]
2+
line-length = 120
3+
select = ["E", "F", "I", "UP"]
4+
ignore = ["D203"]
5+
6+
[tool.ruff.isort]
7+
8+
[tool.pytest.ini_options]
9+
addopts = "-ra -vv"
10+
DJANGO_SETTINGS_MODULE = "project.settings"
11+
pythonpath = ["src"]
12+
13+
[tool.coverage.report]
14+
show_missing = true

Diff for: requirements-dev.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-r src/requirements.txt
2+
3+
# Cookiecutter Support
4+
cruft
5+
pip-tools
6+
7+
# Testing Tools
8+
pytest
9+
pytest-django
10+
pytest-playwright
11+
coverage
12+
pytest-cov
13+
axe-playwright-python
14+
15+
# Linters
16+
ruff

0 commit comments

Comments
 (0)