2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-11-09 23:00:56 +00:00

Build ERPNext images on top fresh Frappe images (#582)

Update build_stable.yml
This commit is contained in:
Lev 2021-11-24 02:40:27 +03:00 committed by GitHub
parent d049e33b40
commit 5aae67117c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 154 additions and 103 deletions

View File

@ -55,15 +55,22 @@ jobs:
targets: bench-build targets: bench-build
push: true push: true
build_frappe: build_main:
name: Frappe name: Frappe & ERPNext
runs-on: ubuntu-latest runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup Buildx - name: Setup Buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
- name: Login - name: Login
uses: docker/login-action@v1 uses: docker/login-action@v1
@ -72,56 +79,37 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build - name: Build Frappe
uses: docker/bake-action@v1.6.0 uses: docker/bake-action@v1.6.0
with: with:
files: docker-bake.hcl files: docker-bake.hcl
targets: frappe-develop-test targets: frappe-develop-test
load: true load: true
- name: Test - name: Push Frappe to local registry
run: ./tests/test-frappe.sh
- name: Push
if: env.IS_AUTHORIZED_RUN == 'true'
uses: docker/bake-action@v1.6.0 uses: docker/bake-action@v1.6.0
with: with:
files: docker-bake.hcl files: docker-bake.hcl
targets: frappe-develop targets: frappe-develop-test-local
push: true push: true
build_erpnext: - name: Test Frappe
name: ERPNext run: ./tests/test-frappe.sh
runs-on: ubuntu-latest
needs: build_frappe
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Buildx - name: Build ERPNext
uses: docker/setup-buildx-action@v1
- name: Login
uses: docker/login-action@v1
if: env.IS_AUTHORIZED_RUN == 'true'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build
uses: docker/bake-action@v1.6.0 uses: docker/bake-action@v1.6.0
with: with:
files: docker-bake.hcl files: docker-bake.hcl
targets: erpnext-develop-test targets: erpnext-develop-test
load: true load: true
- name: Test - name: Test ERPNext
run: FRAPPE_VERSION=develop ./tests/test-erpnext.sh run: ./tests/test-erpnext.sh
- name: Push - name: Push
if: env.IS_AUTHORIZED_RUN == 'true' if: env.IS_AUTHORIZED_RUN == 'true'
uses: docker/bake-action@v1.6.0 uses: docker/bake-action@v1.6.0
with: with:
files: docker-bake.hcl files: docker-bake.hcl
targets: erpnext-develop targets: frappe-develop,erpnext-develop
push: true push: true

View File

@ -35,19 +35,25 @@ env:
IS_AUTHORIZED_RUN: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} IS_AUTHORIZED_RUN: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }}
jobs: jobs:
build_frappe: build:
name: Frappe name: Frappe & ERPNext
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
version: [12, 13] version: [12, 13]
services:
registry:
image: registry:2
ports:
- 5000:5000
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup Buildx - name: Setup Buildx
uses: docker/setup-buildx-action@v1 uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
- name: Login - name: Login
uses: docker/login-action@v1 uses: docker/login-action@v1
@ -61,14 +67,36 @@ jobs:
env: env:
VERSION: ${{ matrix.version }} VERSION: ${{ matrix.version }}
- name: Build - name: Build Frappe
uses: docker/bake-action@v1.6.0 uses: docker/bake-action@v1.6.0
with: with:
files: docker-bake.hcl files: docker-bake.hcl
targets: frappe-stable-test targets: frappe-stable-test
load: true load: true
- name: Push - name: Push Frappe to local registry
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: frappe-stable-test-local
push: true
- name: Test Frappe
if: github.event_name == 'pull_request'
run: ./tests/test-frappe.sh
- name: Build ERPNext
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: erpnext-stable-test
load: true
- name: Test ERPNext
if: github.event_name == 'pull_request'
run: ./tests/test-erpnext.sh
- name: Push Frappe
if: env.IS_AUTHORIZED_RUN == 'true' if: env.IS_AUTHORIZED_RUN == 'true'
uses: docker/bake-action@v1.6.0 uses: docker/bake-action@v1.6.0
with: with:
@ -78,41 +106,7 @@ jobs:
env: env:
GIT_TAG: ${{ env.FRAPPE_VERSION }} GIT_TAG: ${{ env.FRAPPE_VERSION }}
build_erpnext: - name: Push ERPNext
name: ERPNext
runs-on: ubuntu-latest
needs: build_frappe
strategy:
matrix:
version: [12, 13]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Buildx
uses: docker/setup-buildx-action@v1
- name: Login
uses: docker/login-action@v1
if: env.IS_AUTHORIZED_RUN == 'true'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get latest versions
run: ./.github/scripts/get-latest-tags.sh
env:
VERSION: ${{ matrix.version }}
- name: Build
uses: docker/bake-action@v1.6.0
with:
files: docker-bake.hcl
targets: erpnext-stable-test
load: true
- name: Push
if: env.IS_AUTHORIZED_RUN == 'true' if: env.IS_AUTHORIZED_RUN == 'true'
uses: docker/bake-action@v1.6.0 uses: docker/bake-action@v1.6.0
with: with:
@ -126,7 +120,7 @@ jobs:
name: Release Helm name: Release Helm
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' if: github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request'
needs: [build_frappe, build_erpnext] needs: build
steps: steps:
- name: Setup deploy key - name: Setup deploy key

