diff --git a/.dockerignore b/.dockerignore index 6288a4d..db7e340 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,8 +1,8 @@ .env - -# NODE -node_modules - -# PYTHON __pycache__ .venv +.pytest_cache +docs +node_modules +output +sketching diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml new file mode 100644 index 0000000..1e667cf --- /dev/null +++ b/.github/workflows/build-image.yaml @@ -0,0 +1,33 @@ +name: Build Docker Image + +on: + push: + tags: + - "docker/*" + +jobs: + docker: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + id-token: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + tags: ghcr.io/bcye/structured-wikivoyage-exports:latest diff --git a/Dockerfile b/Dockerfile index 4dfe203..161a820 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,10 @@ -FROM node:22 +FROM ghcr.io/astral-sh/uv:0.6-python3.12-bookworm WORKDIR /app -COPY package.json . -COPY package-lock.json . +COPY pyproject.toml uv.lock ./ +RUN uv sync --frozen -RUN npm install +COPY . . -COPY index.ts . - -CMD [ "node", "--max-old-space-size=4096", "--experimental-strip-types", "index.ts" ] +CMD ["uv", "run", "main.py"] \ No newline at end of file diff --git a/README.md b/README.md index 02cb2a5..69a1aaa 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,15 @@ Small utility to convert the wikitext data from the Wikivoyage dumps into a structured format. The goal is to make it easier to work with the data and extract useful information programmatically. -## Installation +## Usage + +### Docker + +This script is intended to be run with docker. A docker image is [available from the GitHub registry](https://github.com/bcye/structured-wikivoyage-exports/pkgs/container/structured-wikivoyage-exports). For example, you may run it using the filesystem handler with `docker run -e HANDLER=filesystem -e HANDLER_FILESYSTEM_OUTPUT_DIR=/output -v ./output:/output --ulimit nofile=65536:65536 ghcr.io/bcye/structured-wikivoyage-exports`. For all the different options, refer to [the docs](docs). + +### Types + +TypeScript types for consuming the json output are available, you may install them from the [@bcye/structured-wikivoyage-types](https://www.npmjs.com/package/@bcye/structured-wikivoyage-types) npm package. Refer to the included docstrings in [types/index.d.ts](types/index.d.ts) for reference. ## Documentation @@ -22,4 +30,4 @@ All code and documentation unless otherwise stated is licensed under the AGPLv3 ### Examples -Files in the `docs/example` and `tests/fixtures` are copies (.txt) or derivatives (.json) of the Boston Article on Wikivoyage and licensed under CC BY-SA 4.0. A [list of contributors is available on the original article](https://en.wikivoyage.org/w/index.php?title=Boston&action=history). +Files in the `docs/example` and `tests/fixtures` are copies (.txt) or derivatives (.json) of the Boston Article on Wikivoyage and licensed under CC BY-SA 4.0. A [list of contributors is available on the original article](https://en.wikivoyage.org/w/index.php?title=Boston&action=history). \ No newline at end of file