From 07fe457a9033baf9a534258105488f0b57853f7d Mon Sep 17 00:00:00 2001 From: lumin <71011125+l-melon@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:15:16 +0900 Subject: [PATCH 1/2] feat: add devcontainer configuration and installation script Add a devcontainer configuration to streamline the development environment setup. Introduce an `install.sh` script to install the project in editable mode. Update the Dockerfile to use the `python:3.13-slim-bullseye` base image and install dependencies using `apt-get` for better compatibility. --- .devcontainer/devcontainer.json | 30 ++++++++++++++++++++++++++++++ Dockerfile | 6 ++++-- install.sh | 7 +++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 install.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..2ce479b --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,30 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile +{ + "name": "Existing Dockerfile", + "build": { + // Sets the run context to one level up instead of the .devcontainer folder. + "context": "..", + // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. + "dockerfile": "../Dockerfile" + }, + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + "features": { + "ghcr.io/devcontainers-extra/features/hatch:2": {} + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Uncomment the next line to run commands after the container is created. + // "postCreateCommand": "cat /etc/os-release", + "postCreateCommand": "./install.sh", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. + "remoteUser": "root" +} diff --git a/Dockerfile b/Dockerfile index 492ad8a..f9c0bef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,11 @@ -FROM python:3.13-alpine +FROM python:3.13-slim-bullseye USER root # Runtime dependency -RUN apk add --no-cache ffmpeg +RUN apt-get update && apt-get install -y --no-install-recommends \ + ffmpeg \ + && rm -rf /var/lib/apt/lists/* RUN pip install markitdown diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..7133c15 --- /dev/null +++ b/install.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# Install the current project in editable mode +echo "Installing the project in editable mode..." +pip install -e . + +echo "Setup complete!" From e0a30295ffdee37d0dbaaa6568cfdbfa48ecfe30 Mon Sep 17 00:00:00 2001 From: lumin <71011125+l-melon@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:36:15 +0900 Subject: [PATCH 2/2] docs: update README with Devcontainer instructions Add instructions for using Dev to run tests.Remove the install script it is no longer needed. Update trademark section for clarity. --- .devcontainer/devcontainer.json | 1 - README.md | 11 +++++++++-- install.sh | 7 ------- 3 files changed, 9 insertions(+), 10 deletions(-) delete mode 100644 install.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2ce479b..f12fbcb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -20,7 +20,6 @@ // Uncomment the next line to run commands after the container is created. // "postCreateCommand": "cat /etc/os-release", - "postCreateCommand": "./install.sh", // Configure tool-specific properties. // "customizations": {}, diff --git a/README.md b/README.md index 7079dbf..1de6cdc 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,13 @@ hatch shell hatch test ``` +Alternative method: using Devcontainer +- Reopen project in the Devcontainer (via the Command Palette: `Reopen in Container`) +- Once inside the container, run: +```sh +hatch test +``` + ### Running Pre-commit Checks Please run the pre-commit checks before submitting a PR. @@ -113,8 +120,8 @@ pre-commit run --all-files ## Trademarks -This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft -trademarks or logos is subject to and must follow +This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft +trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies. diff --git a/install.sh b/install.sh deleted file mode 100644 index 7133c15..0000000 --- a/install.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# Install the current project in editable mode -echo "Installing the project in editable mode..." -pip install -e . - -echo "Setup complete!"