Skip to content

Commit 196131c

Browse files
authored
Create a devcontainer to ease dev setup (#1381)
1 parent 311439b commit 196131c

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.231.5/containers/ubuntu/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Ubuntu version (use hirsuite or bionic on local arm64/Apple Silicon): hirsute, focal, bionic
4+
ARG VARIANT="hirsute"
5+
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
6+
7+
# [Optional] Uncomment this section to install additional OS packages.
8+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
9+
# && apt-get -y install --no-install-recommends \

.devcontainer/devcontainer.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.231.5/containers/ubuntu
3+
{
4+
"name": "Ubuntu",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
// Update 'VARIANT' to pick an Ubuntu version: hirsute, focal, bionic
8+
// Use hirsute or bionic on local arm64/Apple Silicon.
9+
"args": {
10+
"VARIANT": "focal"
11+
}
12+
},
13+
// Set *default* container specific settings.json values on container create.
14+
"settings": {
15+
"[python]": {
16+
"editor.codeActionsOnSave": {
17+
"source.organizeImports": true,
18+
"editor.formatOnSave": true,
19+
},
20+
"editor.formatOnSave": true, // Required to actually format on save
21+
},
22+
"editor.rulers": [
23+
80, // default color or as customized (with "editorRuler.foreground")
24+
{
25+
"column": 88,
26+
"color": "#ff000065"
27+
},
28+
],
29+
"python.defaultInterpreterPath": "/usr/local/python/bin/python",
30+
"python.formatting.provider": "black",
31+
"python.linting.mypyEnabled": true,
32+
"python.linting.mypyPath": "mypy",
33+
"python.linting.mypyArgs": [
34+
"--follow-imports=silent",
35+
"--ignore-missing-imports",
36+
"--show-column-numbers",
37+
"--show-error-codes"
38+
],
39+
"python.linting.ignorePatterns": [
40+
"**/site-packages/",
41+
".vscode/*.py",
42+
"**/.tox/",
43+
"*.pyi",
44+
"**/dist/"
45+
],
46+
"search.exclude": {
47+
"**/build/lib/*": true,
48+
"**/dist/*": true,
49+
},
50+
"python.testing.pytestArgs": [
51+
"--no-cov",
52+
"-v",
53+
"tests/"
54+
],
55+
"python.testing.pytestEnabled": true,
56+
"python.testing.pytestPath": "pytest",
57+
},
58+
// Add the IDs of extensions you want installed when the container is created.
59+
"extensions": [
60+
"njpwerner.autodocstring",
61+
"yzhang.markdown-all-in-one",
62+
"ms-python.python",
63+
"littlefoxteam.vscode-python-test-adapter",
64+
"ms-vscode-remote.remote-containers",
65+
"hbenl.vscode-test-explorer",
66+
"trond-snekvik.simple-rst",
67+
"wayou.vscode-todo-highlight",
68+
"ms-azuretools.vscode-docker"
69+
],
70+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
71+
"forwardPorts": [
72+
// The jira server instance we run via docker is exposed on:
73+
2990
74+
],
75+
// Use 'postCreateCommand' to run commands after the container is created.
76+
"postCreateCommand": "./.devcontainer/post_create.sh",
77+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
78+
// "remoteUser": "vscode",
79+
"features": {
80+
"docker-in-docker": "latest",
81+
"git": "latest",
82+
"python": "3.10"
83+
}
84+
}

.devcontainer/post_create.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
# This file is run from the .vscode folder
3+
WORKSPACE_FOLDER=/workspaces/jira
4+
5+
# Start the Jira Server docker instance first so can be running while we initialise everything else
6+
# Need to ensure this --version matches what is in CI
7+
echo "Initiating jira server instance, use the docker extension to inspect the logs (takes around 10/15mins to startup)"
8+
docker run -dit -p 2990:2990 --name jira addono/jira-software-standalone --version 8.17.1
9+
echo "Once started up, Jira host port is forwarded and can be found on: localhost:2990/jira/"
10+
11+
# For Windows uses that have cloned into Windows' partition, we do this so that
12+
# it doesn't show all the files as "changed" for having different line endings.
13+
# As we use pre-commit for managing our line endings we do this to tell git we don't care
14+
git config --global core.autocrlf input
15+
git add .
16+
17+
# Install tox and pre-commit
18+
pipx install pre-commit
19+
pipx install tox
20+
21+
# Sanity check that we can run pre-commit env
22+
pre-commit run mypy --all-files
23+
24+
# Set the PIP_CONSTRAINT env variable
25+
PIP_CONSTRAINT=$WORKSPACE_FOLDER/constraints.txt
26+
if [ -f "$PIP_CONSTRAINT" ]; then
27+
echo "$PIP_CONSTRAINT found, use 'unset PIP_CONSTRAINT' if you want to remove the constraints."
28+
echo "export PIP_CONSTRAINT="$PIP_CONSTRAINT"" >> ~/.bashrc && source ~/.bashrc
29+
else
30+
echo "$PIP_CONSTRAINT was not found, dependencies are not controlled."
31+
fi
32+
33+
# Install package in editable mode with test dependencies
34+
pip install -e .[test]

0 commit comments

Comments
 (0)