Skip to content

Commit 1e7b447

Browse files
author
nick
committed
misc: devcontainer configuration for vscode
- Legacy-Id: 19477
1 parent 3386e59 commit 1e7b447

8 files changed

Lines changed: 543 additions & 0 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.202.5/containers/python-3/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
4+
ARG VARIANT="3.10-bullseye"
5+
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
6+
7+
EXPOSE 8000
8+
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
RUN apt-get update
12+
RUN apt-get -qy upgrade
13+
14+
# Install the packages we need
15+
RUN apt-get install -qy \
16+
build-essential \
17+
bzip2 \
18+
ca-certificates \
19+
colordiff \
20+
gawk \
21+
gcc \
22+
python3-ipython \
23+
jq \
24+
less \
25+
libbz2-dev \
26+
libdb5.3-dev \
27+
libexpat1-dev \
28+
libffi-dev \
29+
libgdbm-dev \
30+
libjpeg62-turbo-dev \
31+
liblzma-dev \
32+
libmagic1 \
33+
libmariadb-dev-compat \
34+
libmariadb-dev \
35+
libncurses5-dev \
36+
libncursesw5-dev \
37+
libreadline-dev \
38+
libsqlite3-dev \
39+
libssl-dev \
40+
libsvn1 \
41+
libxml2-dev \
42+
libxslt-dev \
43+
libyang1 \
44+
libz-dev \
45+
libffi-dev \
46+
locales \
47+
make \
48+
man \
49+
mariadb-client \
50+
netcat \
51+
openssh-client \
52+
patch \
53+
procps \
54+
pv \
55+
rsync \
56+
rsyslog \
57+
subversion \
58+
sudo \
59+
uuid-dev \
60+
vim \
61+
wget \
62+
xz-utils\
63+
zile \
64+
zlib1g-dev
65+
66+
# Install libyang
67+
# RUN wget -nv http://download.opensuse.org/repositories/home:liberouter/Debian_9.0/Release.key && \
68+
# apt-key add - < Release.key && \
69+
# rm Release.key && \
70+
# echo "deb http://download.opensuse.org/repositories/home:/liberouter/Debian_9.0/ /" >> /etc/apt/sources.list.d/libyang.list && \
71+
# apt-get update && \
72+
# apt-get install -qy libyang1
73+
74+
# Install chromedriver
75+
RUN apt-get update && \
76+
apt-get install -y gnupg wget curl unzip --no-install-recommends && \
77+
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
78+
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list && \
79+
apt-get update -y && \
80+
apt-get install -y google-chrome-stable && \
81+
CHROMEVER=$(google-chrome --product-version | grep -o "[^\.]*\.[^\.]*\.[^\.]*") && \
82+
DRIVERVER=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROMEVER") && \
83+
wget -q --continue -P /chromedriver "http://chromedriver.storage.googleapis.com/$DRIVERVER/chromedriver_linux64.zip" && \
84+
unzip /chromedriver/chromedriver* -d /chromedriver && \
85+
ln -s /chromedriver/chromedriver /usr/local/bin/chromedriver && \
86+
ln -s /chromedriver/chromedriver /usr/bin/chromedriver
87+
88+
# Get rid of installation files we don't need in the image, to reduce size
89+
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
90+
91+
# Enable some common locales
92+
RUN sed -i -e 's/^. en_US/en_US/' -e 's/^. en_GB/en_GB/' -e 's/^. en_IE/en_IE/' /etc/locale.gen && \
93+
locale-gen
94+
95+
# Remove an rsyslog module that we don't need, which also requires extra permissions
96+
RUN sed -i -e '/load="imklog"/d' /etc/rsyslog.conf
97+
98+
# Set up root password
99+
RUN echo "root:root" | chpasswd
100+
101+
# idnits and dependencies
102+
ADD https://tools.ietf.org/tools/idnits/idnits /usr/local/bin/
103+
RUN chmod +rx /usr/local/bin/idnits
104+
105+
# Directory for Mac certs
106+
RUN mkdir /etc/certificates
107+
108+
# Setup workspace
109+
ENV HOSTNAME="datatracker"
110+
111+
ENV DDIR="/usr/local/share/datatracker"
112+
RUN mkdir -p $DDIR
113+
WORKDIR $DDIR
114+
115+
COPY requirements.txt /tmp/pip-tmp/
116+
RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
117+
&& rm -rf /tmp/pip-tmp
118+
119+
COPY .devcontainer/init.sh /docker-init.sh
120+
RUN chmod +x /docker-init.sh
121+
ENTRYPOINT ["/docker-init.sh"]
122+
CMD ["sleep", "infinity"]
123+
124+
# [Optional] Uncomment this section to install additional OS packages.
125+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
126+
# && apt-get -y install --no-install-recommends <your-package-list-here>
127+
128+
# [Optional] Uncomment this line to install global node packages.
129+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

