Skip to content

Commit 192a52e

Browse files
committed
feat: python switch to dockerfile
1 parent 0e50dc7 commit 192a52e

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# To use:
2+
#
3+
# pre-commit run -a
4+
#
5+
# Or:
6+
#
7+
# pre-commit install # (runs every time you commit in git)
8+
#
9+
# To update this file:
10+
#
11+
# pre-commit autoupdate
12+
#
13+
# See https://github.com/pre-commit/pre-commit
14+
15+
repos:
16+
# Standard hooks
17+
- repo: https://github.com/pre-commit/pre-commit-hooks
18+
rev: v4.5.0
19+
hooks:
20+
- id: check-added-large-files
21+
- id: check-case-conflict
22+
- id: check-docstring-first
23+
- id: check-merge-conflict
24+
- id: check-symlinks
25+
- id: check-toml
26+
- id: debug-statements
27+
- id: mixed-line-ending
28+
- id: requirements-txt-fixer
29+
- id: trailing-whitespace
30+
31+
- repo: https://github.com/timothycrosley/isort
32+
rev: 5.13.2
33+
hooks:
34+
- id: isort
35+
exclude: ^(docs/)|(project/)|(assignments/)|(project/interface/)|(examples/)
36+
37+
# - repo: https://github.com/pre-commit/mirrors-mypy
38+
# rev: v1.8.0
39+
# hooks:
40+
# - id: mypy
41+
# exclude: ^(docs/)|(project/)|(assignments/)|(project/interface/)|(examples/)
42+
43+
- repo: https://github.com/psf/black
44+
rev: 24.4.2
45+
hooks:
46+
- id: black
47+
48+
- repo: https://github.com/astral-sh/ruff-pre-commit
49+
rev: v0.4.7
50+
hooks:
51+
- id: ruff
52+
- id: ruff-format
53+
54+
# # Doc linter
55+
# - repo: https://github.com/terrencepreilly/darglint
56+
# rev: v1.8.1
57+
# hooks:
58+
# - id: darglint
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
ARG VARIANT=3.12
2+
FROM python:${VARIANT}
3+
4+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
5+
# Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
6+
&& apt-get purge -y imagemagick imagemagick-6-common
7+
8+
# Temporary: Upgrade python packages due to https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-40897 and https://github.com/advisories/GHSA-2mqj-m65w-jghx
9+
# They are installed by the base image (python) which does not have the patch.
10+
RUN python3 -m pip install --upgrade \
11+
setuptools==69.0.3 \
12+
gitpython==3.1.41
13+
14+
# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
15+
COPY .pre-commit-config.yaml /tmp/
16+
COPY requirements.txt /tmp/pip-tmp/
17+
RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
18+
&& rm -rf /tmp/pip-tmp
19+
20+
# [Optional] Uncomment this section to install additional OS packages.
21+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
22+
&& apt-get -y install --no-install-recommends nodejs npm \
23+
&& rm -rf /var/lib/apt/lists/*
24+
25+
# [Optional] Uncomment this line to install global node packages.
26+
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g husky" 2>&1

src/python/.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"image": "mcr.microsoft.com/devcontainers/python",
2+
"dockerFile": "Dockerfile",
33
"features": {
44
"ghcr.io/devcontainers-contrib/features/black:2": {},
55
"ghcr.io/devcontainers-contrib/features/cz-cli:1": {},
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
black==24.4.2
2+
commitizen==3.27.0
3+
pre-commit==2.21.0
4+
requests==2.32.2
5+
ruff==0.4.7

0 commit comments

Comments
 (0)