Skip to content

Commit f0298d4

Browse files
authored
Merge pull request #234 from mxmeinhold/code-spaces
2 parents 9a706d2 + dcc1a08 commit f0298d4

File tree

4 files changed

+109
-1
lines changed

4 files changed

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

.devcontainer/docker-compose.yaml

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

.github/workflows/python-app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
steps:
2121
- name: Install ldap dependencies
22-
run: sudo apt-get install libldap2-dev libsasl2-dev
22+
run: sudo apt-get update && sudo apt-get install libldap2-dev libsasl2-dev
2323
- uses: actions/checkout@v2
2424
- name: Set up Python ${{ matrix.python-version }}
2525
uses: actions/setup-python@v2

0 commit comments

Comments
 (0)