View File

@ -1,4 +1,8 @@
# Images # Docker Buildx Bake build definition file
# Reference: https://github.com/docker/buildx/blob/master/docs/reference/buildx_bake.md
# Bench images
target "bench-build" { target "bench-build" {
tags = ["frappe/bench:latest"] tags = ["frappe/bench:latest"]
@ -11,6 +15,9 @@ target "bench-test" {
target = "test" target = "test"
} }
# Main images
# Base for all other targets
target "frappe-nginx" { target "frappe-nginx" {
dockerfile = "build/frappe-nginx/Dockerfile" dockerfile = "build/frappe-nginx/Dockerfile"
} }
@ -41,35 +48,51 @@ target "develop-args" {
} }
} }
variable "GIT_TAG" {}
variable "GIT_BRANCH" {}
variable "VERSION" {}
target "stable-args" {
args = {
GIT_BRANCH = "${GIT_BRANCH}"
IMAGE_TAG = "${GIT_BRANCH}"
PYTHON_VERSION = "${VERSION}" == "12" ? "3.7" : "3.9"
}
}
function "set_develop_tags" { function "set_develop_tags" {
params = [repo] params = [repo]
result = ["${repo}:latest", "${repo}:edge", "${repo}:develop"] result = ["${repo}:latest", "${repo}:edge", "${repo}:develop"]
} }
# NOTE: Variable are used only for stable builds
variable "GIT_TAG" {} # git tag, e.g. v13.15.0
variable "GIT_BRANCH" {} # git branch, e.g. version-13
variable "VERSION" {} # Frappe and ERPNext version, e.g. 13
target "stable-args" {
args = {
GIT_BRANCH = "${GIT_BRANCH}"
IMAGE_TAG = "${GIT_BRANCH}"
# ERPNext build fails on v12
# TODO: Remove PYTHON_VERSION argument when v12 will stop being supported
PYTHON_VERSION = "${VERSION}" == "12" ? "3.7" : "3.9"
}
}
function "set_stable_tags" { function "set_stable_tags" {
# e.g. base_image:v13.15.0, base_image:v13, base_image:version-13
params = [repo] params = [repo]
result = ["${repo}:${GIT_TAG}", "${repo}:v${VERSION}", "${repo}:${GIT_BRANCH}"] result = ["${repo}:${GIT_TAG}", "${repo}:v${VERSION}", "${repo}:${GIT_BRANCH}"]
} }
target "test-erpnext-args" {
args = {
IMAGE_TAG = "test"
DOCKER_REGISTRY_PREFIX = "localhost:5000/frappe"
}
}
function "set_local_test_tags" {
params = [repo]
result = ["localhost:5000/${repo}:test"]
}
function "set_test_tags" { function "set_test_tags" {
params = [repo] params = [repo]
result = ["${repo}:test"] result = ["${repo}:test"]
} }
# Develop # Develop images
target "frappe-nginx-develop" { target "frappe-nginx-develop" {
inherits = ["frappe-nginx", "develop-args"] inherits = ["frappe-nginx", "develop-args"]
@ -104,7 +127,22 @@ group "erpnext-develop" {
targets = ["erpnext-nginx-develop", "erpnext-worker-develop"] targets = ["erpnext-nginx-develop", "erpnext-worker-develop"]
} }
# Develop test # Test develop images
target "frappe-nginx-develop-test-local" {
inherits = ["frappe-nginx-develop"]
tags = set_local_test_tags("frappe/frappe-nginx")
}
target "frappe-worker-develop-test-local" {
inherits = ["frappe-worker-develop"]
tags = set_local_test_tags("frappe/frappe-worker")
}
target "frappe-socketio-develop-test-local" {
inherits = ["frappe-socketio-develop"]
tags = set_local_test_tags("frappe/frappe-socketio")
}
target "frappe-nginx-develop-test" { target "frappe-nginx-develop-test" {
inherits = ["frappe-nginx-develop"] inherits = ["frappe-nginx-develop"]
@ -122,15 +160,19 @@ target "frappe-socketio-develop-test" {
} }
target "erpnext-nginx-develop-test" { target "erpnext-nginx-develop-test" {
inherits = ["erpnext-nginx-develop"] inherits = ["erpnext-nginx-develop", "test-erpnext-args"]
tags = set_test_tags("frappe/erpnext-nginx") tags = set_test_tags("frappe/erpnext-nginx")
} }
target "erpnext-worker-develop-test" { target "erpnext-worker-develop-test" {
inherits = ["erpnext-worker-develop"] inherits = ["erpnext-worker-develop", "test-erpnext-args"]
tags = set_test_tags("frappe/erpnext-worker") tags = set_test_tags("frappe/erpnext-worker")
} }
group "frappe-develop-test-local" {
targets = ["frappe-nginx-develop-test-local", "frappe-worker-develop-test-local", "frappe-socketio-develop-test-local"]
}
group "frappe-develop-test" { group "frappe-develop-test" {
targets = ["frappe-nginx-develop-test", "frappe-worker-develop-test", "frappe-socketio-develop-test"] targets = ["frappe-nginx-develop-test", "frappe-worker-develop-test", "frappe-socketio-develop-test"]
} }
@ -140,7 +182,7 @@ group "erpnext-develop-test" {
} }
# Stable # Stable images
target "frappe-nginx-stable" { target "frappe-nginx-stable" {
inherits = ["frappe-nginx", "stable-args"] inherits = ["frappe-nginx", "stable-args"]
@ -175,7 +217,23 @@ group "erpnext-stable" {
targets = ["erpnext-nginx-stable", "erpnext-worker-stable"] targets = ["erpnext-nginx-stable", "erpnext-worker-stable"]
} }
# Stable test # Test stable images
target "frappe-nginx-stable-test-local" {
inherits = ["frappe-nginx-stable"]
tags = set_local_test_tags("frappe/frappe-nginx")
}
target "frappe-worker-stable-test-local" {
inherits = ["frappe-worker-stable"]
tags = set_local_test_tags("frappe/frappe-worker")
}
target "frappe-socketio-stable-test-local" {
inherits = ["frappe-socketio-stable"]
tags = set_local_test_tags("frappe/frappe-socketio")
}
target "frappe-nginx-stable-test" { target "frappe-nginx-stable-test" {
inherits = ["frappe-nginx-stable"] inherits = ["frappe-nginx-stable"]
tags = set_test_tags("frappe/frappe-nginx") tags = set_test_tags("frappe/frappe-nginx")
@ -192,15 +250,19 @@ target "frappe-socketio-stable-test" {
} }
target "erpnext-nginx-stable-test" { target "erpnext-nginx-stable-test" {
inherits = ["erpnext-nginx-stable"] inherits = ["erpnext-nginx-stable", "test-erpnext-args"]
tags = set_test_tags("frappe/erpnext-nginx") tags = set_test_tags("frappe/erpnext-nginx")
} }
target "erpnext-worker-stable-test" { target "erpnext-worker-stable-test" {
inherits = ["erpnext-worker-stable"] inherits = ["erpnext-worker-stable", "test-erpnext-args"]
tags = set_test_tags("frappe/erpnext-worker") tags = set_test_tags("frappe/erpnext-worker")
} }
group "frappe-stable-test-local" {
targets = ["frappe-nginx-stable-test-local", "frappe-worker-stable-test-local", "frappe-socketio-stable-test-local"]
}
group "frappe-stable-test" { group "frappe-stable-test" {
targets = ["frappe-nginx-stable-test", "frappe-worker-stable-test", "frappe-socketio-stable-test"] targets = ["frappe-nginx-stable-test", "frappe-worker-stable-test", "frappe-socketio-stable-test"]
} }

View File

@ -9,14 +9,12 @@ SITE_NAME="test_erpnext.localhost"
echo ::group::Setup env echo ::group::Setup env
cp env-example .env cp env-example .env
sed -i -e "s/FRAPPE_VERSION=edge/FRAPPE_VERSION=$FRAPPE_VERSION/g" .env sed -i -e "s/edge/test/g" .env
sed -i -e "s/ERPNEXT_VERSION=edge/ERPNEXT_VERSION=test/g" .env
# shellcheck disable=SC2046 # shellcheck disable=SC2046
export $(cat .env) export $(cat .env)
cat .env cat .env
print_group Start services print_group Start services
FRAPPE_VERSION=$FRAPPE_VERSION ERPNEXT_VERSION="test" \
docker-compose \ docker-compose \
-p $project_name \ -p $project_name \
-f installation/docker-compose-common.yml \ -f installation/docker-compose-common.yml \
@ -24,6 +22,7 @@ FRAPPE_VERSION=$FRAPPE_VERSION ERPNEXT_VERSION="test" \
-f installation/erpnext-publish.yml \ -f installation/erpnext-publish.yml \
up -d up -d
print_group Fix permissions
docker run \ docker run \
--rm \ --rm \
--user root \ --user root \

View File

@ -7,6 +7,16 @@ source tests/functions.sh
project_name="test_frappe" project_name="test_frappe"
SITE_NAME="test_frappe.localhost" SITE_NAME="test_frappe.localhost"
docker_compose_with_args() {
# shellcheck disable=SC2068
docker-compose \
-p $project_name \
-f installation/docker-compose-common.yml \
-f installation/docker-compose-frappe.yml \
-f installation/frappe-publish.yml \
$@
}
echo ::group::Setup env echo ::group::Setup env
cp env-example .env cp env-example .env
sed -i -e "s/edge/test/g" .env sed -i -e "s/edge/test/g" .env
@ -15,13 +25,7 @@ export $(cat .env)
cat .env cat .env
print_group Start services print_group Start services
FRAPPE_VERSION="test" \ docker_compose_with_args up -d
docker-compose \
-p $project_name \
-f installation/docker-compose-common.yml \
-f installation/docker-compose-frappe.yml \
-f installation/frappe-publish.yml \
up -d
print_group Create site print_group Create site
docker run \ docker run \
@ -32,4 +36,8 @@ docker run \
frappe/frappe-worker:test new frappe/frappe-worker:test new
ping_site ping_site
print_group Stop and remove containers
docker_compose_with_args down
rm .env rm .env