.devcontainer/devcontainer.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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.202.5/containers/python-3
3+
{
4+
"name": "IETF Datatracker",
5+
"dockerComposeFile": "docker-compose.yml",
6+
"service": "app",
7+
"workspaceFolder": "/usr/local/share/datatracker",
8+
"shutdownAction": "stopCompose",
9+
10+
// Set *default* container specific settings.json values on container create.
11+
"settings": {
12+
"python.pythonPath": "/usr/local/bin/python",
13+
"python.languageServer": "Pylance",
14+
"python.linting.enabled": true,
15+
"python.linting.pylintEnabled": true,
16+
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
17+
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
18+
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
19+
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
20+
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
21+
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
22+
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
23+
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
24+
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
25+
"python.testing.pytestArgs": [
26+
"ietf"
27+
],
28+
"python.testing.unittestEnabled": true,
29+
"python.testing.pytestEnabled": false,
30+
"python.testing.unittestArgs": [
31+
"-v",
32+
"-s",
33+
"./ietf",
34+
"-p",
35+
"test*.py"
36+
]
37+
},
38+
39+
// Add the IDs of extensions you want installed when the container is created.
40+
"extensions": [
41+
"ms-python.python",
42+
"ms-python.vscode-pylance",
43+
"ms-azuretools.vscode-docker",
44+
"editorconfig.editorconfig",
45+
"redhat.vscode-yaml",
46+
"visualstudioexptteam.vscodeintellicode",
47+
"batisteo.vscode-django",
48+
"littlefoxteam.vscode-python-test-adapter"
49+
],
50+
51+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
52+
"forwardPorts": [8000, 3306],
53+
54+
// Use 'postCreateCommand' to run commands after the container is created.
55+
// "postCreateCommand": "sh /docker-init.sh",
56+
57+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
58+
// "remoteUser": "django"
59+
}

.devcontainer/docker-compose.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
build:
6+
context: ..
7+
dockerfile: .devcontainer/Dockerfile
8+
args:
9+
# Update 'VARIANT' to pick a version of Python: 3, 3.10, 3.9, 3.8, 3.7, 3.6
10+
# Append -bullseye or -buster to pin to an OS version.
11+
# Use -bullseye variants on local arm64/Apple Silicon.
12+
VARIANT: 3.6-bullseye
13+
14+
volumes:
15+
- ..:/usr/local/share/datatracker:cached
16+
init: true
17+
18+
# Overrides default command so things don't shut down after the process ends.
19+
command: sleep infinity
20+
21+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
22+
network_mode: service:db
23+
24+
depends_on:
25+
- db
26+
27+
environment:
28+
USER: django
29+
UID: 1001
30+
GID: 1001
31+
DATADIR: data
32+
33+
# Uncomment the next line to use a non-root user for all processes.
34+
# user: vscode
35+
36+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
37+
# (Adding the "ports" property to this file will not forward from a Codespace.)
38+
39+
db:
40+
image: mariadb:10
41+
restart: unless-stopped
42+
volumes:
43+
- mariadb-data:/var/lib/mysql
44+
environment:
45+
MYSQL_ROOT_PASSWORD: ietf
46+
MYSQL_DATABASE: ietf_utf8
47+
MYSQL_USER: django
48+
MYSQL_PASSWORD: RkTkDPFnKpko
49+
command: ['--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci']
50+
51+
52+
# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
53+
# (Adding the "ports" property to this file will not forward from a Codespace.)
54+
55+
volumes:
56+
mariadb-data:

0 commit comments

Comments
 (0)