From 2c9e0436a7dff2a6a8d8c92f0d6e75a40d86c629 Mon Sep 17 00:00:00 2001 From: Fabian Reinold Date: Mon, 4 May 2026 20:02:07 +0200 Subject: [PATCH 1/6] feat: add Copier-based Python template scaffold --- .coderabbit.yaml | 7 ++ .github/workflows/dependency-review.yml | 2 +- .github/workflows/deploy-docs.yml | 52 +++++++++++ .github/workflows/ruff.yml | 17 ++++ .github/workflows/scorecard.yml | 38 ++++++++ ...ckend %}backend-tests.yml{% endif %}.jinja | 28 ++++++ ...ocker-release-backend.yml{% endif %}.jinja | 63 +++++++++++++ ...cker-release-frontend.yml{% endif %}.jinja | 63 +++++++++++++ ... %}docker-release-job.yml{% endif %}.jinja | 63 +++++++++++++ .pre-commit-config.yaml | 25 +++++ CODE_OF_CONDUCT.md | 4 +- CONTRIBUTING.md | 15 +++ Dockerfile | 8 -- LICENSE => LICENSE.jinja | 4 +- README.md | 81 ---------------- README.md.jinja | 77 +++++++++++++++ compose.yaml.jinja | 27 ++++++ copier.yml | 93 +++++++++++++++++++ docs/.gitkeep | 0 docs/.vitepress/config.mts.jinja | 10 ++ docs/guide/index.md.jinja | 5 + docs/index.md.jinja | 19 ++++ docs/package.json.jinja | 14 +++ renovate.json5 | 6 -- renovate.json5.jinja | 38 ++++++++ ruff.toml.jinja | 49 ++++++++++ {{ _copier_conf.answers_file }}.jinja | 2 + {{project_name}}-backend/.dockerignore | 8 ++ {{project_name}}-backend/.python-version | 1 + {{project_name}}-backend/Dockerfile.jinja | 38 ++++++++ {{project_name}}-backend/README.md.jinja | 10 ++ {{project_name}}-backend/main.py.jinja | 7 ++ {{project_name}}-backend/pyproject.toml.jinja | 31 +++++++ .../test/test_app.py.jinja | 12 +++ .../{{module_name}}/app.py.jinja | 15 +++ .../{{module_name}}/settings.py.jinja | 11 +++ {{project_name}}-frontend/.dockerignore | 4 + {{project_name}}-frontend/Dockerfile.jinja | 37 ++++++++ {{project_name}}-frontend/README.md.jinja | 10 ++ .../docker/nginx/default.conf | 10 ++ {{project_name}}-frontend/index.html.jinja | 15 +++ {{project_name}}-frontend/package.json.jinja | 24 +++++ {{project_name}}-frontend/src/App.vue.jinja | 6 ++ {{project_name}}-frontend/src/main.ts | 5 + {{project_name}}-frontend/src/style.css | 18 ++++ {{project_name}}-frontend/tsconfig.app.json | 4 + {{project_name}}-frontend/tsconfig.json | 4 + {{project_name}}-frontend/tsconfig.node.json | 10 ++ {{project_name}}-frontend/vite.config.ts | 6 ++ {{project_name}}-job/.dockerignore | 8 ++ {{project_name}}-job/.python-version | 1 + {{project_name}}-job/Dockerfile.jinja | 38 ++++++++ {{project_name}}-job/README.md.jinja | 10 ++ {{project_name}}-job/main.py | 17 ++++ {{project_name}}-job/pyproject.toml.jinja | 25 +++++ {{project_name}}-job/test/test_main.py.jinja | 31 +++++++ .../{{module_name}}/worker.py | 7 ++ 57 files changed, 1133 insertions(+), 100 deletions(-) create mode 100644 .coderabbit.yaml create mode 100644 .github/workflows/deploy-docs.yml create mode 100644 .github/workflows/ruff.yml create mode 100644 .github/workflows/scorecard.yml create mode 100644 .github/workflows/{% if backend %}backend-tests.yml{% endif %}.jinja create mode 100644 .github/workflows/{% if backend %}docker-release-backend.yml{% endif %}.jinja create mode 100644 .github/workflows/{% if frontend %}docker-release-frontend.yml{% endif %}.jinja create mode 100644 .github/workflows/{% if job %}docker-release-job.yml{% endif %}.jinja create mode 100644 .pre-commit-config.yaml create mode 100644 CONTRIBUTING.md delete mode 100644 Dockerfile rename LICENSE => LICENSE.jinja (92%) delete mode 100644 README.md create mode 100644 README.md.jinja create mode 100644 compose.yaml.jinja create mode 100644 copier.yml delete mode 100644 docs/.gitkeep create mode 100644 docs/.vitepress/config.mts.jinja create mode 100644 docs/guide/index.md.jinja create mode 100644 docs/index.md.jinja create mode 100644 docs/package.json.jinja delete mode 100644 renovate.json5 create mode 100644 renovate.json5.jinja create mode 100644 ruff.toml.jinja create mode 100644 {{ _copier_conf.answers_file }}.jinja create mode 100644 {{project_name}}-backend/.dockerignore create mode 100644 {{project_name}}-backend/.python-version create mode 100644 {{project_name}}-backend/Dockerfile.jinja create mode 100644 {{project_name}}-backend/README.md.jinja create mode 100644 {{project_name}}-backend/main.py.jinja create mode 100644 {{project_name}}-backend/pyproject.toml.jinja create mode 100644 {{project_name}}-backend/test/test_app.py.jinja create mode 100644 {{project_name}}-backend/{{module_name}}/app.py.jinja create mode 100644 {{project_name}}-backend/{{module_name}}/settings.py.jinja create mode 100644 {{project_name}}-frontend/.dockerignore create mode 100644 {{project_name}}-frontend/Dockerfile.jinja create mode 100644 {{project_name}}-frontend/README.md.jinja create mode 100644 {{project_name}}-frontend/docker/nginx/default.conf create mode 100644 {{project_name}}-frontend/index.html.jinja create mode 100644 {{project_name}}-frontend/package.json.jinja create mode 100644 {{project_name}}-frontend/src/App.vue.jinja create mode 100644 {{project_name}}-frontend/src/main.ts create mode 100644 {{project_name}}-frontend/src/style.css create mode 100644 {{project_name}}-frontend/tsconfig.app.json create mode 100644 {{project_name}}-frontend/tsconfig.json create mode 100644 {{project_name}}-frontend/tsconfig.node.json create mode 100644 {{project_name}}-frontend/vite.config.ts create mode 100644 {{project_name}}-job/.dockerignore create mode 100644 {{project_name}}-job/.python-version create mode 100644 {{project_name}}-job/Dockerfile.jinja create mode 100644 {{project_name}}-job/README.md.jinja create mode 100644 {{project_name}}-job/main.py create mode 100644 {{project_name}}-job/pyproject.toml.jinja create mode 100644 {{project_name}}-job/test/test_main.py.jinja create mode 100644 {{project_name}}-job/{{module_name}}/worker.py diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 0000000..3efc99f --- /dev/null +++ b/.coderabbit.yaml @@ -0,0 +1,7 @@ +# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json +reviews: + profile: "chill" + review_status: true + auto_review: + enabled: true + auto_incremental_review: true diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 800dfb1..7a8f6fa 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -7,4 +7,4 @@ jobs: dependency-review: runs-on: ubuntu-latest steps: - - uses: it-at-m/lhm_actions/action-templates/actions/action-dependency-review@691ffa2542ed7cc1c53c416d22ace9a153d5152f # v1.0.21 \ No newline at end of file + - uses: it-at-m/lhm_actions/action-templates/actions/action-dependency-review@691ffa2542ed7cc1c53c416d22ace9a153d5152f # v1.0.21 diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 0000000..03fa31c --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,52 @@ +name: Deploy documentation website + +on: + push: + branches: + - main + paths: + - "docs/**" + - ".github/workflows/deploy-docs.yml" + pull_request: + paths: + - "docs/**" + - ".github/workflows/deploy-docs.yml" + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + with: + node-version: "22" + - name: Install docs dependencies + working-directory: docs + run: npm install + - name: Build docs site + working-directory: docs + run: npm run build + - uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0 + - uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0 + with: + path: docs/.vitepress/dist + + deploy: + if: "github.event_name == 'push' && github.ref == 'refs/heads/main'" + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: "${{ steps.deployment.outputs.page_url }}" + steps: + - id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 0000000..407a15f --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,17 @@ +name: Ruff + +on: + push: + pull_request: + +permissions: + contents: read + +jobs: + ruff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: astral-sh/ruff-action@0ce1b0bf8b818ef400413f810f8a11cdbda0034b # v4.0.0 + with: + args: check --config ruff.toml diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml new file mode 100644 index 0000000..43c00ff --- /dev/null +++ b/.github/workflows/scorecard.yml @@ -0,0 +1,38 @@ +# This workflow uses actions that are not certified by GitHub. +name: Scorecard supply-chain security + +on: + branch_protection_rule: + schedule: + - cron: "43 9 * * 5" + push: + branches: [ "main" ] + +permissions: read-all + +jobs: + analysis: + name: Scorecard analysis + runs-on: ubuntu-latest + if: "github.event.repository.default_branch == github.ref_name || + github.event_name == 'pull_request'" + permissions: + security-events: write + id-token: write + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: ossf/scorecard-action@v2.4.2 + with: + results_file: results.sarif + results_format: sarif + publish_results: true + - uses: actions/upload-artifact@v4 + with: + name: SARIF file + path: results.sarif + retention-days: 5 + - uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: results.sarif diff --git a/.github/workflows/{% if backend %}backend-tests.yml{% endif %}.jinja b/.github/workflows/{% if backend %}backend-tests.yml{% endif %}.jinja new file mode 100644 index 0000000..f2ea5bb --- /dev/null +++ b/.github/workflows/{% if backend %}backend-tests.yml{% endif %}.jinja @@ -0,0 +1,28 @@ +name: Backend Tests + +on: +pull_request: +paths: +- "{{ project_name }}-backend/**" +- ".github/workflows/backend-tests.yml" + +permissions: +contents: read + +jobs: +backend-tests: +runs-on: ubuntu-latest +defaults: +run: +working-directory: "{{ project_name }}-backend" +steps: +- uses: actions/checkout@v4 +- uses: astral-sh/setup-uv@v4 +with: +python-version-file: "{{ project_name }}-backend/.python-version" +- name: Install dependencies +run: uv sync --group dev +- name: Run backend tests +run: uv run pytest +env: +OPENAI_API_KEY: dummykey \ No newline at end of file diff --git a/.github/workflows/{% if backend %}docker-release-backend.yml{% endif %}.jinja b/.github/workflows/{% if backend %}docker-release-backend.yml{% endif %}.jinja new file mode 100644 index 0000000..d79dc9f --- /dev/null +++ b/.github/workflows/{% if backend %}docker-release-backend.yml{% endif %}.jinja @@ -0,0 +1,63 @@ +name: Build and Release Backend Docker Image + +permissions: +contents: read + +on: +push: +tags: +- "backend-*" +workflow_dispatch: +inputs: +tag: +description: "Backend tag to release (e.g., backend-1.0.0)" +required: true +default: "backend-latest" + +jobs: +build-and-push-backend: +runs-on: ubuntu-latest +permissions: +actions: write +packages: write +steps: +- uses: actions/checkout@v4.2.2 +- uses: docker/setup-qemu-action@v3.6.0 +- uses: docker/setup-buildx-action@v3.11.1 +- uses: docker/login-action@v3.4.0 +with: +registry: ghcr.io +username: {% raw %}${{ github.actor }}{% endraw %} +password: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} +- name: Extract version from backend tag +id: vars +run: | +if [[ "{% raw %}${{ github.event_name }}{% endraw %}" == "workflow_dispatch" ]]; then +FULL_TAG="{% raw %}${{ github.event.inputs.tag }}{% endraw %}" +else +FULL_TAG=${GITHUB_REF#refs/tags/} +fi + +if [[ "$FULL_TAG" =~ ^backend-(.+)$ ]]; then +VERSION="${BASH_REMATCH[1]}" +else +echo "Error: Tag must start with 'backend-'" +exit 1 +fi + +echo "version=${VERSION}" >> $GITHUB_OUTPUT +echo "repo_lowercase=$(echo '{% raw %}${{ github.repository }}{% endraw %}' | tr '[:upper:]' '[:lower:]')" >> +$GITHUB_OUTPUT +- uses: docker/build-push-action@v6.18.0 +with: +context: ./{{ project_name }}-backend +file: ./{{ project_name }}-backend/Dockerfile +push: true +sbom: true +provenance: true +tags: | +ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-backend:{% raw %}${{ +steps.vars.outputs.version }}{% endraw %} +ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-backend:latest +cache-from: type=gha +cache-to: type=gha,mode=max \ No newline at end of file diff --git a/.github/workflows/{% if frontend %}docker-release-frontend.yml{% endif %}.jinja b/.github/workflows/{% if frontend %}docker-release-frontend.yml{% endif %}.jinja new file mode 100644 index 0000000..8b2bef3 --- /dev/null +++ b/.github/workflows/{% if frontend %}docker-release-frontend.yml{% endif %}.jinja @@ -0,0 +1,63 @@ +name: Build and Release Frontend Docker Image + +permissions: +contents: read + +on: +push: +tags: +- "frontend-*" +workflow_dispatch: +inputs: +tag: +description: "Frontend tag to release (e.g., frontend-1.0.0)" +required: true +default: "frontend-latest" + +jobs: +build-and-push-frontend: +runs-on: ubuntu-latest +permissions: +actions: write +packages: write +steps: +- uses: actions/checkout@v4.2.2 +- uses: docker/setup-qemu-action@v3.6.0 +- uses: docker/setup-buildx-action@v3.11.1 +- uses: docker/login-action@v3.4.0 +with: +registry: ghcr.io +username: {% raw %}${{ github.actor }}{% endraw %} +password: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} +- name: Extract version from frontend tag +id: vars +run: | +if [[ "{% raw %}${{ github.event_name }}{% endraw %}" == "workflow_dispatch" ]]; then +FULL_TAG="{% raw %}${{ github.event.inputs.tag }}{% endraw %}" +else +FULL_TAG=${GITHUB_REF#refs/tags/} +fi + +if [[ "$FULL_TAG" =~ ^frontend-(.+)$ ]]; then +VERSION="${BASH_REMATCH[1]}" +else +echo "Error: Tag must start with 'frontend-'" +exit 1 +fi + +echo "version=${VERSION}" >> $GITHUB_OUTPUT +echo "repo_lowercase=$(echo '{% raw %}${{ github.repository }}{% endraw %}' | tr '[:upper:]' '[:lower:]')" >> +$GITHUB_OUTPUT +- uses: docker/build-push-action@v6.18.0 +with: +context: ./{{ project_name }}-frontend +file: ./{{ project_name }}-frontend/Dockerfile +push: true +sbom: true +provenance: true +tags: | +ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-frontend:{% raw %}${{ +steps.vars.outputs.version }}{% endraw %} +ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-frontend:latest +cache-from: type=gha +cache-to: type=gha,mode=max \ No newline at end of file diff --git a/.github/workflows/{% if job %}docker-release-job.yml{% endif %}.jinja b/.github/workflows/{% if job %}docker-release-job.yml{% endif %}.jinja new file mode 100644 index 0000000..809653c --- /dev/null +++ b/.github/workflows/{% if job %}docker-release-job.yml{% endif %}.jinja @@ -0,0 +1,63 @@ +name: Build and Release Job Docker Image + +permissions: +contents: read + +on: +push: +tags: +- "job-*" +workflow_dispatch: +inputs: +tag: +description: "Job tag to release (e.g., job-1.0.0)" +required: true +default: "job-latest" + +jobs: +build-and-push-job: +runs-on: ubuntu-latest +permissions: +actions: write +packages: write +steps: +- uses: actions/checkout@v4.2.2 +- uses: docker/setup-qemu-action@v3.6.0 +- uses: docker/setup-buildx-action@v3.11.1 +- uses: docker/login-action@v3.4.0 +with: +registry: ghcr.io +username: {% raw %}${{ github.actor }}{% endraw %} +password: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} +- name: Extract version from job tag +id: vars +run: | +if [[ "{% raw %}${{ github.event_name }}{% endraw %}" == "workflow_dispatch" ]]; then +FULL_TAG="{% raw %}${{ github.event.inputs.tag }}{% endraw %}" +else +FULL_TAG=${GITHUB_REF#refs/tags/} +fi + +if [[ "$FULL_TAG" =~ ^job-(.+)$ ]]; then +VERSION="${BASH_REMATCH[1]}" +else +echo "Error: Tag must start with 'job-'" +exit 1 +fi + +echo "version=${VERSION}" >> $GITHUB_OUTPUT +echo "repo_lowercase=$(echo '{% raw %}${{ github.repository }}{% endraw %}' | tr '[:upper:]' '[:lower:]')" >> +$GITHUB_OUTPUT +- uses: docker/build-push-action@v6.18.0 +with: +context: ./{{ project_name }}-job +file: ./{{ project_name }}-job/Dockerfile +push: true +sbom: true +provenance: true +tags: | +ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-job:{% raw %}${{ +steps.vars.outputs.version }}{% endraw %} +ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-job:latest +cache-from: type=gha +cache-to: type=gha,mode=max \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..7f049f7 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +default_language_version: + python: python3.13 +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.14.14 + hooks: + - id: ruff-check + types_or: [python, pyi, jupyter] + args: [--fix] + - id: ruff-format + types_or: [python, pyi, jupyter] + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-ast + - id: check-json + - id: check-yaml + - id: detect-private-key + - id: pretty-format-json + args: [--autofix, --no-ensure-ascii] + exclude: '\\.ipynb$' + - repo: https://github.com/gitleaks/gitleaks + rev: v8.30.0 + hooks: + - id: gitleaks diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 766872d..da8ccc4 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -31,7 +31,7 @@ Examples of unacceptable behavior include: advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment -* Publishing others' private information, such as a physical or email +* Publishing others' private information, such as a personal or email address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting @@ -124,4 +124,4 @@ enforcement ladder](https://github.com/mozilla/diversity). For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at -https://www.contributor-covenant.org/translations. +https://www.contributor-covenant.org/translations. \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..46e36a0 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,15 @@ +# Contributing + +Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. + +If you have a suggestion that would make this better, please open an issue with the tag "enhancement", fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". +Don't forget to give the project a star! Thanks again! + +1. Open an issue with the tag "enhancement" +2. Fork the Project +3. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) +4. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) +5. Push to the Branch (`git push origin feature/AmazingFeature`) +6. Open a Pull Request + +More about this in the [CODE_OF_CONDUCT](/CODE_OF_CONDUCT.md) file. diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index ae71e59..0000000 --- a/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -# Dockerfiles may only contain a FROM and the application data. -# For Java applications use /ubi9/openjdk-11-runtime or /ubi9/openjdk-17-runtime as Base Image, for documentation -# please see https://access.redhat.com/documentation/en-us/red_hat_jboss_middleware_for_openshift/3/html/red_hat_java_s2i_for_openshift/ -# All other variations must be approved by KM8 - -FROM registry.access.redhat.com/ubi9/openjdk-17-runtime:latest - -COPY target/*.jar /deployments/application.jar diff --git a/LICENSE b/LICENSE.jinja similarity index 92% rename from LICENSE rename to LICENSE.jinja index 1331279..ae8bde7 100644 --- a/LICENSE +++ b/LICENSE.jinja @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Landeshauptstadt München | it@M +Copyright (c) {% now 'utc', '%Y' %} Landeshauptstadt München | it@M Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 7bdf9b8..0000000 --- a/README.md +++ /dev/null @@ -1,81 +0,0 @@ -## Customize this file after creating the new REPO and remove this lines. -What to adjust: -* Add the your project or repo name direct under the logo. -* Add a short and long desciption. -* Add links for your final repo to report a bug or request a feature. -* Add list of used technologies. -* If you have, add a roadmap or remove this section. -* Fill up the section for set up and documentation. - * Start in this file only with documentation and link to the docs folder. -* Add more project shields. Use [shields.io](https://shields.io/) with style `for-the-badge`. - -## ------- end to remove ------- - - -# repo or project name - -[![Made with love by it@M][made-with-love-shield]][itm-opensource] - - -*Add a description from your project here.* - - -### Built With - -The documentation project is built with technologies we use in our projects: - -* *write here the list of used technologies* - -## Roadmap - -*if you have a ROADMAP for your project add this here* - - -See the [open issues](#) for a full list of proposed features (and known issues). - - -## Set up -*how can i start and fly this project* - -## Documentation -*what insights do you have to tell* - -```mermaid -graph TD; - A-->B; - A-->C; - B-->D; - C-->D; -``` - -use [diagrams](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-diagrams). - -## Contributing - -Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. - -If you have a suggestion that would make this better, please open an issue with the tag "enhancement", fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". -Don't forget to give the project a star! Thanks again! - -1. Open an issue with the tag "enhancement" -2. Fork the Project -3. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) -4. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) -5. Push to the Branch (`git push origin feature/AmazingFeature`) -6. Open a Pull Request - -More about this in the [CODE_OF_CONDUCT](/CODE_OF_CONDUCT.md) file. - - -## License - -Distributed under the MIT License. See [LICENSE](LICENSE) file for more information. - - -## Contact - -it@M - opensource@muenchen.de - - -[made-with-love-shield]: https://img.shields.io/badge/made%20with%20%E2%9D%A4%20by-it%40M-yellow?style=for-the-badge -[itm-opensource]: https://opensource.muenchen.de/ diff --git a/README.md.jinja b/README.md.jinja new file mode 100644 index 0000000..221de27 --- /dev/null +++ b/README.md.jinja @@ -0,0 +1,77 @@ +## Customize this file after creating the new REPO and remove this lines. + +What to adjust: + +- Add a long desciption. +- Add links for your final repo to report a bug or request a feature. +- Append list of used technologies. +- If you have, add a roadmap or remove this section. +- Fill up the section for set up and documentation. +- Start in this file only with documentation and link to the docs folder. +- Add more project shields. Use [shields.io](https://shields.io/) with style `for-the-badge`. + +## ------- end to remove ------- + + + +# {{ project_name }} + +[![Made with love by it@M][made-with-love-shield]][itm-opensource] +[![Copier][copier-shield]][copier-repo] + + + +{{ short_description }} + +### Built With + +The documentation project is built with technologies we use in our projects: + +- Python +- uv +- ruff +- ty +- copier +- vitepress +- pre-commit + +## Roadmap + +_if you have a ROADMAP for your project add this here_ + +See the [open issues](#) for a full list of proposed features (and known issues). + +## Set up + +_how can i start and fly this project_ + +Copier uses Jinja extensions in this template, so install Copier together with the required packages in the same uv tool environment before rendering the template: + +```bash +uv tool install --with jinja2-time --with jinja2-slug --with jinja-markdown copier +``` + +## Documentation + +See the [docs][docs-website] for more details. +You can also check the [docs folder](docs) for the source of the documentation. + +## Contributing + +See the [CONTRIBUTING](CONTRIBUTING.md) file for more details. + +## License + +Distributed under the MIT License. See [LICENSE](LICENSE) file for more information. + +## Contact + +it@M - opensource@muenchen.de + + + +[made-with-love-shield]: https://img.shields.io/badge/made%20with%20%E2%9D%A4%20by-it%40M-yellow +[itm-opensource]: https://opensource.muenchen.de/ +[copier-shield]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-black.json +[copier-repo]: https://github.com/copier-org/copier +[docs-website]: https://it-at-m.github.io/{{ project_name }}/ diff --git a/compose.yaml.jinja b/compose.yaml.jinja new file mode 100644 index 0000000..d9673d0 --- /dev/null +++ b/compose.yaml.jinja @@ -0,0 +1,27 @@ +services: + {% if backend %} + backend: + build: + context: ./{{ project_name }}-backend + dockerfile: Dockerfile + env_file: + - ./.env + ports: + - "8080:8080" + {% endif %} + {% if frontend %} + frontend: + build: + context: ./{{ project_name }}-frontend + dockerfile: Dockerfile + ports: + - "8081:8080" + {% endif %} + {% if job %} + job: + build: + context: ./{{ project_name }}-job + dockerfile: Dockerfile + env_file: + - ./.env + {% endif %} \ No newline at end of file diff --git a/copier.yml b/copier.yml new file mode 100644 index 0000000..e45ad2c --- /dev/null +++ b/copier.yml @@ -0,0 +1,93 @@ +_jinja_extensions: + - jinja_markdown.MarkdownExtension + - jinja2_slug.SlugExtension + - jinja2_time.TimeExtension + +_exclude: + - "copier.yml" + - "copier.yaml" + - "~*" + - "*.py[co]" + - "__pycache__" + - ".git" + - ".DS_Store" + - ".svn" + - "{% if not frontend %}{{ project_name }}-frontend{% endif %}" + - "{% if not frontend %}{{ project_name }}-frontend/**{% endif %}" + - "{% if not backend %}{{ project_name }}-backend{% endif %}" + - "{% if not backend %}{{ project_name }}-backend/**{% endif %}" + - "{% if not job %}{{ project_name }}-job{% endif %}" + - "{% if not job %}{{ project_name }}-job/**{% endif %}" + +project_name: + type: str + help: What is your project or repository name? This can include hyphens. + +module_name: + type: str + default: "{{ project_name | lower | replace(' ', '_') | replace('-', '_') }}" + help: What is your Python import name? Use a valid Python package name without hyphens. + +repository_owner: + type: str + default: it-at-m + help: What GitHub owner or organization should be used for repository URLs? + +backend_ubi10_base_image: + type: str + default: registry.access.redhat.com/ubi10/ubi-minimal:latest + choices: + UBI 10 regular: registry.access.redhat.com/ubi10/ubi:latest + UBI 10 minimal: registry.access.redhat.com/ubi10/ubi-minimal:latest + UBI 10 micro: registry.access.redhat.com/ubi10/ubi-micro:latest + when: "{{ backend }}" + help: Which UBI 10 base image should be used for the backend container? + +job_ubi10_base_image: + type: str + default: registry.access.redhat.com/ubi10/ubi-minimal:latest + choices: + UBI 10 regular: registry.access.redhat.com/ubi10/ubi:latest + UBI 10 minimal: registry.access.redhat.com/ubi10/ubi-minimal:latest + UBI 10 micro: registry.access.redhat.com/ubi10/ubi-micro:latest + when: "{{ job }}" + help: Which UBI 10 base image should be used for the job container? + +short_description: + type: str + help: What is the short description for the generated project? + +maintainers: + type: yaml + default: [] + help: GitHub usernames of the maintainers as a YAML list. + +oci_authors: + type: str + default: "Landeshauptstadt München " + help: What should the OCI authors label be? + +oci_vendor: + type: str + default: Landeshauptstadt München + help: What should the OCI vendor label be? + +oci_license: + type: str + default: MIT + help: What should the OCI license label be? + +backend: + type: bool + default: true + help: Create a python backend? + +job: + type: bool + default: false + help: Create a python job worker (e.g. for background tasks like indexing)? + +frontend: + type: bool + default: true + help: Create a Vue frontend? diff --git a/docs/.gitkeep b/docs/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/docs/.vitepress/config.mts.jinja b/docs/.vitepress/config.mts.jinja new file mode 100644 index 0000000..e2289b8 --- /dev/null +++ b/docs/.vitepress/config.mts.jinja @@ -0,0 +1,10 @@ +import { defineConfig } from "vitepress" + +export default defineConfig({ +title: "{{ project_name }}", +description: "Documentation for {{ project_name }}", +themeConfig: { +nav: [{ text: "Home", link: "/" }], +sidebar: [{ text: "Introduction", items: [{ text: "Home", link: "/" }] }], +}, +}) \ No newline at end of file diff --git a/docs/guide/index.md.jinja b/docs/guide/index.md.jinja new file mode 100644 index 0000000..02b0384 --- /dev/null +++ b/docs/guide/index.md.jinja @@ -0,0 +1,5 @@ +# Getting started + +This is the starter guide for {{ project_name }}. + +Add your project introduction, setup instructions, and deployment notes here. \ No newline at end of file diff --git a/docs/index.md.jinja b/docs/index.md.jinja new file mode 100644 index 0000000..ce85460 --- /dev/null +++ b/docs/index.md.jinja @@ -0,0 +1,19 @@ +--- +layout: home + +hero: + name: "{{ project_name }}" + text: "Project documentation" + tagline: "A starter VitePress site generated by Copier" + actions: + - theme: brand + text: Get started + link: /guide/ +features: + - icon: 📘 + title: Documentation first + details: Put the essentials in one place. + - icon: ⚙️ + title: Easy to extend + details: Add more pages as the project grows. +--- \ No newline at end of file diff --git a/docs/package.json.jinja b/docs/package.json.jinja new file mode 100644 index 0000000..79ff837 --- /dev/null +++ b/docs/package.json.jinja @@ -0,0 +1,14 @@ +{ + "name": "{{ project_name }}-docs", + "private": true, + "type": "module", + "version": "0.1.0", + "scripts": { + "dev": "vitepress dev .", + "build": "vitepress build .", + "preview": "vitepress preview ." + }, + "devDependencies": { + "vitepress": "^1.6.4" + } +} \ No newline at end of file diff --git a/renovate.json5 b/renovate.json5 deleted file mode 100644 index 7f65b31..0000000 --- a/renovate.json5 +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "github>it-at-m/.github//renovate-configs/renovate-config.json5" - ] -} diff --git a/renovate.json5.jinja b/renovate.json5.jinja new file mode 100644 index 0000000..ccc3e45 --- /dev/null +++ b/renovate.json5.jinja @@ -0,0 +1,38 @@ +{ + $schema: "https://docs.renovatebot.com/renovate-schema.json", + description: "Renovate config for {{ project_name }}", + extends: [ + "config:best-practices", + "customManagers:githubActionsVersions", + "helpers:pinGitHubActionDigestsToSemver", + ":pinAllExceptPeerDependencies", + ":separateMultipleMajorReleases", + ":timezone(Europe/Berlin)", + "schedule:weekly", + "security:openssf-scorecard", + ], + labels: ["renovate", "dependencies"], + reviewers: [{% for maintainer in maintainers %}"{{ maintainer }}"{% if not loop.last %}, {% endif %}{% endfor %}], + lockFileMaintenance: { + enabled: true, + }, + packageRules: [ + { + matchManagers: ["pep621"], + matchUpdateTypes: ["minor", "patch"], + groupName: "Python: non-major updates", + groupSlug: "python-non-major", + matchDepNames: ["!python"], + }, + { + matchManagers: ["dockerfile"], + groupName: "Dockerfile base images", + groupSlug: "dockerfile-base-images", + }, + { + matchManagers: ["github-actions"], + groupName: "GitHub Actions dependencies", + groupSlug: "github-actions", + }, + ], +} \ No newline at end of file diff --git a/ruff.toml.jinja b/ruff.toml.jinja new file mode 100644 index 0000000..08bcc9a --- /dev/null +++ b/ruff.toml.jinja @@ -0,0 +1,49 @@ +src = ["{{ project_name }}-backend", "{{ project_name }}-job"] + +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] + +line-length = 140 +indent-width = 4 +target-version = "py313" + +[lint] +select = ["E4", "E7", "E9", "F", "I"] +ignore = [] +fixable = ["ALL"] +unfixable = [] +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[format] +quote-style = "double" +indent-style = "space" +skip-magic-trailing-comma = false +line-ending = "auto" +docstring-code-format = false +docstring-code-line-length = "dynamic" \ No newline at end of file diff --git a/{{ _copier_conf.answers_file }}.jinja b/{{ _copier_conf.answers_file }}.jinja new file mode 100644 index 0000000..88acac8 --- /dev/null +++ b/{{ _copier_conf.answers_file }}.jinja @@ -0,0 +1,2 @@ +# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY +{{ _copier_answers|to_nice_yaml -}} \ No newline at end of file diff --git a/{{project_name}}-backend/.dockerignore b/{{project_name}}-backend/.dockerignore new file mode 100644 index 0000000..6d20ada --- /dev/null +++ b/{{project_name}}-backend/.dockerignore @@ -0,0 +1,8 @@ +.venv +__pycache__ +.pytest_cache +.ruff_cache +.mypy_cache +.git +dist +build \ No newline at end of file diff --git a/{{project_name}}-backend/.python-version b/{{project_name}}-backend/.python-version new file mode 100644 index 0000000..4fd0f83 --- /dev/null +++ b/{{project_name}}-backend/.python-version @@ -0,0 +1 @@ +3.13.9 \ No newline at end of file diff --git a/{{project_name}}-backend/Dockerfile.jinja b/{{project_name}}-backend/Dockerfile.jinja new file mode 100644 index 0000000..543da20 --- /dev/null +++ b/{{project_name}}-backend/Dockerfile.jinja @@ -0,0 +1,38 @@ +FROM {{ backend_ubi10_base_image }} + +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ + +ENV UV_PROJECT_ENVIRONMENT=/app/backend/.venv +ENV UV_COMPILE_BYTECODE=1 +ENV UV_LINK_MODE=copy + +WORKDIR /app/backend + +COPY pyproject.toml ./ + +RUN --mount=type=cache,target=/root/.cache/uv \ + uv sync --no-dev --no-install-project + +COPY . /app/backend/ + +RUN --mount=type=cache,target=/root/.cache/uv \ + uv sync --no-dev + +ARG IMAGE_CREATED="unknown" +ARG IMAGE_REVISION="unknown" +ARG IMAGE_VERSION="unknown" +LABEL org.opencontainers.image.authors="{{ oci_authors }}" \ + org.opencontainers.image.vendor="{{ oci_vendor }}" \ + org.opencontainers.image.created="$IMAGE_CREATED" \ + org.opencontainers.image.revision="$IMAGE_REVISION" \ + org.opencontainers.image.version="$IMAGE_VERSION" \ + org.opencontainers.image.url="https://github.com/{{ repository_owner }}/{{ project_name }}" \ + org.opencontainers.image.documentation="https://github.com/{{ repository_owner }}/{{ project_name }}/README.md" \ + org.opencontainers.image.source="https://github.com/{{ repository_owner }}/{{ project_name }}" \ + org.opencontainers.image.licenses="{{ oci_license }}" \ + org.opencontainers.image.title="{{ project_name }}-backend" \ + org.opencontainers.image.description="Python backend for {{ short_description }}" + +ENV PATH="/app/backend/.venv/bin:$PATH" + +ENTRYPOINT ["/app/backend/.venv/bin/python", "main.py"] \ No newline at end of file diff --git a/{{project_name}}-backend/README.md.jinja b/{{project_name}}-backend/README.md.jinja new file mode 100644 index 0000000..1dd4b46 --- /dev/null +++ b/{{project_name}}-backend/README.md.jinja @@ -0,0 +1,10 @@ +# {{ project_name }} backend + +FastAPI service scaffolded with uv. + +## Start + +```bash +uv sync +uv run python main.py +``` \ No newline at end of file diff --git a/{{project_name}}-backend/main.py.jinja b/{{project_name}}-backend/main.py.jinja new file mode 100644 index 0000000..5098fb2 --- /dev/null +++ b/{{project_name}}-backend/main.py.jinja @@ -0,0 +1,7 @@ +from {{ module_name }}.app import app + + +if __name__ == "__main__": + import uvicorn + + uvicorn.run("{{ module_name }}.app:app", host="0.0.0.0", port=8080, reload=False) \ No newline at end of file diff --git a/{{project_name}}-backend/pyproject.toml.jinja b/{{project_name}}-backend/pyproject.toml.jinja new file mode 100644 index 0000000..8245da5 --- /dev/null +++ b/{{project_name}}-backend/pyproject.toml.jinja @@ -0,0 +1,31 @@ +[project] +name = "{{ project_name }}-backend" +version = "0.1.0" +description = "FastAPI backend for {{ project_name }}" +readme = "README.md" +requires-python = ">=3.13" +dependencies = [ + "fastapi>=0.128.0", + "httpx>=0.28.1", + "pydantic-settings>=2.12.0", + "pyyaml>=6.0.3", + "uvicorn[standard]>=0.40.0", +] + +[dependency-groups] +dev = [ + "pre-commit>=4.5.1", + "pytest>=9.0.3", + "pytest-asyncio>=1.3.0", + "pytest-cov>=7.0.0", + "ruff>=0.14.14", + "ty>=0.0.14", +] + +[tool.uv] +add-bounds = "exact" + +[tool.pytest.ini_options] +pythonpath = ["."] +testpaths = ["test"] +addopts = ["--cov={{ module_name }}", "--cov-report=term-missing"] \ No newline at end of file diff --git a/{{project_name}}-backend/test/test_app.py.jinja b/{{project_name}}-backend/test/test_app.py.jinja new file mode 100644 index 0000000..942b980 --- /dev/null +++ b/{{project_name}}-backend/test/test_app.py.jinja @@ -0,0 +1,12 @@ +from fastapi.testclient import TestClient + +from {{ module_name }}.app import app + + +def test_healthz() -> None: + client = TestClient(app) + + response = client.get("/api/healthz") + + assert response.status_code == 200 + assert response.json() == {"status": "ok"} \ No newline at end of file diff --git a/{{project_name}}-backend/{{module_name}}/app.py.jinja b/{{project_name}}-backend/{{module_name}}/app.py.jinja new file mode 100644 index 0000000..cd8d564 --- /dev/null +++ b/{{project_name}}-backend/{{module_name}}/app.py.jinja @@ -0,0 +1,15 @@ +from fastapi import FastAPI + +from .settings import settings + +app = FastAPI(title=settings.app_name) + + +@app.get("/api/healthz") +async def healthz() -> dict[str, str]: + return {"status": "ok"} + + +@app.get("/") +async def root() -> dict[str, str]: + return {"message": "{{ project_name }} backend is running"} \ No newline at end of file diff --git a/{{project_name}}-backend/{{module_name}}/settings.py.jinja b/{{project_name}}-backend/{{module_name}}/settings.py.jinja new file mode 100644 index 0000000..34cb8fa --- /dev/null +++ b/{{project_name}}-backend/{{module_name}}/settings.py.jinja @@ -0,0 +1,11 @@ +from pydantic_settings import BaseSettings, SettingsConfigDict + + +class Settings(BaseSettings): + model_config = SettingsConfigDict(env_prefix="{{ project_name | upper | replace('-', '_') }}_", env_file=".env", extra="ignore") + + app_name: str = "{{ project_name }} backend" + log_level: str = "INFO" + + +settings = Settings() \ No newline at end of file diff --git a/{{project_name}}-frontend/.dockerignore b/{{project_name}}-frontend/.dockerignore new file mode 100644 index 0000000..601d7f5 --- /dev/null +++ b/{{project_name}}-frontend/.dockerignore @@ -0,0 +1,4 @@ +node_modules +dist +.vite +.git \ No newline at end of file diff --git a/{{project_name}}-frontend/Dockerfile.jinja b/{{project_name}}-frontend/Dockerfile.jinja new file mode 100644 index 0000000..e821862 --- /dev/null +++ b/{{project_name}}-frontend/Dockerfile.jinja @@ -0,0 +1,37 @@ +FROM node:22.22.2-alpine AS builder + +WORKDIR /build + +COPY package.json ./ + +RUN npm install + +COPY index.html tsconfig.json tsconfig.app.json tsconfig.node.json vite.config.ts ./ +COPY src ./src +COPY docker ./docker + +RUN npm run build + +FROM registry.access.redhat.com/ubi10/nginx-126:10.1-1775622738 + +COPY --from=builder /build/dist /opt/app-root/src +COPY docker/nginx/default.conf "${NGINX_DEFAULT_CONF_PATH}" + +ARG IMAGE_CREATED="unknown" +ARG IMAGE_REVISION="unknown" +ARG IMAGE_VERSION="unknown" +LABEL org.opencontainers.image.authors="{{ oci_authors }}" \ + org.opencontainers.image.vendor="{{ oci_vendor }}" \ + org.opencontainers.image.created="$IMAGE_CREATED" \ + org.opencontainers.image.revision="$IMAGE_REVISION" \ + org.opencontainers.image.version="$IMAGE_VERSION" \ + org.opencontainers.image.url="https://github.com/{{ repository_owner }}/{{ project_name }}" \ + org.opencontainers.image.documentation="https://github.com/{{ repository_owner }}/{{ project_name }}/README.md" \ + org.opencontainers.image.source="https://github.com/{{ repository_owner }}/{{ project_name }}" \ + org.opencontainers.image.licenses="{{ oci_license }}" \ + org.opencontainers.image.title="{{ project_name }}-frontend" \ + org.opencontainers.image.description="Vue frontend for {{ short_description }}" + +EXPOSE 8080 + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/{{project_name}}-frontend/README.md.jinja b/{{project_name}}-frontend/README.md.jinja new file mode 100644 index 0000000..9385302 --- /dev/null +++ b/{{project_name}}-frontend/README.md.jinja @@ -0,0 +1,10 @@ +# {{ project_name }} frontend + +Vue 3 + Vite + TypeScript starter. + +## Start + +```bash +npm install +npm run dev +``` \ No newline at end of file diff --git a/{{project_name}}-frontend/docker/nginx/default.conf b/{{project_name}}-frontend/docker/nginx/default.conf new file mode 100644 index 0000000..f33878d --- /dev/null +++ b/{{project_name}}-frontend/docker/nginx/default.conf @@ -0,0 +1,10 @@ +server { + listen 8080; + server_name _; + root /opt/app-root/src; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } +} \ No newline at end of file diff --git a/{{project_name}}-frontend/index.html.jinja b/{{project_name}}-frontend/index.html.jinja new file mode 100644 index 0000000..0c343e1 --- /dev/null +++ b/{{project_name}}-frontend/index.html.jinja @@ -0,0 +1,15 @@ + + + + + + + {{ project_name }} frontend + + + +
+ + + + \ No newline at end of file diff --git a/{{project_name}}-frontend/package.json.jinja b/{{project_name}}-frontend/package.json.jinja new file mode 100644 index 0000000..f2a4fe4 --- /dev/null +++ b/{{project_name}}-frontend/package.json.jinja @@ -0,0 +1,24 @@ +{ + "name": "{{ project_name }}-frontend", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vue-tsc --build --noCheck && vite build", + "preview": "vite preview", + "typecheck": "vue-tsc --build --noEmit" + }, + "dependencies": { + "vue": "3.5.27" + }, + "devDependencies": { + "@tsconfig/node-lts": "22.0.4", + "@types/node": "22.19.17", + "@vitejs/plugin-vue": "6.0.5", + "@vue/tsconfig": "0.8.1", + "typescript": "5.9.3", + "vite": "7.3.2", + "vue-tsc": "3.1.8" + } +} \ No newline at end of file diff --git a/{{project_name}}-frontend/src/App.vue.jinja b/{{project_name}}-frontend/src/App.vue.jinja new file mode 100644 index 0000000..95a80fe --- /dev/null +++ b/{{project_name}}-frontend/src/App.vue.jinja @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/{{project_name}}-frontend/src/main.ts b/{{project_name}}-frontend/src/main.ts new file mode 100644 index 0000000..d0c080b --- /dev/null +++ b/{{project_name}}-frontend/src/main.ts @@ -0,0 +1,5 @@ +import { createApp } from "vue" +import App from "./App.vue" +import "./style.css" + +createApp(App).mount("#app") \ No newline at end of file diff --git a/{{project_name}}-frontend/src/style.css b/{{project_name}}-frontend/src/style.css new file mode 100644 index 0000000..3841f9d --- /dev/null +++ b/{{project_name}}-frontend/src/style.css @@ -0,0 +1,18 @@ +:root { + font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; + color: #111827; + background: #f8fafc; +} + +body { + margin: 0; + min-width: 320px; + min-height: 100vh; +} + +.app-shell { + min-height: 100vh; + display: grid; + place-items: center; + text-align: center; +} \ No newline at end of file diff --git a/{{project_name}}-frontend/tsconfig.app.json b/{{project_name}}-frontend/tsconfig.app.json new file mode 100644 index 0000000..5601df6 --- /dev/null +++ b/{{project_name}}-frontend/tsconfig.app.json @@ -0,0 +1,4 @@ +{ + "extends": "@vue/tsconfig/tsconfig.dom.json", + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"] +} \ No newline at end of file diff --git a/{{project_name}}-frontend/tsconfig.json b/{{project_name}}-frontend/tsconfig.json new file mode 100644 index 0000000..2cc3e68 --- /dev/null +++ b/{{project_name}}-frontend/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "./tsconfig.app.json", + "references": [{ "path": "./tsconfig.node.json" }] +} \ No newline at end of file diff --git a/{{project_name}}-frontend/tsconfig.node.json b/{{project_name}}-frontend/tsconfig.node.json new file mode 100644 index 0000000..9403914 --- /dev/null +++ b/{{project_name}}-frontend/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "extends": "@tsconfig/node-lts/tsconfig.json", + "compilerOptions": { + "composite": true, + "module": "ESNext", + "moduleResolution": "Bundler", + "noEmit": true + }, + "include": ["vite.config.ts"] +} \ No newline at end of file diff --git a/{{project_name}}-frontend/vite.config.ts b/{{project_name}}-frontend/vite.config.ts new file mode 100644 index 0000000..6ea8547 --- /dev/null +++ b/{{project_name}}-frontend/vite.config.ts @@ -0,0 +1,6 @@ +import { defineConfig } from "vite"; +import vue from "@vitejs/plugin-vue"; + +export default defineConfig({ + plugins: [vue()], +}); diff --git a/{{project_name}}-job/.dockerignore b/{{project_name}}-job/.dockerignore new file mode 100644 index 0000000..6d20ada --- /dev/null +++ b/{{project_name}}-job/.dockerignore @@ -0,0 +1,8 @@ +.venv +__pycache__ +.pytest_cache +.ruff_cache +.mypy_cache +.git +dist +build \ No newline at end of file diff --git a/{{project_name}}-job/.python-version b/{{project_name}}-job/.python-version new file mode 100644 index 0000000..4fd0f83 --- /dev/null +++ b/{{project_name}}-job/.python-version @@ -0,0 +1 @@ +3.13.9 \ No newline at end of file diff --git a/{{project_name}}-job/Dockerfile.jinja b/{{project_name}}-job/Dockerfile.jinja new file mode 100644 index 0000000..e05a50d --- /dev/null +++ b/{{project_name}}-job/Dockerfile.jinja @@ -0,0 +1,38 @@ +FROM {{ job_ubi10_base_image }} + +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ + +ENV UV_PROJECT_ENVIRONMENT=/app/job/.venv +ENV UV_COMPILE_BYTECODE=1 +ENV UV_LINK_MODE=copy + +WORKDIR /app/job + +COPY pyproject.toml ./ + +RUN --mount=type=cache,target=/root/.cache/uv \ + uv sync --no-dev --no-install-project + +COPY . /app/job/ + +RUN --mount=type=cache,target=/root/.cache/uv \ + uv sync --no-dev + +ARG IMAGE_CREATED="unknown" +ARG IMAGE_REVISION="unknown" +ARG IMAGE_VERSION="unknown" +LABEL org.opencontainers.image.authors="{{ oci_authors }}" \ + org.opencontainers.image.vendor="{{ oci_vendor }}" \ + org.opencontainers.image.created="$IMAGE_CREATED" \ + org.opencontainers.image.revision="$IMAGE_REVISION" \ + org.opencontainers.image.version="$IMAGE_VERSION" \ + org.opencontainers.image.url="https://github.com/{{ repository_owner }}/{{ project_name }}" \ + org.opencontainers.image.documentation="https://github.com/{{ repository_owner }}/{{ project_name }}/README.md" \ + org.opencontainers.image.source="https://github.com/{{ repository_owner }}/{{ project_name }}" \ + org.opencontainers.image.licenses="{{ oci_license }}" \ + org.opencontainers.image.title="{{ project_name }}-job" \ + org.opencontainers.image.description="Background job for {{ short_description }}" + +ENV PATH="/app/job/.venv/bin:$PATH" + +ENTRYPOINT ["/app/job/.venv/bin/python", "main.py"] \ No newline at end of file diff --git a/{{project_name}}-job/README.md.jinja b/{{project_name}}-job/README.md.jinja new file mode 100644 index 0000000..47c611d --- /dev/null +++ b/{{project_name}}-job/README.md.jinja @@ -0,0 +1,10 @@ +# {{ project_name }} job + +Simple HTTPX-based background job scaffold. + +## Start + +```bash +uv sync +uv run python main.py +``` \ No newline at end of file diff --git a/{{project_name}}-job/main.py b/{{project_name}}-job/main.py new file mode 100644 index 0000000..7a96b43 --- /dev/null +++ b/{{project_name}}-job/main.py @@ -0,0 +1,17 @@ +import asyncio + +import httpx + + +EXAMPLE_URL = "https://jsonplaceholder.typicode.com/todos/1" + + +async def run() -> None: + async with httpx.AsyncClient(timeout=10.0) as client: + response = await client.get(EXAMPLE_URL) + response.raise_for_status() + print(response.json()) + + +if __name__ == "__main__": + asyncio.run(run()) diff --git a/{{project_name}}-job/pyproject.toml.jinja b/{{project_name}}-job/pyproject.toml.jinja new file mode 100644 index 0000000..7e154e1 --- /dev/null +++ b/{{project_name}}-job/pyproject.toml.jinja @@ -0,0 +1,25 @@ +[project] +name = "{{ project_name }}-job" +version = "0.1.0" +description = "Background job for {{ project_name }}" +readme = "README.md" +requires-python = ">=3.13" +dependencies = [ + "httpx>=0.28.1", + "pydantic-settings>=2.12.0", +] + +[dependency-groups] +dev = [ + "pre-commit>=4.5.1", + "pytest>=9.0.3", + "ruff>=0.14.14", + "ty>=0.0.14", +] + +[tool.uv] +add-bounds = "exact" + +[tool.pytest.ini_options] +pythonpath = ["."] +testpaths = ["test"] \ No newline at end of file diff --git a/{{project_name}}-job/test/test_main.py.jinja b/{{project_name}}-job/test/test_main.py.jinja new file mode 100644 index 0000000..c42aa20 --- /dev/null +++ b/{{project_name}}-job/test/test_main.py.jinja @@ -0,0 +1,31 @@ +import asyncio + +import main + + +def test_run_uses_example_url(monkeypatch) -> None: + captured = {} + + class DummyResponse: + def raise_for_status(self) -> None: + return None + + def json(self) -> dict[str, str]: + return {"ok": "true"} + + class DummyClient: + async def __aenter__(self): + return self + + async def __aexit__(self, exc_type, exc, tb): + return None + + async def get(self, url: str): + captured["url"] = url + return DummyResponse() + + monkeypatch.setattr(main.httpx, "AsyncClient", lambda timeout: DummyClient()) + + asyncio.run(main.run()) + + assert captured["url"] == main.EXAMPLE_URL \ No newline at end of file diff --git a/{{project_name}}-job/{{module_name}}/worker.py b/{{project_name}}-job/{{module_name}}/worker.py new file mode 100644 index 0000000..3e9ea1f --- /dev/null +++ b/{{project_name}}-job/{{module_name}}/worker.py @@ -0,0 +1,7 @@ +import asyncio + +from ..main import run + + +if __name__ == "__main__": + asyncio.run(run()) From c33c9825060e373c96ae8b8b6444602a4dec6c6b Mon Sep 17 00:00:00 2001 From: Fabian Reinold Date: Mon, 4 May 2026 20:21:14 +0200 Subject: [PATCH 2/6] feat: add template usage docs, update Python version to 3.14 and add Prettier configuration files --- .pre-commit-config.yaml | 2 +- LICENSE | 21 ++ README.md | 181 ++++++++++++++++++ README.md.jinja | 27 ++- docs/.npmrc | 2 + docs/.prettierignore | 2 + docs/.prettierrc | 1 + docs/package.json.jinja | 5 +- ruff.toml.jinja | 2 +- {{project_name}}-backend/.python-version | 2 +- {{project_name}}-backend/pyproject.toml.jinja | 2 +- {{project_name}}-frontend/.npmrc | 2 + {{project_name}}-frontend/.prettierignore | 2 + {{project_name}}-frontend/.prettierrc | 1 + {{project_name}}-frontend/package.json.jinja | 5 +- {{project_name}}-job/.python-version | 2 +- {{project_name}}-job/pyproject.toml.jinja | 2 +- 17 files changed, 249 insertions(+), 12 deletions(-) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 docs/.npmrc create mode 100644 docs/.prettierignore create mode 100644 docs/.prettierrc create mode 100644 {{project_name}}-frontend/.npmrc create mode 100644 {{project_name}}-frontend/.prettierignore create mode 100644 {{project_name}}-frontend/.prettierrc diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7f049f7..2cffda5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ default_language_version: - python: python3.13 + python: python3.14 repos: - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.14.14 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4bd5130 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Landeshauptstadt München | it@M + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..673382a --- /dev/null +++ b/README.md @@ -0,0 +1,181 @@ +# python-templates + +[![Template][template-shield]][template-link] +[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-black.json)](https://github.com/copier-org/copier) +[![Python][python-shield]][python-org] +[![uv][uv-shield]][uv-repo] +[![Jinja][jinja-shield]][jinja-repo] +[![Docker][docker-shield]][docker-repo] +[![License][license-shield]][license-link] + +This repository contains a Copier template for creating new Python-based projects with an optional backend, frontend, and background job worker. + +Use this template when you want a consistent starting point for a new application and want Copier to generate the repository structure, configuration, and starter files from a small set of answers. + +## What this template generates + +By default, Copier renders a project with: + +- A Python backend service +- A Vue 3 + Vite frontend +- Optional background job worker support +- Dockerfiles for the selected components +- A Docker Compose file for local development +- Docs scaffolding +- Shared linting and formatting configuration + +You can enable or disable the backend, frontend, and job worker independently during generation. + +## Prerequisites + +Install Copier and the Jinja extensions used by this template in the same environment: + +```bash +uv tool install --with jinja2-time --with jinja2-slug --with jinja-markdown copier +``` + +You also need: + +- `git` +- `uv` for the Python parts +- `node` and `npm` for the frontend parts + +## Create a new project + +Run Copier from the root of this template repository: + +```bash +copier copy . ../my-new-project +``` + +You will be prompted for the project name and the component options. Copier then creates the target repository and writes the rendered files there. + +If you want to use this template directly from Git instead of a local checkout, you can also copy from the repository URL: + +```bash +copier copy https://github.com/it-at-m/python-templates.git ../my-new-project +``` + +## Answers you will be asked for + +The template is driven by the values in [copier.yml](copier.yml): + +- `project_name`: Name of the generated repository or application +- `module_name`: Python import package name, derived from `project_name` by default +- `repository_owner`: GitHub owner used in generated URLs and metadata +- `short_description`: Short summary shown in the generated README and docs +- `maintainers`: GitHub usernames of the maintainers as a YAML list +- `backend`: Enable or disable the backend service +- `frontend`: Enable or disable the Vue frontend +- `job`: Enable or disable the background job worker +- `backend_ubi10_base_image`: Base image for the backend container when the backend is enabled +- `job_ubi10_base_image`: Base image for the job container when the job worker is enabled +- `oci_authors`, `oci_vendor`, `oci_license`: OCI metadata values used in generated container images + +The defaults are chosen so that a standard project can be created quickly, but you can override any of them during generation. + +## Typical workflow after generation + +After Copier finishes, switch into the new repository and install the dependencies for the parts you enabled. + +Backend: + +```bash +cd my-new-project/my-new-project-backend +uv sync +uv run python main.py +``` + +Frontend: + +```bash +cd my-new-project/my-new-project-frontend +npm install +npm run dev +``` + +Job worker: + +```bash +cd my-new-project/my-new-project-job +uv sync +uv run python main.py +``` + +If the generated repository includes Docker Compose, you can usually start the selected services from the repository root with: + +```bash +docker compose up --build +``` + +## Updating an existing project + +Copier is not only for first-time generation. After the template evolves, you can refresh a generated repository with: + +```bash +copier update +``` + +Run that command from the generated repository root. Copier uses the stored answers file to compare the template version that was originally used with the current template. + +## Template structure + +The top-level template repository is organized like this: + +- [README.md.jinja](README.md.jinja) renders the README for generated projects +- [copier.yml](copier.yml) defines the template questions and defaults +- [compose.yaml.jinja](compose.yaml.jinja) renders the local compose file +- `{{project_name}}-backend/` contains the backend scaffold +- `{{project_name}}-frontend/` contains the frontend scaffold +- `{{project_name}}-job/` contains the job worker scaffold +- `docs/` contains the generated documentation site content + +Files ending in `.jinja` are rendered by Copier into the target repository. The root README in this repository documents the template itself; the generated project README is produced from [README.md.jinja](README.md.jinja). + +## How the component selection works + +The backend, frontend, and job worker are rendered conditionally: + +- If `backend` is disabled, the backend directory and its Docker setup are excluded +- If `frontend` is disabled, the frontend directory and its Docker setup are excluded +- If `job` is disabled, the job worker directory and its Docker setup are excluded + +This lets you keep the generated project small when you do not need all components. + +## Customizing the template + +If you are maintaining this template, update the Jinja source files rather than the rendered output. + +- Edit the `.jinja` files to change what future projects receive +- Adjust [copier.yml](copier.yml) when you want to add, remove, or rename template answers +- Use the `when` and `_exclude` rules in [copier.yml](copier.yml) to control conditional files +- Keep the generated-project README in [README.md.jinja](README.md.jinja) aligned with the template behavior + +When you change the template, create a fresh test project and run `copier update` there to verify the rendered result. + +## Troubleshooting + +If Copier fails while rendering Jinja templates, make sure the `copier` tool and the required Jinja extensions are installed in the same environment. + +If the generated backend or job project does not start, check that the selected UBI base image is compatible with your runtime and that the rendered container configuration matches the chosen components. + +If a directory is unexpectedly missing, review the `backend`, `frontend`, and `job` answers and the `_exclude` rules in [copier.yml](copier.yml). + +## Contributing + +See [CONTRIBUTING.md](CONTRIBUTING.md) for the contribution workflow and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for community guidelines. + + + +[template-shield]: https://img.shields.io/badge/template-Copier-111111?logo=copier +[template-link]: https://copier.readthedocs.io/ +[python-shield]: https://img.shields.io/badge/python-3.14.4%2B-3776AB?logo=python&logoColor=white +[python-org]: https://www.python.org/ +[uv-shield]: https://img.shields.io/badge/uv-tool-111111?logo=astral&logoColor=white +[uv-repo]: https://docs.astral.sh/uv/ +[jinja-shield]: https://img.shields.io/badge/jinja-templates-B41717?logo=jinja&logoColor=white +[jinja-repo]: https://jinja.palletsprojects.com/ +[docker-shield]: https://img.shields.io/badge/docker-supported-2496ED?logo=docker&logoColor=white +[docker-repo]: https://www.docker.com/ +[license-shield]: https://img.shields.io/badge/license-MIT-007EC6 +[license-link]: LICENSE diff --git a/README.md.jinja b/README.md.jinja index 221de27..7e37b20 100644 --- a/README.md.jinja +++ b/README.md.jinja @@ -17,7 +17,14 @@ What to adjust: # {{ project_name }} [![Made with love by it@M][made-with-love-shield]][itm-opensource] -[![Copier][copier-shield]][copier-repo] +[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-black.json)](https://github.com/copier-org/copier) +[![Python][python-shield]][python-org] +[![uv][uv-shield]][uv-repo] +[![Docker][docker-shield]][docker-repo] +[![License][license-shield]][license-link] +{% if backend %}[![FastAPI][fastapi-shield]][fastapi-repo]{% endif %} +{% if frontend %}[![Vue 3][vue-shield]][vue-repo]{% endif %} +{% if frontend %}[![Vite][vite-shield]][vite-repo]{% endif %} @@ -70,8 +77,20 @@ it@M - opensource@muenchen.de -[made-with-love-shield]: https://img.shields.io/badge/made%20with%20%E2%9D%A4%20by-it%40M-yellow +[made-with-love-shield]: https://img.shields.io/badge/made_with_%E2%9D%A4%20by-it%40M-yellow [itm-opensource]: https://opensource.muenchen.de/ -[copier-shield]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-black.json -[copier-repo]: https://github.com/copier-org/copier +[python-shield]: https://img.shields.io/badge/python-3.14.4%2B-3776AB?logo=python&logoColor=white +[python-org]: https://www.python.org/ +[uv-shield]: https://img.shields.io/badge/uv-tool-111111?logo=astral&logoColor=white +[uv-repo]: https://docs.astral.sh/uv/ +[docker-shield]: https://img.shields.io/badge/docker-supported-2496ED?logo=docker&logoColor=white +[docker-repo]: https://www.docker.com/ +[license-shield]: https://img.shields.io/badge/license-MIT-007EC6 +[license-link]: LICENSE +[fastapi-shield]: https://img.shields.io/badge/fastapi-api-009688?logo=fastapi&logoColor=white +[fastapi-repo]: https://fastapi.tiangolo.com/ +[vue-shield]: https://img.shields.io/badge/vue-3-4FC08D?logo=vuedotjs&logoColor=white +[vue-repo]: https://vuejs.org/ +[vite-shield]: https://img.shields.io/badge/vite-build-646CFF?logo=vite&logoColor=white +[vite-repo]: https://vite.dev/ [docs-website]: https://it-at-m.github.io/{{ project_name }}/ diff --git a/docs/.npmrc b/docs/.npmrc new file mode 100644 index 0000000..412955b --- /dev/null +++ b/docs/.npmrc @@ -0,0 +1,2 @@ +# Omits the resolved property (with specific reference to the npm repository) from the lockfile. +omit-lockfile-registry-resolved=true \ No newline at end of file diff --git a/docs/.prettierignore b/docs/.prettierignore new file mode 100644 index 0000000..db4c6d9 --- /dev/null +++ b/docs/.prettierignore @@ -0,0 +1,2 @@ +dist +node_modules \ No newline at end of file diff --git a/docs/.prettierrc b/docs/.prettierrc new file mode 100644 index 0000000..3cd7a47 --- /dev/null +++ b/docs/.prettierrc @@ -0,0 +1 @@ +"@muenchen/prettier-codeformat" diff --git a/docs/package.json.jinja b/docs/package.json.jinja index 79ff837..35cb817 100644 --- a/docs/package.json.jinja +++ b/docs/package.json.jinja @@ -6,9 +6,12 @@ "scripts": { "dev": "vitepress dev .", "build": "vitepress build .", - "preview": "vitepress preview ." + "preview": "vitepress preview .", + "lint": "prettier --check .", + "fix": "prettier --write ." }, "devDependencies": { + "prettier": "3.5.3", "vitepress": "^1.6.4" } } \ No newline at end of file diff --git a/ruff.toml.jinja b/ruff.toml.jinja index 08bcc9a..44f8751 100644 --- a/ruff.toml.jinja +++ b/ruff.toml.jinja @@ -31,7 +31,7 @@ exclude = [ line-length = 140 indent-width = 4 -target-version = "py313" +target-version = "py314" [lint] select = ["E4", "E7", "E9", "F", "I"] diff --git a/{{project_name}}-backend/.python-version b/{{project_name}}-backend/.python-version index 4fd0f83..c4f2bbc 100644 --- a/{{project_name}}-backend/.python-version +++ b/{{project_name}}-backend/.python-version @@ -1 +1 @@ -3.13.9 \ No newline at end of file +3.14.4 \ No newline at end of file diff --git a/{{project_name}}-backend/pyproject.toml.jinja b/{{project_name}}-backend/pyproject.toml.jinja index 8245da5..5ac744a 100644 --- a/{{project_name}}-backend/pyproject.toml.jinja +++ b/{{project_name}}-backend/pyproject.toml.jinja @@ -3,7 +3,7 @@ name = "{{ project_name }}-backend" version = "0.1.0" description = "FastAPI backend for {{ project_name }}" readme = "README.md" -requires-python = ">=3.13" +requires-python = ">=3.14" dependencies = [ "fastapi>=0.128.0", "httpx>=0.28.1", diff --git a/{{project_name}}-frontend/.npmrc b/{{project_name}}-frontend/.npmrc new file mode 100644 index 0000000..412955b --- /dev/null +++ b/{{project_name}}-frontend/.npmrc @@ -0,0 +1,2 @@ +# Omits the resolved property (with specific reference to the npm repository) from the lockfile. +omit-lockfile-registry-resolved=true \ No newline at end of file diff --git a/{{project_name}}-frontend/.prettierignore b/{{project_name}}-frontend/.prettierignore new file mode 100644 index 0000000..db4c6d9 --- /dev/null +++ b/{{project_name}}-frontend/.prettierignore @@ -0,0 +1,2 @@ +dist +node_modules \ No newline at end of file diff --git a/{{project_name}}-frontend/.prettierrc b/{{project_name}}-frontend/.prettierrc new file mode 100644 index 0000000..3cd7a47 --- /dev/null +++ b/{{project_name}}-frontend/.prettierrc @@ -0,0 +1 @@ +"@muenchen/prettier-codeformat" diff --git a/{{project_name}}-frontend/package.json.jinja b/{{project_name}}-frontend/package.json.jinja index f2a4fe4..10f254e 100644 --- a/{{project_name}}-frontend/package.json.jinja +++ b/{{project_name}}-frontend/package.json.jinja @@ -7,7 +7,9 @@ "dev": "vite", "build": "vue-tsc --build --noCheck && vite build", "preview": "vite preview", - "typecheck": "vue-tsc --build --noEmit" + "typecheck": "vue-tsc --build --noEmit", + "lint": "prettier --check .", + "fix": "prettier --write ." }, "dependencies": { "vue": "3.5.27" @@ -17,6 +19,7 @@ "@types/node": "22.19.17", "@vitejs/plugin-vue": "6.0.5", "@vue/tsconfig": "0.8.1", + "prettier": "3.5.3", "typescript": "5.9.3", "vite": "7.3.2", "vue-tsc": "3.1.8" diff --git a/{{project_name}}-job/.python-version b/{{project_name}}-job/.python-version index 4fd0f83..c4f2bbc 100644 --- a/{{project_name}}-job/.python-version +++ b/{{project_name}}-job/.python-version @@ -1 +1 @@ -3.13.9 \ No newline at end of file +3.14.4 \ No newline at end of file diff --git a/{{project_name}}-job/pyproject.toml.jinja b/{{project_name}}-job/pyproject.toml.jinja index 7e154e1..f8819e1 100644 --- a/{{project_name}}-job/pyproject.toml.jinja +++ b/{{project_name}}-job/pyproject.toml.jinja @@ -3,7 +3,7 @@ name = "{{ project_name }}-job" version = "0.1.0" description = "Background job for {{ project_name }}" readme = "README.md" -requires-python = ">=3.13" +requires-python = ">=3.14" dependencies = [ "httpx>=0.28.1", "pydantic-settings>=2.12.0", From 36736cd178e3d2b54bee3a4ebdbae3f851a97b0b Mon Sep 17 00:00:00 2001 From: Fabian Reinold Date: Fri, 15 May 2026 16:39:04 +0200 Subject: [PATCH 3/6] fix: apply security and quality review findings across template - Fix invalid YAML indentation in all four GitHub Actions workflow templates (backend-tests, docker-release-backend/frontend/job) - Remove unconditional OPENAI_API_KEY dummy value from backend CI; no OpenAI integration exists in the scaffold - Combine split echo redirects onto single lines in docker-release workflows to fix bash syntax errors - Drop overly broad actions:write permission from docker-release-frontend - Remove dead pull_request branch from scorecard.yml if-condition - Add .env/.env.* to backend and job .dockerignore files - Pin uv to 0.11.14 in backend and job Dockerfiles; copy uv.lock for deterministic installs; add --frozen flag to job uv sync calls - Add non-root appuser to backend and job Dockerfiles - Switch all container and compose paths from project_name to module_name for consistency with Python module naming; rename template directories accordingly and update all references (copier.yml, ruff.toml, compose, workflows) - Reorder copier.yml so backend/job/frontend booleans precede the conditional image questions; pin UBI base image defaults to 10.1-1775622738 - Fix vitepress config.mts.jinja indentation inside defineConfig block - Fix README.md.jinja: typo in description, hardcoded org in docs URL, replace Copier install snippet with project-oriented setup instructions - Remove unused pyyaml dependency from backend pyproject.toml; add asyncio_mode = "auto" for pytest-asyncio - Add nginx security headers, gzip compression, and static asset cache headers to frontend nginx config - Switch frontend Dockerfile to npm ci with package-lock.json copy - Remove --noCheck from frontend build script to enforce type checking - Fix brittle monkeypatch lambda and add assertion guard in job test Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/scorecard.yml | 3 +- ...ckend %}backend-tests.yml{% endif %}.jinja | 40 ++++--- ...ocker-release-backend.yml{% endif %}.jinja | 105 +++++++++--------- ...cker-release-frontend.yml{% endif %}.jinja | 105 +++++++++--------- ... %}docker-release-job.yml{% endif %}.jinja | 105 +++++++++--------- README.md.jinja | 17 ++- compose.yaml.jinja | 6 +- copier.yml | 52 ++++----- docs/.vitepress/config.mts.jinja | 14 +-- ruff.toml.jinja | 2 +- .../.dockerignore | 4 +- .../.python-version | 0 .../Dockerfile.jinja | 18 +-- .../README.md.jinja | 0 .../main.py.jinja | 0 .../pyproject.toml.jinja | 4 +- .../test/test_app.py.jinja | 0 .../{{module_name}}/app.py.jinja | 0 .../{{module_name}}/settings.py.jinja | 0 .../.dockerignore | 0 .../.npmrc | 0 .../.prettierignore | 0 .../.prettierrc | 0 .../Dockerfile.jinja | 6 +- .../README.md.jinja | 0 .../docker/nginx/default.conf | 23 ++++ .../index.html.jinja | 0 .../package.json.jinja | 2 +- .../src/App.vue.jinja | 0 .../src/main.ts | 0 .../src/style.css | 0 .../tsconfig.app.json | 0 .../tsconfig.json | 0 .../tsconfig.node.json | 0 .../vite.config.ts | 0 .../.dockerignore | 4 +- .../.python-version | 0 .../Dockerfile.jinja | 22 ++-- .../README.md.jinja | 0 .../main.py | 0 .../pyproject.toml.jinja | 0 .../test/test_main.py.jinja | 5 +- .../{{module_name}}/worker.py | 0 .../docker/nginx/default.conf | 10 -- 44 files changed, 284 insertions(+), 263 deletions(-) rename {{{project_name}}-backend => {{module_name}}-backend}/.dockerignore (79%) rename {{{project_name}}-backend => {{module_name}}-backend}/.python-version (100%) rename {{{project_name}}-backend => {{module_name}}-backend}/Dockerfile.jinja (74%) rename {{{project_name}}-backend => {{module_name}}-backend}/README.md.jinja (100%) rename {{{project_name}}-backend => {{module_name}}-backend}/main.py.jinja (100%) rename {{{project_name}}-backend => {{module_name}}-backend}/pyproject.toml.jinja (96%) rename {{{project_name}}-backend => {{module_name}}-backend}/test/test_app.py.jinja (100%) rename {{{project_name}}-backend => {{module_name}}-backend}/{{module_name}}/app.py.jinja (100%) rename {{{project_name}}-backend => {{module_name}}-backend}/{{module_name}}/settings.py.jinja (100%) rename {{{project_name}}-frontend => {{module_name}}-frontend}/.dockerignore (100%) rename {{{project_name}}-frontend => {{module_name}}-frontend}/.npmrc (100%) rename {{{project_name}}-frontend => {{module_name}}-frontend}/.prettierignore (100%) rename {{{project_name}}-frontend => {{module_name}}-frontend}/.prettierrc (100%) rename {{{project_name}}-frontend => {{module_name}}-frontend}/Dockerfile.jinja (93%) rename {{{project_name}}-frontend => {{module_name}}-frontend}/README.md.jinja (100%) create mode 100644 {{module_name}}-frontend/docker/nginx/default.conf rename {{{project_name}}-frontend => {{module_name}}-frontend}/index.html.jinja (100%) rename {{{project_name}}-frontend => {{module_name}}-frontend}/package.json.jinja (91%) rename {{{project_name}}-frontend => {{module_name}}-frontend}/src/App.vue.jinja (100%) rename {{{project_name}}-frontend => {{module_name}}-frontend}/src/main.ts (100%) rename {{{project_name}}-frontend => {{module_name}}-frontend}/src/style.css (100%) rename {{{project_name}}-frontend => {{module_name}}-frontend}/tsconfig.app.json (100%) rename {{{project_name}}-frontend => {{module_name}}-frontend}/tsconfig.json (100%) rename {{{project_name}}-frontend => {{module_name}}-frontend}/tsconfig.node.json (100%) rename {{{project_name}}-frontend => {{module_name}}-frontend}/vite.config.ts (100%) rename {{{project_name}}-job => {{module_name}}-job}/.dockerignore (79%) rename {{{project_name}}-job => {{module_name}}-job}/.python-version (100%) rename {{{project_name}}-job => {{module_name}}-job}/Dockerfile.jinja (69%) rename {{{project_name}}-job => {{module_name}}-job}/README.md.jinja (100%) rename {{{project_name}}-job => {{module_name}}-job}/main.py (100%) rename {{{project_name}}-job => {{module_name}}-job}/pyproject.toml.jinja (100%) rename {{{project_name}}-job => {{module_name}}-job}/test/test_main.py.jinja (77%) rename {{{project_name}}-job => {{module_name}}-job}/{{module_name}}/worker.py (100%) delete mode 100644 {{project_name}}-frontend/docker/nginx/default.conf diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 43c00ff..926e905 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -14,8 +14,7 @@ jobs: analysis: name: Scorecard analysis runs-on: ubuntu-latest - if: "github.event.repository.default_branch == github.ref_name || - github.event_name == 'pull_request'" + if: "github.event.repository.default_branch == github.ref_name" permissions: security-events: write id-token: write diff --git a/.github/workflows/{% if backend %}backend-tests.yml{% endif %}.jinja b/.github/workflows/{% if backend %}backend-tests.yml{% endif %}.jinja index f2ea5bb..58023cd 100644 --- a/.github/workflows/{% if backend %}backend-tests.yml{% endif %}.jinja +++ b/.github/workflows/{% if backend %}backend-tests.yml{% endif %}.jinja @@ -1,28 +1,26 @@ name: Backend Tests on: -pull_request: -paths: -- "{{ project_name }}-backend/**" -- ".github/workflows/backend-tests.yml" + pull_request: + paths: + - "{{ module_name }}-backend/**" + - ".github/workflows/backend-tests.yml" permissions: -contents: read + contents: read jobs: -backend-tests: -runs-on: ubuntu-latest -defaults: -run: -working-directory: "{{ project_name }}-backend" -steps: -- uses: actions/checkout@v4 -- uses: astral-sh/setup-uv@v4 -with: -python-version-file: "{{ project_name }}-backend/.python-version" -- name: Install dependencies -run: uv sync --group dev -- name: Run backend tests -run: uv run pytest -env: -OPENAI_API_KEY: dummykey \ No newline at end of file + backend-tests: + runs-on: ubuntu-latest + defaults: + run: + working-directory: "{{ module_name }}-backend" + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v4 + with: + python-version-file: "{{ module_name }}-backend/.python-version" + - name: Install dependencies + run: uv sync --group dev + - name: Run backend tests + run: uv run pytest diff --git a/.github/workflows/{% if backend %}docker-release-backend.yml{% endif %}.jinja b/.github/workflows/{% if backend %}docker-release-backend.yml{% endif %}.jinja index d79dc9f..2ed422b 100644 --- a/.github/workflows/{% if backend %}docker-release-backend.yml{% endif %}.jinja +++ b/.github/workflows/{% if backend %}docker-release-backend.yml{% endif %}.jinja @@ -1,63 +1,60 @@ name: Build and Release Backend Docker Image permissions: -contents: read + contents: read on: -push: -tags: -- "backend-*" -workflow_dispatch: -inputs: -tag: -description: "Backend tag to release (e.g., backend-1.0.0)" -required: true -default: "backend-latest" + push: + tags: + - "backend-*" + workflow_dispatch: + inputs: + tag: + description: "Backend tag to release (e.g., backend-1.0.0)" + required: true + default: "backend-latest" jobs: -build-and-push-backend: -runs-on: ubuntu-latest -permissions: -actions: write -packages: write -steps: -- uses: actions/checkout@v4.2.2 -- uses: docker/setup-qemu-action@v3.6.0 -- uses: docker/setup-buildx-action@v3.11.1 -- uses: docker/login-action@v3.4.0 -with: -registry: ghcr.io -username: {% raw %}${{ github.actor }}{% endraw %} -password: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} -- name: Extract version from backend tag -id: vars -run: | -if [[ "{% raw %}${{ github.event_name }}{% endraw %}" == "workflow_dispatch" ]]; then -FULL_TAG="{% raw %}${{ github.event.inputs.tag }}{% endraw %}" -else -FULL_TAG=${GITHUB_REF#refs/tags/} -fi + build-and-push-backend: + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - uses: actions/checkout@v4.2.2 + - uses: docker/setup-qemu-action@v3.6.0 + - uses: docker/setup-buildx-action@v3.11.1 + - uses: docker/login-action@v3.4.0 + with: + registry: ghcr.io + username: {% raw %}${{ github.actor }}{% endraw %} + password: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} + - name: Extract version from backend tag + id: vars + run: | + if [[ "{% raw %}${{ github.event_name }}{% endraw %}" == "workflow_dispatch" ]]; then + FULL_TAG="{% raw %}${{ github.event.inputs.tag }}{% endraw %}" + else + FULL_TAG=${GITHUB_REF#refs/tags/} + fi -if [[ "$FULL_TAG" =~ ^backend-(.+)$ ]]; then -VERSION="${BASH_REMATCH[1]}" -else -echo "Error: Tag must start with 'backend-'" -exit 1 -fi + if [[ "$FULL_TAG" =~ ^backend-(.+)$ ]]; then + VERSION="${BASH_REMATCH[1]}" + else + echo "Error: Tag must start with 'backend-'" + exit 1 + fi -echo "version=${VERSION}" >> $GITHUB_OUTPUT -echo "repo_lowercase=$(echo '{% raw %}${{ github.repository }}{% endraw %}' | tr '[:upper:]' '[:lower:]')" >> -$GITHUB_OUTPUT -- uses: docker/build-push-action@v6.18.0 -with: -context: ./{{ project_name }}-backend -file: ./{{ project_name }}-backend/Dockerfile -push: true -sbom: true -provenance: true -tags: | -ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-backend:{% raw %}${{ -steps.vars.outputs.version }}{% endraw %} -ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-backend:latest -cache-from: type=gha -cache-to: type=gha,mode=max \ No newline at end of file + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" + echo "repo_lowercase=$(echo '{% raw %}${{ github.repository }}{% endraw %}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT" + - uses: docker/build-push-action@v6.18.0 + with: + context: ./{{ module_name }}-backend + file: ./{{ module_name }}-backend/Dockerfile + push: true + sbom: true + provenance: true + tags: | + ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-backend:{% raw %}${{ steps.vars.outputs.version }}{% endraw %} + ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-backend:latest + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/{% if frontend %}docker-release-frontend.yml{% endif %}.jinja b/.github/workflows/{% if frontend %}docker-release-frontend.yml{% endif %}.jinja index 8b2bef3..d4d9b3b 100644 --- a/.github/workflows/{% if frontend %}docker-release-frontend.yml{% endif %}.jinja +++ b/.github/workflows/{% if frontend %}docker-release-frontend.yml{% endif %}.jinja @@ -1,63 +1,60 @@ name: Build and Release Frontend Docker Image permissions: -contents: read + contents: read on: -push: -tags: -- "frontend-*" -workflow_dispatch: -inputs: -tag: -description: "Frontend tag to release (e.g., frontend-1.0.0)" -required: true -default: "frontend-latest" + push: + tags: + - "frontend-*" + workflow_dispatch: + inputs: + tag: + description: "Frontend tag to release (e.g., frontend-1.0.0)" + required: true + default: "frontend-latest" jobs: -build-and-push-frontend: -runs-on: ubuntu-latest -permissions: -actions: write -packages: write -steps: -- uses: actions/checkout@v4.2.2 -- uses: docker/setup-qemu-action@v3.6.0 -- uses: docker/setup-buildx-action@v3.11.1 -- uses: docker/login-action@v3.4.0 -with: -registry: ghcr.io -username: {% raw %}${{ github.actor }}{% endraw %} -password: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} -- name: Extract version from frontend tag -id: vars -run: | -if [[ "{% raw %}${{ github.event_name }}{% endraw %}" == "workflow_dispatch" ]]; then -FULL_TAG="{% raw %}${{ github.event.inputs.tag }}{% endraw %}" -else -FULL_TAG=${GITHUB_REF#refs/tags/} -fi + build-and-push-frontend: + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - uses: actions/checkout@v4.2.2 + - uses: docker/setup-qemu-action@v3.6.0 + - uses: docker/setup-buildx-action@v3.11.1 + - uses: docker/login-action@v3.4.0 + with: + registry: ghcr.io + username: {% raw %}${{ github.actor }}{% endraw %} + password: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} + - name: Extract version from frontend tag + id: vars + run: | + if [[ "{% raw %}${{ github.event_name }}{% endraw %}" == "workflow_dispatch" ]]; then + FULL_TAG="{% raw %}${{ github.event.inputs.tag }}{% endraw %}" + else + FULL_TAG=${GITHUB_REF#refs/tags/} + fi -if [[ "$FULL_TAG" =~ ^frontend-(.+)$ ]]; then -VERSION="${BASH_REMATCH[1]}" -else -echo "Error: Tag must start with 'frontend-'" -exit 1 -fi + if [[ "$FULL_TAG" =~ ^frontend-(.+)$ ]]; then + VERSION="${BASH_REMATCH[1]}" + else + echo "Error: Tag must start with 'frontend-'" + exit 1 + fi -echo "version=${VERSION}" >> $GITHUB_OUTPUT -echo "repo_lowercase=$(echo '{% raw %}${{ github.repository }}{% endraw %}' | tr '[:upper:]' '[:lower:]')" >> -$GITHUB_OUTPUT -- uses: docker/build-push-action@v6.18.0 -with: -context: ./{{ project_name }}-frontend -file: ./{{ project_name }}-frontend/Dockerfile -push: true -sbom: true -provenance: true -tags: | -ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-frontend:{% raw %}${{ -steps.vars.outputs.version }}{% endraw %} -ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-frontend:latest -cache-from: type=gha -cache-to: type=gha,mode=max \ No newline at end of file + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" + echo "repo_lowercase=$(echo '{% raw %}${{ github.repository }}{% endraw %}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT" + - uses: docker/build-push-action@v6.18.0 + with: + context: ./{{ module_name }}-frontend + file: ./{{ module_name }}-frontend/Dockerfile + push: true + sbom: true + provenance: true + tags: | + ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-frontend:{% raw %}${{ steps.vars.outputs.version }}{% endraw %} + ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-frontend:latest + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/{% if job %}docker-release-job.yml{% endif %}.jinja b/.github/workflows/{% if job %}docker-release-job.yml{% endif %}.jinja index 809653c..d16450b 100644 --- a/.github/workflows/{% if job %}docker-release-job.yml{% endif %}.jinja +++ b/.github/workflows/{% if job %}docker-release-job.yml{% endif %}.jinja @@ -1,63 +1,60 @@ name: Build and Release Job Docker Image permissions: -contents: read + contents: read on: -push: -tags: -- "job-*" -workflow_dispatch: -inputs: -tag: -description: "Job tag to release (e.g., job-1.0.0)" -required: true -default: "job-latest" + push: + tags: + - "job-*" + workflow_dispatch: + inputs: + tag: + description: "Job tag to release (e.g., job-1.0.0)" + required: true + default: "job-latest" jobs: -build-and-push-job: -runs-on: ubuntu-latest -permissions: -actions: write -packages: write -steps: -- uses: actions/checkout@v4.2.2 -- uses: docker/setup-qemu-action@v3.6.0 -- uses: docker/setup-buildx-action@v3.11.1 -- uses: docker/login-action@v3.4.0 -with: -registry: ghcr.io -username: {% raw %}${{ github.actor }}{% endraw %} -password: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} -- name: Extract version from job tag -id: vars -run: | -if [[ "{% raw %}${{ github.event_name }}{% endraw %}" == "workflow_dispatch" ]]; then -FULL_TAG="{% raw %}${{ github.event.inputs.tag }}{% endraw %}" -else -FULL_TAG=${GITHUB_REF#refs/tags/} -fi + build-and-push-job: + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - uses: actions/checkout@v4.2.2 + - uses: docker/setup-qemu-action@v3.6.0 + - uses: docker/setup-buildx-action@v3.11.1 + - uses: docker/login-action@v3.4.0 + with: + registry: ghcr.io + username: {% raw %}${{ github.actor }}{% endraw %} + password: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} + - name: Extract version from job tag + id: vars + run: | + if [[ "{% raw %}${{ github.event_name }}{% endraw %}" == "workflow_dispatch" ]]; then + FULL_TAG="{% raw %}${{ github.event.inputs.tag }}{% endraw %}" + else + FULL_TAG=${GITHUB_REF#refs/tags/} + fi -if [[ "$FULL_TAG" =~ ^job-(.+)$ ]]; then -VERSION="${BASH_REMATCH[1]}" -else -echo "Error: Tag must start with 'job-'" -exit 1 -fi + if [[ "$FULL_TAG" =~ ^job-(.+)$ ]]; then + VERSION="${BASH_REMATCH[1]}" + else + echo "Error: Tag must start with 'job-'" + exit 1 + fi -echo "version=${VERSION}" >> $GITHUB_OUTPUT -echo "repo_lowercase=$(echo '{% raw %}${{ github.repository }}{% endraw %}' | tr '[:upper:]' '[:lower:]')" >> -$GITHUB_OUTPUT -- uses: docker/build-push-action@v6.18.0 -with: -context: ./{{ project_name }}-job -file: ./{{ project_name }}-job/Dockerfile -push: true -sbom: true -provenance: true -tags: | -ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-job:{% raw %}${{ -steps.vars.outputs.version }}{% endraw %} -ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-job:latest -cache-from: type=gha -cache-to: type=gha,mode=max \ No newline at end of file + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" + echo "repo_lowercase=$(echo '{% raw %}${{ github.repository }}{% endraw %}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT" + - uses: docker/build-push-action@v6.18.0 + with: + context: ./{{ module_name }}-job + file: ./{{ module_name }}-job/Dockerfile + push: true + sbom: true + provenance: true + tags: | + ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-job:{% raw %}${{ steps.vars.outputs.version }}{% endraw %} + ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-job:latest + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/README.md.jinja b/README.md.jinja index 7e37b20..c385192 100644 --- a/README.md.jinja +++ b/README.md.jinja @@ -2,7 +2,7 @@ What to adjust: -- Add a long desciption. +- Add a long description. - Add links for your final repo to report a bug or request a feature. - Append list of used technologies. - If you have, add a roadmap or remove this section. @@ -52,12 +52,19 @@ See the [open issues](#) for a full list of proposed features (and known issues) _how can i start and fly this project_ -Copier uses Jinja extensions in this template, so install Copier together with the required packages in the same uv tool environment before rendering the template: - ```bash -uv tool install --with jinja2-time --with jinja2-slug --with jinja-markdown copier +# Install dependencies +uv sync + +# Configure environment variables (copy and edit the example) +cp .env.example .env + +# Run the project +uv run python main.py ``` +> For template maintenance details (updating the Copier template, Jinja extensions, etc.) see [CONTRIBUTING.md](CONTRIBUTING.md). + ## Documentation See the [docs][docs-website] for more details. @@ -93,4 +100,4 @@ it@M - opensource@muenchen.de [vue-repo]: https://vuejs.org/ [vite-shield]: https://img.shields.io/badge/vite-build-646CFF?logo=vite&logoColor=white [vite-repo]: https://vite.dev/ -[docs-website]: https://it-at-m.github.io/{{ project_name }}/ +[docs-website]: https://{{ repository_owner }}.github.io/{{ project_name }}/ diff --git a/compose.yaml.jinja b/compose.yaml.jinja index d9673d0..ea78c68 100644 --- a/compose.yaml.jinja +++ b/compose.yaml.jinja @@ -2,7 +2,7 @@ services: {% if backend %} backend: build: - context: ./{{ project_name }}-backend + context: ./{{ module_name }}-backend dockerfile: Dockerfile env_file: - ./.env @@ -12,7 +12,7 @@ services: {% if frontend %} frontend: build: - context: ./{{ project_name }}-frontend + context: ./{{ module_name }}-frontend dockerfile: Dockerfile ports: - "8081:8080" @@ -20,7 +20,7 @@ services: {% if job %} job: build: - context: ./{{ project_name }}-job + context: ./{{ module_name }}-job dockerfile: Dockerfile env_file: - ./.env diff --git a/copier.yml b/copier.yml index e45ad2c..0235919 100644 --- a/copier.yml +++ b/copier.yml @@ -12,12 +12,12 @@ _exclude: - ".git" - ".DS_Store" - ".svn" - - "{% if not frontend %}{{ project_name }}-frontend{% endif %}" - - "{% if not frontend %}{{ project_name }}-frontend/**{% endif %}" - - "{% if not backend %}{{ project_name }}-backend{% endif %}" - - "{% if not backend %}{{ project_name }}-backend/**{% endif %}" - - "{% if not job %}{{ project_name }}-job{% endif %}" - - "{% if not job %}{{ project_name }}-job/**{% endif %}" + - "{% if not frontend %}{{ module_name }}-frontend{% endif %}" + - "{% if not frontend %}{{ module_name }}-frontend/**{% endif %}" + - "{% if not backend %}{{ module_name }}-backend{% endif %}" + - "{% if not backend %}{{ module_name }}-backend/**{% endif %}" + - "{% if not job %}{{ module_name }}-job{% endif %}" + - "{% if not job %}{{ module_name }}-job/**{% endif %}" project_name: type: str @@ -33,26 +33,6 @@ repository_owner: default: it-at-m help: What GitHub owner or organization should be used for repository URLs? -backend_ubi10_base_image: - type: str - default: registry.access.redhat.com/ubi10/ubi-minimal:latest - choices: - UBI 10 regular: registry.access.redhat.com/ubi10/ubi:latest - UBI 10 minimal: registry.access.redhat.com/ubi10/ubi-minimal:latest - UBI 10 micro: registry.access.redhat.com/ubi10/ubi-micro:latest - when: "{{ backend }}" - help: Which UBI 10 base image should be used for the backend container? - -job_ubi10_base_image: - type: str - default: registry.access.redhat.com/ubi10/ubi-minimal:latest - choices: - UBI 10 regular: registry.access.redhat.com/ubi10/ubi:latest - UBI 10 minimal: registry.access.redhat.com/ubi10/ubi-minimal:latest - UBI 10 micro: registry.access.redhat.com/ubi10/ubi-micro:latest - when: "{{ job }}" - help: Which UBI 10 base image should be used for the job container? - short_description: type: str help: What is the short description for the generated project? @@ -91,3 +71,23 @@ frontend: type: bool default: true help: Create a Vue frontend? + +backend_ubi10_base_image: + type: str + default: registry.access.redhat.com/ubi10/ubi-minimal:10.1-1775622738 + choices: + UBI 10 regular: registry.access.redhat.com/ubi10/ubi:10.1-1775622738 + UBI 10 minimal: registry.access.redhat.com/ubi10/ubi-minimal:10.1-1775622738 + UBI 10 micro: registry.access.redhat.com/ubi10/ubi-micro:10.1-1775622738 + when: "{{ backend }}" + help: Which UBI 10 base image should be used for the backend container? + +job_ubi10_base_image: + type: str + default: registry.access.redhat.com/ubi10/ubi-minimal:10.1-1775622738 + choices: + UBI 10 regular: registry.access.redhat.com/ubi10/ubi:10.1-1775622738 + UBI 10 minimal: registry.access.redhat.com/ubi10/ubi-minimal:10.1-1775622738 + UBI 10 micro: registry.access.redhat.com/ubi10/ubi-micro:10.1-1775622738 + when: "{{ job }}" + help: Which UBI 10 base image should be used for the job container? diff --git a/docs/.vitepress/config.mts.jinja b/docs/.vitepress/config.mts.jinja index e2289b8..1322bf9 100644 --- a/docs/.vitepress/config.mts.jinja +++ b/docs/.vitepress/config.mts.jinja @@ -1,10 +1,10 @@ import { defineConfig } from "vitepress" export default defineConfig({ -title: "{{ project_name }}", -description: "Documentation for {{ project_name }}", -themeConfig: { -nav: [{ text: "Home", link: "/" }], -sidebar: [{ text: "Introduction", items: [{ text: "Home", link: "/" }] }], -}, -}) \ No newline at end of file + title: "{{ project_name }}", + description: "Documentation for {{ project_name }}", + themeConfig: { + nav: [{ text: "Home", link: "/" }], + sidebar: [{ text: "Introduction", items: [{ text: "Home", link: "/" }] }], + }, +}) diff --git a/ruff.toml.jinja b/ruff.toml.jinja index 44f8751..0f256b8 100644 --- a/ruff.toml.jinja +++ b/ruff.toml.jinja @@ -1,4 +1,4 @@ -src = ["{{ project_name }}-backend", "{{ project_name }}-job"] +src = ["{{ module_name }}-backend", "{{ module_name }}-job"] exclude = [ ".bzr", diff --git a/{{project_name}}-backend/.dockerignore b/{{module_name}}-backend/.dockerignore similarity index 79% rename from {{project_name}}-backend/.dockerignore rename to {{module_name}}-backend/.dockerignore index 6d20ada..ea2456f 100644 --- a/{{project_name}}-backend/.dockerignore +++ b/{{module_name}}-backend/.dockerignore @@ -5,4 +5,6 @@ __pycache__ .mypy_cache .git dist -build \ No newline at end of file +build +.env +.env.* \ No newline at end of file diff --git a/{{project_name}}-backend/.python-version b/{{module_name}}-backend/.python-version similarity index 100% rename from {{project_name}}-backend/.python-version rename to {{module_name}}-backend/.python-version diff --git a/{{project_name}}-backend/Dockerfile.jinja b/{{module_name}}-backend/Dockerfile.jinja similarity index 74% rename from {{project_name}}-backend/Dockerfile.jinja rename to {{module_name}}-backend/Dockerfile.jinja index 543da20..2930f89 100644 --- a/{{project_name}}-backend/Dockerfile.jinja +++ b/{{module_name}}-backend/Dockerfile.jinja @@ -1,19 +1,19 @@ FROM {{ backend_ubi10_base_image }} -COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ +COPY --from=ghcr.io/astral-sh/uv:0.11.14 /uv /uvx /bin/ -ENV UV_PROJECT_ENVIRONMENT=/app/backend/.venv +ENV UV_PROJECT_ENVIRONMENT=/app/{{ module_name }}/.venv ENV UV_COMPILE_BYTECODE=1 ENV UV_LINK_MODE=copy -WORKDIR /app/backend +WORKDIR /app/{{ module_name }} -COPY pyproject.toml ./ +COPY pyproject.toml uv.lock ./ RUN --mount=type=cache,target=/root/.cache/uv \ uv sync --no-dev --no-install-project -COPY . /app/backend/ +COPY . /app/{{ module_name }}/ RUN --mount=type=cache,target=/root/.cache/uv \ uv sync --no-dev @@ -33,6 +33,10 @@ LABEL org.opencontainers.image.authors="{{ oci_authors }}" \ org.opencontainers.image.title="{{ project_name }}-backend" \ org.opencontainers.image.description="Python backend for {{ short_description }}" -ENV PATH="/app/backend/.venv/bin:$PATH" +ENV PATH="/app/{{ module_name }}/.venv/bin:$PATH" -ENTRYPOINT ["/app/backend/.venv/bin/python", "main.py"] \ No newline at end of file +RUN useradd -r -u 1001 -g root appuser && chown -R appuser /app + +USER appuser + +ENTRYPOINT ["/app/{{ module_name }}/.venv/bin/python", "main.py"] diff --git a/{{project_name}}-backend/README.md.jinja b/{{module_name}}-backend/README.md.jinja similarity index 100% rename from {{project_name}}-backend/README.md.jinja rename to {{module_name}}-backend/README.md.jinja diff --git a/{{project_name}}-backend/main.py.jinja b/{{module_name}}-backend/main.py.jinja similarity index 100% rename from {{project_name}}-backend/main.py.jinja rename to {{module_name}}-backend/main.py.jinja diff --git a/{{project_name}}-backend/pyproject.toml.jinja b/{{module_name}}-backend/pyproject.toml.jinja similarity index 96% rename from {{project_name}}-backend/pyproject.toml.jinja rename to {{module_name}}-backend/pyproject.toml.jinja index 5ac744a..2f04b64 100644 --- a/{{project_name}}-backend/pyproject.toml.jinja +++ b/{{module_name}}-backend/pyproject.toml.jinja @@ -8,7 +8,6 @@ dependencies = [ "fastapi>=0.128.0", "httpx>=0.28.1", "pydantic-settings>=2.12.0", - "pyyaml>=6.0.3", "uvicorn[standard]>=0.40.0", ] @@ -28,4 +27,5 @@ add-bounds = "exact" [tool.pytest.ini_options] pythonpath = ["."] testpaths = ["test"] -addopts = ["--cov={{ module_name }}", "--cov-report=term-missing"] \ No newline at end of file +asyncio_mode = "auto" +addopts = ["--cov={{ module_name }}", "--cov-report=term-missing"] diff --git a/{{project_name}}-backend/test/test_app.py.jinja b/{{module_name}}-backend/test/test_app.py.jinja similarity index 100% rename from {{project_name}}-backend/test/test_app.py.jinja rename to {{module_name}}-backend/test/test_app.py.jinja diff --git a/{{project_name}}-backend/{{module_name}}/app.py.jinja b/{{module_name}}-backend/{{module_name}}/app.py.jinja similarity index 100% rename from {{project_name}}-backend/{{module_name}}/app.py.jinja rename to {{module_name}}-backend/{{module_name}}/app.py.jinja diff --git a/{{project_name}}-backend/{{module_name}}/settings.py.jinja b/{{module_name}}-backend/{{module_name}}/settings.py.jinja similarity index 100% rename from {{project_name}}-backend/{{module_name}}/settings.py.jinja rename to {{module_name}}-backend/{{module_name}}/settings.py.jinja diff --git a/{{project_name}}-frontend/.dockerignore b/{{module_name}}-frontend/.dockerignore similarity index 100% rename from {{project_name}}-frontend/.dockerignore rename to {{module_name}}-frontend/.dockerignore diff --git a/{{project_name}}-frontend/.npmrc b/{{module_name}}-frontend/.npmrc similarity index 100% rename from {{project_name}}-frontend/.npmrc rename to {{module_name}}-frontend/.npmrc diff --git a/{{project_name}}-frontend/.prettierignore b/{{module_name}}-frontend/.prettierignore similarity index 100% rename from {{project_name}}-frontend/.prettierignore rename to {{module_name}}-frontend/.prettierignore diff --git a/{{project_name}}-frontend/.prettierrc b/{{module_name}}-frontend/.prettierrc similarity index 100% rename from {{project_name}}-frontend/.prettierrc rename to {{module_name}}-frontend/.prettierrc diff --git a/{{project_name}}-frontend/Dockerfile.jinja b/{{module_name}}-frontend/Dockerfile.jinja similarity index 93% rename from {{project_name}}-frontend/Dockerfile.jinja rename to {{module_name}}-frontend/Dockerfile.jinja index e821862..b95b727 100644 --- a/{{project_name}}-frontend/Dockerfile.jinja +++ b/{{module_name}}-frontend/Dockerfile.jinja @@ -2,9 +2,9 @@ FROM node:22.22.2-alpine AS builder WORKDIR /build -COPY package.json ./ +COPY package.json package-lock.json ./ -RUN npm install +RUN npm ci COPY index.html tsconfig.json tsconfig.app.json tsconfig.node.json vite.config.ts ./ COPY src ./src @@ -34,4 +34,4 @@ LABEL org.opencontainers.image.authors="{{ oci_authors }}" \ EXPOSE 8080 -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +CMD ["nginx", "-g", "daemon off;"] diff --git a/{{project_name}}-frontend/README.md.jinja b/{{module_name}}-frontend/README.md.jinja similarity index 100% rename from {{project_name}}-frontend/README.md.jinja rename to {{module_name}}-frontend/README.md.jinja diff --git a/{{module_name}}-frontend/docker/nginx/default.conf b/{{module_name}}-frontend/docker/nginx/default.conf new file mode 100644 index 0000000..3addc0c --- /dev/null +++ b/{{module_name}}-frontend/docker/nginx/default.conf @@ -0,0 +1,23 @@ +server { + listen 8080; + server_name _; + root /opt/app-root/src; + index index.html; + + gzip on; + gzip_types text/plain text/css application/javascript application/json image/svg+xml; + + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header Referrer-Policy "strict-origin-when-cross-origin" always; + add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self';" always; + + location / { + try_files $uri $uri/ /index.html; + } + + location ~* \.(js|css|png|jpg|jpeg|svg|ico|woff|woff2)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } +} diff --git a/{{project_name}}-frontend/index.html.jinja b/{{module_name}}-frontend/index.html.jinja similarity index 100% rename from {{project_name}}-frontend/index.html.jinja rename to {{module_name}}-frontend/index.html.jinja diff --git a/{{project_name}}-frontend/package.json.jinja b/{{module_name}}-frontend/package.json.jinja similarity index 91% rename from {{project_name}}-frontend/package.json.jinja rename to {{module_name}}-frontend/package.json.jinja index 10f254e..5be454f 100644 --- a/{{project_name}}-frontend/package.json.jinja +++ b/{{module_name}}-frontend/package.json.jinja @@ -5,7 +5,7 @@ "type": "module", "scripts": { "dev": "vite", - "build": "vue-tsc --build --noCheck && vite build", + "build": "vue-tsc --build && vite build", "preview": "vite preview", "typecheck": "vue-tsc --build --noEmit", "lint": "prettier --check .", diff --git a/{{project_name}}-frontend/src/App.vue.jinja b/{{module_name}}-frontend/src/App.vue.jinja similarity index 100% rename from {{project_name}}-frontend/src/App.vue.jinja rename to {{module_name}}-frontend/src/App.vue.jinja diff --git a/{{project_name}}-frontend/src/main.ts b/{{module_name}}-frontend/src/main.ts similarity index 100% rename from {{project_name}}-frontend/src/main.ts rename to {{module_name}}-frontend/src/main.ts diff --git a/{{project_name}}-frontend/src/style.css b/{{module_name}}-frontend/src/style.css similarity index 100% rename from {{project_name}}-frontend/src/style.css rename to {{module_name}}-frontend/src/style.css diff --git a/{{project_name}}-frontend/tsconfig.app.json b/{{module_name}}-frontend/tsconfig.app.json similarity index 100% rename from {{project_name}}-frontend/tsconfig.app.json rename to {{module_name}}-frontend/tsconfig.app.json diff --git a/{{project_name}}-frontend/tsconfig.json b/{{module_name}}-frontend/tsconfig.json similarity index 100% rename from {{project_name}}-frontend/tsconfig.json rename to {{module_name}}-frontend/tsconfig.json diff --git a/{{project_name}}-frontend/tsconfig.node.json b/{{module_name}}-frontend/tsconfig.node.json similarity index 100% rename from {{project_name}}-frontend/tsconfig.node.json rename to {{module_name}}-frontend/tsconfig.node.json diff --git a/{{project_name}}-frontend/vite.config.ts b/{{module_name}}-frontend/vite.config.ts similarity index 100% rename from {{project_name}}-frontend/vite.config.ts rename to {{module_name}}-frontend/vite.config.ts diff --git a/{{project_name}}-job/.dockerignore b/{{module_name}}-job/.dockerignore similarity index 79% rename from {{project_name}}-job/.dockerignore rename to {{module_name}}-job/.dockerignore index 6d20ada..ea2456f 100644 --- a/{{project_name}}-job/.dockerignore +++ b/{{module_name}}-job/.dockerignore @@ -5,4 +5,6 @@ __pycache__ .mypy_cache .git dist -build \ No newline at end of file +build +.env +.env.* \ No newline at end of file diff --git a/{{project_name}}-job/.python-version b/{{module_name}}-job/.python-version similarity index 100% rename from {{project_name}}-job/.python-version rename to {{module_name}}-job/.python-version diff --git a/{{project_name}}-job/Dockerfile.jinja b/{{module_name}}-job/Dockerfile.jinja similarity index 69% rename from {{project_name}}-job/Dockerfile.jinja rename to {{module_name}}-job/Dockerfile.jinja index e05a50d..0896de4 100644 --- a/{{project_name}}-job/Dockerfile.jinja +++ b/{{module_name}}-job/Dockerfile.jinja @@ -1,22 +1,22 @@ FROM {{ job_ubi10_base_image }} -COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ +COPY --from=ghcr.io/astral-sh/uv:0.11.14 /uv /uvx /bin/ -ENV UV_PROJECT_ENVIRONMENT=/app/job/.venv +ENV UV_PROJECT_ENVIRONMENT=/app/{{ module_name }}/.venv ENV UV_COMPILE_BYTECODE=1 ENV UV_LINK_MODE=copy -WORKDIR /app/job +WORKDIR /app/{{ module_name }} -COPY pyproject.toml ./ +COPY pyproject.toml uv.lock ./ RUN --mount=type=cache,target=/root/.cache/uv \ - uv sync --no-dev --no-install-project + uv sync --no-dev --no-install-project --frozen -COPY . /app/job/ +COPY . /app/{{ module_name }}/ RUN --mount=type=cache,target=/root/.cache/uv \ - uv sync --no-dev + uv sync --no-dev --frozen ARG IMAGE_CREATED="unknown" ARG IMAGE_REVISION="unknown" @@ -33,6 +33,10 @@ LABEL org.opencontainers.image.authors="{{ oci_authors }}" \ org.opencontainers.image.title="{{ project_name }}-job" \ org.opencontainers.image.description="Background job for {{ short_description }}" -ENV PATH="/app/job/.venv/bin:$PATH" +ENV PATH="/app/{{ module_name }}/.venv/bin:$PATH" -ENTRYPOINT ["/app/job/.venv/bin/python", "main.py"] \ No newline at end of file +RUN useradd -r -u 1001 -g root appuser && chown -R appuser /app + +USER appuser + +ENTRYPOINT ["/app/{{ module_name }}/.venv/bin/python", "main.py"] diff --git a/{{project_name}}-job/README.md.jinja b/{{module_name}}-job/README.md.jinja similarity index 100% rename from {{project_name}}-job/README.md.jinja rename to {{module_name}}-job/README.md.jinja diff --git a/{{project_name}}-job/main.py b/{{module_name}}-job/main.py similarity index 100% rename from {{project_name}}-job/main.py rename to {{module_name}}-job/main.py diff --git a/{{project_name}}-job/pyproject.toml.jinja b/{{module_name}}-job/pyproject.toml.jinja similarity index 100% rename from {{project_name}}-job/pyproject.toml.jinja rename to {{module_name}}-job/pyproject.toml.jinja diff --git a/{{project_name}}-job/test/test_main.py.jinja b/{{module_name}}-job/test/test_main.py.jinja similarity index 77% rename from {{project_name}}-job/test/test_main.py.jinja rename to {{module_name}}-job/test/test_main.py.jinja index c42aa20..73a1966 100644 --- a/{{project_name}}-job/test/test_main.py.jinja +++ b/{{module_name}}-job/test/test_main.py.jinja @@ -24,8 +24,9 @@ def test_run_uses_example_url(monkeypatch) -> None: captured["url"] = url return DummyResponse() - monkeypatch.setattr(main.httpx, "AsyncClient", lambda timeout: DummyClient()) + monkeypatch.setattr(main.httpx, "AsyncClient", lambda *args, **kwargs: DummyClient()) asyncio.run(main.run()) - assert captured["url"] == main.EXAMPLE_URL \ No newline at end of file + assert "url" in captured + assert captured["url"] == main.EXAMPLE_URL diff --git a/{{project_name}}-job/{{module_name}}/worker.py b/{{module_name}}-job/{{module_name}}/worker.py similarity index 100% rename from {{project_name}}-job/{{module_name}}/worker.py rename to {{module_name}}-job/{{module_name}}/worker.py diff --git a/{{project_name}}-frontend/docker/nginx/default.conf b/{{project_name}}-frontend/docker/nginx/default.conf deleted file mode 100644 index f33878d..0000000 --- a/{{project_name}}-frontend/docker/nginx/default.conf +++ /dev/null @@ -1,10 +0,0 @@ -server { - listen 8080; - server_name _; - root /opt/app-root/src; - index index.html; - - location / { - try_files $uri $uri/ /index.html; - } -} \ No newline at end of file From 171c1bf36680decc2b208a79402926cccff3e252 Mon Sep 17 00:00:00 2001 From: Fabian Reinold Date: Mon, 18 May 2026 00:22:46 +0200 Subject: [PATCH 4/6] fix: align backend Dockerfile with job, tighten nginx headers, and fix prettier dep - Use {{ module_name }} (not {{ project_name }}) in frontend image tags so Docker tag names are guaranteed lowercase and symbol-free - Add --frozen to both uv sync calls in backend Dockerfile, matching the job Dockerfile and ensuring builds fail fast on lockfile drift - Add @muenchen/prettier-codeformat 1.0.2 to devDependencies in frontend and docs package.json so `npm run lint` can resolve the .prettierrc config - Re-apply security headers (X-Frame-Options, X-Content-Type-Options, Referrer-Policy, CSP) inside the static-assets location block, which suppresses parent add_header directives in nginx - Add gzip_vary on to emit Vary: Accept-Encoding for correct CDN caching - Document the lockfile generation step (uv lock / npm install + commit) required before the first Docker build --- .claude/settings.local.json | 8 ++++++++ ...%}docker-release-frontend.yml{% endif %}.jinja | 4 ++-- docs/guide/index.md.jinja | 15 ++++++++++++++- docs/package.json.jinja | 1 + {{module_name}}-backend/Dockerfile.jinja | 4 ++-- {{module_name}}-frontend/README.md.jinja | 6 +++++- .../docker/nginx/default.conf | 5 +++++ {{module_name}}-frontend/package.json.jinja | 1 + 8 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 .claude/settings.local.json diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 0000000..2e3f958 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,8 @@ +{ + "permissions": { + "allow": [ + "Skill(superpowers:receiving-code-review)", + "Skill(superpowers:receiving-code-review:*)" + ] + } +} diff --git a/.github/workflows/{% if frontend %}docker-release-frontend.yml{% endif %}.jinja b/.github/workflows/{% if frontend %}docker-release-frontend.yml{% endif %}.jinja index d4d9b3b..3ad9360 100644 --- a/.github/workflows/{% if frontend %}docker-release-frontend.yml{% endif %}.jinja +++ b/.github/workflows/{% if frontend %}docker-release-frontend.yml{% endif %}.jinja @@ -54,7 +54,7 @@ jobs: sbom: true provenance: true tags: | - ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-frontend:{% raw %}${{ steps.vars.outputs.version }}{% endraw %} - ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ project_name }}-frontend:latest + ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ module_name }}-frontend:{% raw %}${{ steps.vars.outputs.version }}{% endraw %} + ghcr.io/{% raw %}${{ steps.vars.outputs.repo_lowercase }}{% endraw %}/{{ module_name }}-frontend:latest cache-from: type=gha cache-to: type=gha,mode=max diff --git a/docs/guide/index.md.jinja b/docs/guide/index.md.jinja index 02b0384..e4e8bc9 100644 --- a/docs/guide/index.md.jinja +++ b/docs/guide/index.md.jinja @@ -2,4 +2,17 @@ This is the starter guide for {{ project_name }}. -Add your project introduction, setup instructions, and deployment notes here. \ No newline at end of file +Add your project introduction, setup instructions, and deployment notes here. + +## Initial setup after template generation + +After applying the Copier template, generate and commit the lockfiles before your first Docker build: + +{% if backend or job %} +**Python backend/job** — run `uv lock` (or `uv sync`) and commit the generated `uv.lock`. +{% endif %} +{% if frontend %} +**Vue frontend** — run `npm install` inside `{{ module_name }}-frontend/` and commit the generated `package-lock.json`. +{% endif %} + +These lockfiles are required by the Dockerfiles (`uv sync --frozen` / `npm ci`) to produce reproducible images. \ No newline at end of file diff --git a/docs/package.json.jinja b/docs/package.json.jinja index 35cb817..9c1e677 100644 --- a/docs/package.json.jinja +++ b/docs/package.json.jinja @@ -11,6 +11,7 @@ "fix": "prettier --write ." }, "devDependencies": { + "@muenchen/prettier-codeformat": "1.0.2", "prettier": "3.5.3", "vitepress": "^1.6.4" } diff --git a/{{module_name}}-backend/Dockerfile.jinja b/{{module_name}}-backend/Dockerfile.jinja index 2930f89..961ac14 100644 --- a/{{module_name}}-backend/Dockerfile.jinja +++ b/{{module_name}}-backend/Dockerfile.jinja @@ -11,12 +11,12 @@ WORKDIR /app/{{ module_name }} COPY pyproject.toml uv.lock ./ RUN --mount=type=cache,target=/root/.cache/uv \ - uv sync --no-dev --no-install-project + uv sync --frozen --no-dev --no-install-project COPY . /app/{{ module_name }}/ RUN --mount=type=cache,target=/root/.cache/uv \ - uv sync --no-dev + uv sync --frozen --no-dev ARG IMAGE_CREATED="unknown" ARG IMAGE_REVISION="unknown" diff --git a/{{module_name}}-frontend/README.md.jinja b/{{module_name}}-frontend/README.md.jinja index 9385302..8d88d60 100644 --- a/{{module_name}}-frontend/README.md.jinja +++ b/{{module_name}}-frontend/README.md.jinja @@ -7,4 +7,8 @@ Vue 3 + Vite + TypeScript starter. ```bash npm install npm run dev -``` \ No newline at end of file +``` + +> **First-time setup:** After applying this template, commit the generated +> `package-lock.json` before running a Docker build (`npm ci` requires it). +> This is analogous to committing `uv.lock` for the Python backend/job. \ No newline at end of file diff --git a/{{module_name}}-frontend/docker/nginx/default.conf b/{{module_name}}-frontend/docker/nginx/default.conf index 3addc0c..7f4bd76 100644 --- a/{{module_name}}-frontend/docker/nginx/default.conf +++ b/{{module_name}}-frontend/docker/nginx/default.conf @@ -5,6 +5,7 @@ server { index index.html; gzip on; + gzip_vary on; gzip_types text/plain text/css application/javascript application/json image/svg+xml; add_header X-Frame-Options "SAMEORIGIN" always; @@ -19,5 +20,9 @@ server { location ~* \.(js|css|png|jpg|jpeg|svg|ico|woff|woff2)$ { expires 1y; add_header Cache-Control "public, immutable"; + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header Referrer-Policy "strict-origin-when-cross-origin" always; + add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self';" always; } } diff --git a/{{module_name}}-frontend/package.json.jinja b/{{module_name}}-frontend/package.json.jinja index 5be454f..d6b98bf 100644 --- a/{{module_name}}-frontend/package.json.jinja +++ b/{{module_name}}-frontend/package.json.jinja @@ -15,6 +15,7 @@ "vue": "3.5.27" }, "devDependencies": { + "@muenchen/prettier-codeformat": "1.0.2", "@tsconfig/node-lts": "22.0.4", "@types/node": "22.19.17", "@vitejs/plugin-vue": "6.0.5", From 7a5d7deaae1d97528e6a60eab2ff744e2a00bdf6 Mon Sep 17 00:00:00 2001 From: Fabian Reinold Date: Mon, 18 May 2026 18:07:26 +0200 Subject: [PATCH 5/6] fix: convert ruff and deploy-docs workflows to Jinja templates to prevent execution in template repo --- .github/workflows/{deploy-docs.yml => deploy-docs.yml.jinja} | 2 +- .github/workflows/{ruff.yml => ruff.yml.jinja} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{deploy-docs.yml => deploy-docs.yml.jinja} (94%) rename .github/workflows/{ruff.yml => ruff.yml.jinja} (100%) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml.jinja similarity index 94% rename from .github/workflows/deploy-docs.yml rename to .github/workflows/deploy-docs.yml.jinja index 03fa31c..e909f1f 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml.jinja @@ -46,7 +46,7 @@ jobs: runs-on: ubuntu-latest environment: name: github-pages - url: "${{ steps.deployment.outputs.page_url }}" + url: "{% raw %}${{ steps.deployment.outputs.page_url }}{% endraw %}" steps: - id: deployment uses: actions/deploy-pages@v4 diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml.jinja similarity index 100% rename from .github/workflows/ruff.yml rename to .github/workflows/ruff.yml.jinja From 587875dcc525a08c3ff070ff7b2b8b2113430117 Mon Sep 17 00:00:00 2001 From: Fabian Reinold Date: Mon, 18 May 2026 19:22:21 +0200 Subject: [PATCH 6/6] chore: add gitignore --- .claude/settings.local.json | 4 +- .gitignore | 367 ++++++++++++++++++++++++++++++++++++ 2 files changed, 370 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 2e3f958..0981321 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -2,7 +2,9 @@ "permissions": { "allow": [ "Skill(superpowers:receiving-code-review)", - "Skill(superpowers:receiving-code-review:*)" + "Skill(superpowers:receiving-code-review:*)", + "Skill(superpowers:writing-plans)", + "Skill(superpowers:writing-plans:*)" ] } } diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..932ccf4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,367 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[codz] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py.cover +*.lcov +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +# Pipfile.lock + +# UV +# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# uv.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +# poetry.lock +# poetry.toml + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python. +# https://pdm-project.org/en/latest/usage/project/#working-with-version-control +# pdm.lock +# pdm.toml +.pdm-python +.pdm-build/ + +# pixi +# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control. +# pixi.lock +# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one +# in the .venv directory. It is recommended not to include this directory in version control. +.pixi/* +!.pixi/config.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule* +celerybeat.pid + +# Redis +*.rdb +*.aof +*.pid + +# RabbitMQ +mnesia/ +rabbitmq/ +rabbitmq-data/ + +# ActiveMQ +activemq-data/ + +# SageMath parsed files +*.sage.py + +# Environments +.env +.envrc +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +# .idea/ + +# Abstra +# Abstra is an AI-powered process automation framework. +# Ignore directories containing user credentials, local state, and settings. +# Learn more at https://abstra.io/docs +.abstra/ + +# Visual Studio Code +# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore +# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore +# and can be added to the global gitignore or merged into this file. However, if you prefer, +# you could uncomment the following to ignore the entire vscode folder +# .vscode/ +# Temporary file for partial code execution +tempCodeRunnerFile.py + +# Ruff stuff: +.ruff_cache/ + +# PyPI configuration file +.pypirc + +# Marimo +marimo/_static/ +marimo/_lsp/ +__marimo__/ + +# Streamlit +.streamlit/secrets.toml + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.* +!.env.example + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist +.output + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp directory +.temp + +# Sveltekit cache directory +.svelte-kit/ + +# vitepress build output +**/.vitepress/dist + +# vitepress cache directory +**/.vitepress/cache + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# Firebase cache directory +.firebase/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# pnpm +.pnpm-store + +# yarn v3 +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions + +# Vite files +vite.config.js.timestamp-* +vite.config.ts.timestamp-* +.vite/ + +# Custom +.claude/settings.local.json \ No newline at end of file