From e6c0e7263b8fe144dd3b59f150b60fef5aa5e162 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Mon, 26 Jun 2023 11:54:37 +0530 Subject: [PATCH] ci: refactor (#1158) * ci: refactor use debian bookworm use updated wkhtmltopdf override python and nodejs versions * ci: fix bench and test * ci: remove comments from example.env * docs: add maintenance section --- .github/workflows/build_bench.yml | 3 +++ .github/workflows/build_stable.yml | 4 ++++ .github/workflows/docker-build-push.yml | 13 +++++++++++++ CONTRIBUTING.md | 11 +++++++++++ docker-bake.hcl | 11 +++++++++-- images/bench/Dockerfile | 7 ++++--- images/custom/Containerfile | 12 +++++++----- images/production/Containerfile | 12 +++++++----- 8 files changed, 58 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build_bench.yml b/.github/workflows/build_bench.yml index 158c7f4..9f8fd51 100644 --- a/.github/workflows/build_bench.yml +++ b/.github/workflows/build_bench.yml @@ -31,6 +31,9 @@ jobs: - name: Setup Buildx uses: docker/setup-buildx-action@v2 + - name: Set Environment Variables + run: cat example.env | grep -o '^[^#]*' >> "$GITHUB_ENV" + - name: Build and test uses: docker/bake-action@v3.1.0 with: diff --git a/.github/workflows/build_stable.yml b/.github/workflows/build_stable.yml index e842a3d..f33832c 100644 --- a/.github/workflows/build_stable.yml +++ b/.github/workflows/build_stable.yml @@ -36,6 +36,8 @@ jobs: repo: erpnext version: "13" push: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} + python_version: 3.9.17 + node_version: 14.21.3 secrets: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} @@ -46,6 +48,8 @@ jobs: repo: erpnext version: "14" push: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} + python_version: 3.10.12 + node_version: 16.20.1 secrets: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index 138de9f..2bdb363 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -14,6 +14,14 @@ on: push: required: true type: boolean + python_version: + required: true + type: string + description: Python Version + node_version: + required: true + type: string + description: NodeJS Version secrets: DOCKERHUB_USERNAME: required: true @@ -42,6 +50,11 @@ jobs: - name: Get latest versions run: python3 ./.github/scripts/get_latest_tags.py --repo ${{ inputs.repo }} --version ${{ inputs.version }} + - name: Set build args + run: | + echo "PYTHON_VERSION=${{ inputs.python_version }}" >> "$GITHUB_ENV" + echo "NODE_VERSION=${{ inputs.node_version }}" >> "$GITHUB_ENV" + - name: Build uses: docker/bake-action@v3.1.0 with: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cb315ca..3cc671e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,3 +68,14 @@ Place relevant markdown files in the `docs` directory and index them in README.m # Frappe and ERPNext updates Each Frappe/ERPNext release triggers new stable images builds as well as bump to helm chart. + +# Maintenance + +In case of new release of Debian. e.g. bullseye to bookworm. Change following files: + +- `images/erpnext/Containerfile` and `images/custom/Containerfile`: Change the files to use new debian release, make sure new python version tag that is available on new debian release image. e.g. 3.9.9 (bullseye) to 3.9.17 (bookworm) or 3.10.5 (bullseye) to 3.10.12 (bookworm). Make sure apt-get packages and wkhtmltopdf version are also upgraded accordingly. +- `images/bench/Dockerfile`: Change the files to use new debian release. Make sure apt-get packages and wkhtmltopdf version are also upgraded accordingly. + +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`. diff --git a/docker-bake.hcl b/docker-bake.hcl index 9d54213..568e066 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -5,6 +5,13 @@ variable "REGISTRY_USER" { default = "frappe" } +variable PYTHON_VERSION { + default = "3.11.4" +} +variable NODE_VERSION { + default = "18.16.1" +} + variable "FRAPPE_VERSION" { default = "develop" } @@ -65,8 +72,8 @@ target "default-args" { BENCH_REPO = "${BENCH_REPO}" FRAPPE_BRANCH = "${FRAPPE_VERSION}" ERPNEXT_BRANCH = "${ERPNEXT_VERSION}" - PYTHON_VERSION = can(regex("v13", "${ERPNEXT_VERSION}")) ? "3.9.9" : "3.10.5" - NODE_VERSION = can(regex("v13", "${FRAPPE_VERSION}")) ? "14.19.3" : "16.18.0" + PYTHON_VERSION = "${PYTHON_VERSION}" + NODE_VERSION = "${NODE_VERSION}" } } diff --git a/images/bench/Dockerfile b/images/bench/Dockerfile index 40cbbaa..92470bc 100644 --- a/images/bench/Dockerfile +++ b/images/bench/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bullseye-slim as bench +FROM debian:bookworm-slim as bench LABEL author=frappé @@ -75,10 +75,11 @@ RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ && dpkg-reconfigure --frontend=noninteractive locales # Detect arch and install wkhtmltopdf -ENV WKHTMLTOPDF_VERSION 0.12.6-1 +ARG WKHTMLTOPDF_VERSION=0.12.6.1-3 +ARG WKHTMLTOPDF_DISTRO=bookworm RUN if [ "$(uname -m)" = "aarch64" ]; then export ARCH=arm64; fi \ && if [ "$(uname -m)" = "x86_64" ]; then export ARCH=amd64; fi \ - && downloaded_file=wkhtmltox_$WKHTMLTOPDF_VERSION.buster_${ARCH}.deb \ + && downloaded_file=wkhtmltox_${WKHTMLTOPDF_VERSION}.${WKHTMLTOPDF_DISTRO}_${ARCH}.deb \ && wget -q https://github.com/wkhtmltopdf/packaging/releases/download/$WKHTMLTOPDF_VERSION/$downloaded_file \ && dpkg -i $downloaded_file \ && rm $downloaded_file diff --git a/images/custom/Containerfile b/images/custom/Containerfile index 3a16f95..e920083 100644 --- a/images/custom/Containerfile +++ b/images/custom/Containerfile @@ -1,11 +1,13 @@ -ARG PYTHON_VERSION=3.10.5 -FROM python:${PYTHON_VERSION}-slim-bullseye AS base +ARG PYTHON_VERSION=3.11.4 +ARG DEBIAN_BASE=bookworm +FROM python:${PYTHON_VERSION}-slim-${DEBIAN_BASE} AS base COPY resources/nginx-template.conf /templates/nginx/frappe.conf.template COPY resources/nginx-entrypoint.sh /usr/local/bin/nginx-entrypoint.sh -ARG WKHTMLTOPDF_VERSION=0.12.6-1 -ARG NODE_VERSION=16.18.0 +ARG WKHTMLTOPDF_VERSION=0.12.6.1-3 +ARG WKHTMLTOPDF_DISTRO=bookworm +ARG NODE_VERSION=18.16.1 ENV NVM_DIR=/home/frappe/.nvm ENV PATH ${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH} @@ -47,7 +49,7 @@ RUN useradd -ms /bin/bash frappe \ # Install wkhtmltopdf with patched qt && if [ "$(uname -m)" = "aarch64" ]; then export ARCH=arm64; fi \ && if [ "$(uname -m)" = "x86_64" ]; then export ARCH=amd64; fi \ - && downloaded_file=wkhtmltox_$WKHTMLTOPDF_VERSION.buster_${ARCH}.deb \ + && downloaded_file=wkhtmltox_${WKHTMLTOPDF_VERSION}.${WKHTMLTOPDF_DISTRO}_${ARCH}.deb \ && curl -sLO https://github.com/wkhtmltopdf/packaging/releases/download/$WKHTMLTOPDF_VERSION/$downloaded_file \ && apt-get install -y ./$downloaded_file \ && rm $downloaded_file \ diff --git a/images/production/Containerfile b/images/production/Containerfile index 5f761c8..2add02a 100644 --- a/images/production/Containerfile +++ b/images/production/Containerfile @@ -1,8 +1,10 @@ -ARG PYTHON_VERSION=3.10.5 -FROM python:${PYTHON_VERSION}-slim-bullseye AS base +ARG PYTHON_VERSION=3.11.4 +ARG DEBIAN_BASE=bookworm +FROM python:${PYTHON_VERSION}-slim-${DEBIAN_BASE} AS base -ARG WKHTMLTOPDF_VERSION=0.12.6-1 -ARG NODE_VERSION=16.18.0 +ARG WKHTMLTOPDF_VERSION=0.12.6.1-3 +ARG WKHTMLTOPDF_DISTRO=bookworm +ARG NODE_VERSION=18.16.1 ENV NVM_DIR=/home/frappe/.nvm ENV PATH ${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH} @@ -44,7 +46,7 @@ RUN useradd -ms /bin/bash frappe \ # Install wkhtmltopdf with patched qt && if [ "$(uname -m)" = "aarch64" ]; then export ARCH=arm64; fi \ && if [ "$(uname -m)" = "x86_64" ]; then export ARCH=amd64; fi \ - && downloaded_file=wkhtmltox_$WKHTMLTOPDF_VERSION.buster_${ARCH}.deb \ + && downloaded_file=wkhtmltox_${WKHTMLTOPDF_VERSION}.${WKHTMLTOPDF_DISTRO}_${ARCH}.deb \ && curl -sLO https://github.com/wkhtmltopdf/packaging/releases/download/$WKHTMLTOPDF_VERSION/$downloaded_file \ && apt-get install -y ./$downloaded_file \ && rm $downloaded_file \