Skip to content

Commit a8d7c90

Browse files
committedOct 10, 2019
[vscode] docker support and readme added
1 parent 9435834 commit a8d7c90

File tree

5 files changed

+73
-1
lines changed

5 files changed

+73
-1
lines changed
 

‎.devcontainer/devcontainer.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "KT dev environment",
3+
"dockerComposeFile": [
4+
"../docker/dev/docker-compose.yml",
5+
"docker-compose.yml"
6+
],
7+
"service": "kt",
8+
"workspaceFolder": "/app",
9+
"settings": {
10+
"python.pythonPath": "/usr/bin/python",
11+
"python.linting.pylintEnabled": true,
12+
"files.associations": {
13+
"**/*.html": "html",
14+
"**/templates/**/*.html": "django-html",
15+
"**/templates/**/*": "django-txt",
16+
"**/requirements{/**,*}.{txt,in}": "pip-requirements"
17+
},
18+
"terminal.integrated.shell.linux": "/bin/bash"
19+
},
20+
"postCreateCommand": "apt-get update && apt-get install -y git",
21+
"extensions": [
22+
"ms-python.python",
23+
"batisteo.vscode-django"
24+
]
25+
}

‎.devcontainer/docker-compose.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: '3.7'
2+
3+
4+
services:
5+
6+
kt:
7+
command: sleep infinity

‎.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ media/
22
.idea/
33
*.iml
44
bootstrap/
5-
.vscode/
65
db.sqlite3
6+
.vscode/*
7+
!.vscode/launch.json
78

89

910
### Template from https://github.com/github/gitignore/blob/master/Python.gitignore

‎.vscode/launch.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Run KT",
6+
"type": "python",
7+
"request": "launch",
8+
"program": "${workspaceFolder}/manage.py",
9+
"args": [
10+
"runserver",
11+
"--noreload",
12+
"0.0.0.0:8000"
13+
],
14+
"django": true
15+
}
16+
]
17+
}

‎README.md

+22
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,28 @@ If you want to reset your database for any reason, just run:
5858
```
5959

6060

61+
## How to use Visual Studio Code
62+
63+
Install [Visual Studio Code](https://code.visualstudio.com/download).
64+
65+
Install the [Docker](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker) and [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extensions.
66+
67+
Open KT in VSCode: File / Open... / choose the KT folder.
68+
69+
In the Command Palette (press `F1`) choose `Remote-Containers: Reopen in Container`
70+
71+
This will create two Docker containers (one for KT, one for MySQL), if they don't exist already. Now you can:
72+
73+
- navigate the code (dependencies are properly included)
74+
- run/debug KT from VSCode: Debug / Start Debugging (`F5`)
75+
76+
If you want to stop running KT: Debug / Stop Debugging.
77+
78+
If you want to stop developing: `Remote-Containers: Reopen Locally`. This will stop the containers.
79+
80+
Note: you cannot use `./scripts/start-dev.sh` and `Remote-Containers: Reopen in Container` at the same time. If you try, it will fail because port 8000 on your host machine cannot be forwarded to two different containers. And it might also corrupt your database volume (`kt-db`), because two MySQL server instances will try to use it. If the latter happens, you can reset the database with `./scripts/init-dev-db.sh`.
81+
82+
6183
## Developer guide
6284

6385
If you want to participate, here are some rules and guidelines.

0 commit comments

Comments
 (0)
Please sign in to comment.