diff --git a/.github/scripts/get_latest_tags.py b/.github/scripts/get_latest_tags.py index 2eb62fb7..526716ce 100644 --- a/.github/scripts/get_latest_tags.py +++ b/.github/scripts/get_latest_tags.py @@ -49,6 +49,13 @@ def update_env(file_name: str, frappe_tag: str, erpnext_tag: str | None = None): f.write(text) +def update_output(file_name: str, frappe_tag: str, erpnext_tag: str | None = None): + with open(file_name, "a", encoding="utf-8") as f: + f.write(f"frappe_version={frappe_tag}\n") + if erpnext_tag: + f.write(f"erpnext_version={erpnext_tag}\n") + + def _print_resp(frappe_tag: str, erpnext_tag: str | None = None): print(json.dumps({"frappe": frappe_tag, "erpnext": erpnext_tag})) @@ -70,6 +77,9 @@ def main(_args: list[str]) -> int: file_name = os.getenv("GITHUB_ENV") if file_name: update_env(file_name, frappe_tag, erpnext_tag) + file_name = os.getenv("GITHUB_OUTPUT") + if file_name: + update_output(file_name, frappe_tag, erpnext_tag) _print_resp(frappe_tag, erpnext_tag) return 0 diff --git a/.github/workflows/build_develop.yml b/.github/workflows/build_develop.yml deleted file mode 100644 index 8ec061ed..00000000 --- a/.github/workflows/build_develop.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Develop build - -on: - pull_request: - branches: - - main - paths: - - images/production/** - - overrides/** - - tests/** - - compose.yaml - - docker-bake.hcl - - example.env - - .github/workflows/build_develop.yml - - schedule: - # Every day at 12:00 pm - - cron: 0 0 * * * - - workflow_dispatch: - -jobs: - build: - uses: ./.github/workflows/docker-build-push.yml - with: - repo: erpnext - version: develop - push: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} - python_version: 3.14.2 - node_version: 24.12.0 - secrets: - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/build_bench.yml b/.github/workflows/core-build-bench.yml similarity index 95% rename from .github/workflows/build_bench.yml rename to .github/workflows/core-build-bench.yml index 1bc47018..ef0ecbd0 100644 --- a/.github/workflows/build_bench.yml +++ b/.github/workflows/core-build-bench.yml @@ -1,4 +1,4 @@ -name: Bench +name: Core / Build Bench on: pull_request: @@ -7,7 +7,7 @@ on: paths: - images/bench/** - docker-bake.hcl - - .github/workflows/build_bench.yml + - .github/workflows/core-build-bench.yml schedule: # Every day at 12:00 pm diff --git a/.github/workflows/core-build-develop.yml b/.github/workflows/core-build-develop.yml new file mode 100644 index 00000000..64800241 --- /dev/null +++ b/.github/workflows/core-build-develop.yml @@ -0,0 +1,49 @@ +name: Core / Build Develop + +permissions: + contents: read + packages: write + +on: + pull_request: + branches: + - main + paths: + - images/production/** + - overrides/** + - tests/** + - compose.yaml + - docker-bake.hcl + - example.env + - .github/workflows/core-build-develop.yml + - .github/workflows/core-build-test-images.yml + - .github/workflows/core-publish-images.yml + + schedule: + # Every day at 12:00 pm + - cron: 0 0 * * * + + workflow_dispatch: + +jobs: + test: + uses: ./.github/workflows/core-build-test-images.yml + with: + repo: erpnext + version: develop + python_version: 3.14.2 + node_version: 24.12.0 + + publish: + if: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} + needs: test + uses: ./.github/workflows/core-publish-images.yml + with: + repo: erpnext + frappe_version: ${{ needs.test.outputs.frappe_version }} + erpnext_version: ${{ needs.test.outputs.erpnext_version }} + python_version: 3.14.2 + node_version: 24.12.0 + secrets: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/build_stable.yml b/.github/workflows/core-build-stable.yml similarity index 67% rename from .github/workflows/build_stable.yml rename to .github/workflows/core-build-stable.yml index 174516bc..6c453adb 100644 --- a/.github/workflows/build_stable.yml +++ b/.github/workflows/core-build-stable.yml @@ -1,4 +1,8 @@ -name: Stable build +name: Core / Build Stable + +permissions: + contents: read + packages: write on: pull_request: @@ -11,7 +15,9 @@ on: - compose.yaml - docker-bake.hcl - example.env - - .github/workflows/build_stable.yml + - .github/workflows/core-build-stable.yml + - .github/workflows/core-build-test-images.yml + - .github/workflows/core-publish-images.yml push: branches: @@ -23,6 +29,9 @@ on: - compose.yaml - docker-bake.hcl - example.env + - .github/workflows/core-build-stable.yml + - .github/workflows/core-build-test-images.yml + - .github/workflows/core-publish-images.yml # Triggered from frappe/frappe and frappe/erpnext on releases repository_dispatch: @@ -30,24 +39,43 @@ on: workflow_dispatch: jobs: - v15: - uses: ./.github/workflows/docker-build-push.yml + v15_test: + uses: ./.github/workflows/core-build-test-images.yml with: repo: erpnext version: "15" - push: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} + python_version: 3.11.6 + node_version: 20.19.2 + + v15_publish: + if: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} + needs: v15_test + uses: ./.github/workflows/core-publish-images.yml + with: + repo: erpnext + frappe_version: ${{ needs.v15_test.outputs.frappe_version }} + erpnext_version: ${{ needs.v15_test.outputs.erpnext_version }} python_version: 3.11.6 node_version: 20.19.2 secrets: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - v16: - uses: ./.github/workflows/docker-build-push.yml + v16_test: + uses: ./.github/workflows/core-build-test-images.yml with: repo: erpnext version: "16" - push: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} + python_version: 3.14.2 + node_version: 24.12.0 + v16_publish: + if: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} + needs: v16_test + uses: ./.github/workflows/core-publish-images.yml + with: + repo: erpnext + frappe_version: ${{ needs.v16_test.outputs.frappe_version }} + erpnext_version: ${{ needs.v16_test.outputs.erpnext_version }} python_version: 3.14.2 node_version: 24.12.0 secrets: @@ -58,7 +86,7 @@ jobs: name: Update example.env and pwd.yml runs-on: ubuntu-latest if: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} - needs: v16 + needs: v16_publish steps: - name: Checkout @@ -96,7 +124,7 @@ jobs: name: Release Helm runs-on: ubuntu-latest if: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} - needs: v16 + needs: v16_publish steps: - name: Setup deploy key diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/core-build-test-images.yml similarity index 64% rename from .github/workflows/docker-build-push.yml rename to .github/workflows/core-build-test-images.yml index 9fee1782..7c118c93 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/core-build-test-images.yml @@ -1,4 +1,4 @@ -name: Build +name: Core / Build and Test Images on: workflow_call: @@ -11,9 +11,6 @@ on: required: true type: string description: "Major version, git tags should match 'v{version}.*'; or 'develop'" - push: - required: true - type: boolean python_version: required: true type: string @@ -22,16 +19,36 @@ on: required: true type: string description: NodeJS Version - secrets: - DOCKERHUB_USERNAME: - required: true - DOCKERHUB_TOKEN: - required: true + outputs: + frappe_version: + description: "Resolved frappe image tag" + value: ${{ jobs.resolve.outputs.frappe_version }} + erpnext_version: + description: "Resolved erpnext image tag" + value: ${{ jobs.resolve.outputs.erpnext_version }} + +permissions: + contents: read jobs: + resolve: + name: Resolve Versions + runs-on: ubuntu-latest + outputs: + frappe_version: ${{ steps.resolve.outputs.frappe_version }} + erpnext_version: ${{ steps.resolve.outputs.erpnext_version }} + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Resolve image versions + id: resolve + run: python3 ./.github/scripts/get_latest_tags.py --repo ${{ inputs.repo }} --version ${{ inputs.version }} + build: name: Build runs-on: ubuntu-latest + needs: resolve services: registry: image: docker.io/registry:2 @@ -57,8 +74,12 @@ jobs: driver-opts: network=host platforms: linux/${{ matrix.arch }} - - name: Get latest versions - run: python3 ./.github/scripts/get_latest_tags.py --repo ${{ inputs.repo }} --version ${{ inputs.version }} + - name: Set resolved versions + run: | + echo "FRAPPE_VERSION=${{ needs.resolve.outputs.frappe_version }}" >> "$GITHUB_ENV" + if [ -n "${{ needs.resolve.outputs.erpnext_version }}" ]; then + echo "ERPNEXT_VERSION=${{ needs.resolve.outputs.erpnext_version }}" >> "$GITHUB_ENV" + fi - name: Set build args run: | @@ -85,17 +106,3 @@ jobs: - name: Test run: venv/bin/pytest --color=yes - - - name: Login - if: ${{ inputs.push }} - uses: docker/login-action@v4 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Push - if: ${{ inputs.push }} - uses: docker/bake-action@v7.1.0 - with: - push: true - set: "*.platform=linux/amd64,linux/arm64" diff --git a/.github/workflows/core-publish-images.yml b/.github/workflows/core-publish-images.yml new file mode 100644 index 00000000..4da6bfee --- /dev/null +++ b/.github/workflows/core-publish-images.yml @@ -0,0 +1,92 @@ +name: Core / Publish Images + +on: + workflow_call: + inputs: + repo: + required: true + type: string + description: "'erpnext' or 'frappe'" + frappe_version: + required: true + type: string + description: "Resolved frappe image tag" + erpnext_version: + required: false + type: string + description: "Resolved erpnext image tag" + python_version: + required: true + type: string + description: Python Version + node_version: + required: true + type: string + description: NodeJS Version + secrets: + DOCKERHUB_USERNAME: + required: true + DOCKERHUB_TOKEN: + required: true + +permissions: + contents: read + packages: write + +jobs: + publish: + name: Publish + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Setup QEMU + uses: docker/setup-qemu-action@v4 + with: + image: tonistiigi/binfmt:latest + platforms: all + + - name: Setup Buildx + uses: docker/setup-buildx-action@v4 + + - name: Set resolved versions + run: | + echo "FRAPPE_VERSION=${{ inputs.frappe_version }}" >> "$GITHUB_ENV" + if [ -n "${{ inputs.erpnext_version }}" ]; then + echo "ERPNEXT_VERSION=${{ inputs.erpnext_version }}" >> "$GITHUB_ENV" + fi + + - name: Set build args + run: | + echo "PYTHON_VERSION=${{ inputs.python_version }}" >> "$GITHUB_ENV" + echo "NODE_VERSION=${{ inputs.node_version }}" >> "$GITHUB_ENV" + + - name: Login to Docker Hub + uses: docker/login-action@v4 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Push Docker Hub images + uses: docker/bake-action@v7.1.0 + with: + push: true + set: "*.platform=linux/amd64,linux/arm64" + + - name: Login to GHCR + uses: docker/login-action@v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Push GHCR base images + uses: docker/bake-action@v7.1.0 + with: + targets: base-images + push: true + set: "*.platform=linux/amd64,linux/arm64" + env: + REGISTRY_USER: ghcr.io/${{ github.repository_owner }} diff --git a/.github/workflows/publish_docs.yml b/.github/workflows/docs-publish-site.yml similarity index 93% rename from .github/workflows/publish_docs.yml rename to .github/workflows/docs-publish-site.yml index ffecb82c..32a9fb48 100644 --- a/.github/workflows/publish_docs.yml +++ b/.github/workflows/docs-publish-site.yml @@ -1,11 +1,11 @@ -name: Deploy Frappe Docker Docs to GitHub Pages +name: Docs / Publish Site on: push: branches: [main] paths: - "docs/**" - - ".github/workflows/publish_docs.yml" + - ".github/workflows/docs-publish-site.yml" workflow_dispatch: permissions: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 47be9ebb..1b1db5c4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -143,4 +143,4 @@ In case of new release of Debian. e.g. bullseye to bookworm. Change following fi Change following files on release of ERPNext -- `.github/workflows/build_stable.yml`: Add the new release step under `jobs` and remove the unmaintained one. e.g. In case v12, v13 available, v14 will be added and v12 will be removed on release of v14. Also change the `needs:` for later steps to `v14` from `v13`. +- `.github/workflows/core-build-stable.yml`: Add the new release step under `jobs` and remove the unmaintained one. e.g. In case v12, v13 available, v14 will be added and v12 will be removed on release of v14. Also change the `needs:` for later steps to `v14` from `v13`. diff --git a/README.md b/README.md index 6619e4d2..ccf213ab 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Frappe Docker -[![Build Stable](https://github.com/frappe/frappe_docker/actions/workflows/build_stable.yml/badge.svg)](https://github.com/frappe/frappe_docker/actions/workflows/build_stable.yml) -[![Build Develop](https://github.com/frappe/frappe_docker/actions/workflows/build_develop.yml/badge.svg)](https://github.com/frappe/frappe_docker/actions/workflows/build_develop.yml) +[![Build Stable](https://github.com/frappe/frappe_docker/actions/workflows/core-build-stable.yml/badge.svg)](https://github.com/frappe/frappe_docker/actions/workflows/core-build-stable.yml) +[![Build Develop](https://github.com/frappe/frappe_docker/actions/workflows/core-build-develop.yml/badge.svg)](https://github.com/frappe/frappe_docker/actions/workflows/core-build-develop.yml) Docker images and orchestration for Frappe applications. diff --git a/docker-bake.hcl b/docker-bake.hcl index baf7f3b3..cb59f835 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -62,6 +62,10 @@ group "default" { targets = ["erpnext", "base", "build"] } +group "base-images" { + targets = ["base", "build"] +} + function "tag" { params = [repo, version] result = [