Skip to content

Commit f091ed5

Browse files
committed
Create codespaces configuration
Allows for easy dev setup by installing dependencies, setting up a db, and updating the db revision for you (pending codespaces GA)
1 parent 182a5f2 commit f091ed5

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM mcr.microsoft.com/vscode/devcontainers/universal:1-linux
2+
3+
USER root
4+
5+
# Add LDAP and python dependency build deps
6+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && \
7+
apt-get -yq --no-install-recommends install gcc curl libsasl2-dev libldap2-dev libssl-dev python3-dev
8+
9+
USER codespace

.devcontainer/devcontainer.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Update the VARIANT arg in docker-compose.yml to pick a Python version: 3, 3.8, 3.7, 3.6
2+
{
3+
"name": "Packet Codespace (python and postgres)",
4+
"dockerComposeFile": "docker-compose.yaml",
5+
"service": "app",
6+
"mounts": [ "source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind" ],
7+
8+
// Set *default* container specific settings.json values on container create.
9+
"settings": {
10+
"sqltools.connections": [{
11+
"name": "Container database",
12+
"driver": "PostgreSQL",
13+
"previewLimit": 50,
14+
"server": "localhost",
15+
"port": 5432,
16+
"database": "postgres",
17+
"username": "postgres",
18+
"password": "mysecretpassword"
19+
}],
20+
"terminal.integrated.shell.linux": "/bin/bash",
21+
"python.pythonPath": "/opt/python/latest/bin/python",
22+
"python.linting.enabled": true,
23+
"python.linting.pylintEnabled": true,
24+
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
25+
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
26+
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
27+
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
28+
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
29+
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
30+
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
31+
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
32+
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
33+
"python.testing.pytestPath": "/usr/local/py-utils/bin/pytest"
34+
},
35+
"remoteUser": "codespace",
36+
"overrideCommand": false,
37+
"workspaceMount": "source=${localWorkspaceFolder},target=/home/codespace/workspace,type=bind,consistency=cached",
38+
"workspaceFolder": "/home/codespace/workspace",
39+
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined", "--privileged", "--init" ],
40+
41+
// Add the IDs of extensions you want installed when the container is created.
42+
"extensions": [
43+
"GitHub.vscode-pull-request-github",
44+
"ms-python.python",
45+
"mtxr.sqltools",
46+
"mtxr.sqltools-driver-pg"
47+
],
48+
49+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
50+
// "forwardPorts": [5000, 5432],
51+
52+
// Use 'postCreateCommand' to run commands after the container is created.
53+
// "oryx build" will automatically install your dependencies and attempt to build your project
54+
"postCreateCommand": [
55+
"pip install --progress-bar=off install -r requirements.txt;",
56+
"yarn install && `yarn bin gulp production`;",
57+
"/home/codespace/.local/bin/flask db upgrade;"
58+
]
59+
}

.devcontainer/docker-compose.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: '3'
2+
3+
services:
4+
app:
5+
build:
6+
context: ..
7+
dockerfile: .devcontainer/Dockerfile
8+
args:
9+
NODE_VERSION: "10"
10+
11+
volumes:
12+
- ..:/workspace:cached
13+
14+
# Overrides default command so things don't shut down after the process ends.
15+
command: sleep infinity
16+
17+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
18+
network_mode: service:db
19+
20+
# Uncomment the next line to use a non-root user for all processes.
21+
user: codespace
22+
23+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
24+
# (Adding the "ports" property to this file will not forward from a Codespace.)
25+
26+
db:
27+
image: postgres:latest
28+
restart: unless-stopped
29+
volumes:
30+
- postgres-data:/var/lib/postgresql/data
31+
environment:
32+
POSTGRES_USER: postgres
33+
POSTGRES_DB: postgres
34+
POSTGRES_PASSWORD: mysecretpassword
35+
36+
# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward MongoDB locally.
37+
# (Adding the "ports" property to this file will not forward from a Codespace.)
38+
39+
volumes:
40+
postgres-data:

0 commit comments

Comments
 (0)