-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(docker): support valid YAML variations in standalone mode #12949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Baoyuantop
merged 10 commits into
apache:master
from
janiussyafiq:fix/standalone-config-check-12427
Feb 4, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8304bf4
fix(docker): relax regex to support valid YAML variations in standalo…
janiussyafiq 3c29c3d
chore: fix lint error
janiussyafiq 5962711
chore: chmod test files
janiussyafiq cf406be
fix(docker): relocate logic to ops.lua and added corresponding test c…
janiussyafiq ce7c26c
chore: chmod test files
janiussyafiq 71c246c
fix(docker): validate config.yaml in semantic way
janiussyafiq d9e623f
fix(ci): build Docker image before running test
janiussyafiq a7b0cd7
ci: isolate Docker test to dedicated workflow
janiussyafiq 5c77197
ci: fix syntax
janiussyafiq 86c5bc8
ci: fix error on ci
janiussyafiq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| name: Docker Standalone Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: [master, 'release/**'] | ||
| paths: | ||
| - 'apisix/cli/ops.lua' | ||
| - 'docker/debian-dev/**' | ||
| - 't/cli/test_standalone_docker.sh' | ||
| - 'Makefile' | ||
| - '.github/workflows/docker-standalone.yml' | ||
| pull_request: | ||
| branches: [master, 'release/**'] | ||
| paths: | ||
| - 'apisix/cli/ops.lua' | ||
| - 'docker/debian-dev/**' | ||
| - 't/cli/test_standalone_docker.sh' | ||
| - 'Makefile' | ||
| - '.github/workflows/docker-standalone.yml' | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.run_number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| docker-test: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
|
|
||
| steps: | ||
| - name: Check out code | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Build APISIX Dashboard | ||
| run: | | ||
| # install node.js and pnpm | ||
| sudo n lts | ||
| corepack enable pnpm | ||
|
|
||
| # prepare apisix-dashboard source code | ||
| source .requirements | ||
| git clone --revision=${APISIX_DASHBOARD_COMMIT} --depth 1 https://github.com/apache/apisix-dashboard.git | ||
| pushd apisix-dashboard | ||
|
|
||
| # compile | ||
| pnpm install --frozen-lockfile | ||
| pnpm run build | ||
| popd | ||
|
|
||
| # copy the dist files to the ui directory | ||
| mkdir ui | ||
| cp -r apisix-dashboard/dist/* ui/ | ||
| rm -r apisix-dashboard | ||
|
|
||
| # build Docker image | ||
| make build-on-debian-dev | ||
|
|
||
| - name: Run Docker standalone test | ||
| run: | | ||
| ./t/cli/test_standalone_docker.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,214 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| . ./t/cli/common.sh | ||
|
|
||
| standalone() { | ||
| clean_up | ||
| docker rm -f apisix-test-standalone 2>/dev/null || true | ||
| git checkout conf/apisix.yaml | ||
| } | ||
|
|
||
| DOCKER_IMAGE="${DOCKER_IMAGE:-apache/apisix:master-debian-dev}" | ||
| trap standalone EXIT | ||
|
|
||
| echo 'routes: [] | ||
| #END' > conf/apisix.yaml | ||
|
|
||
| run_docker_test() { | ||
| local standalone_flag=$1 | ||
| local config_mode=${2:-ro} | ||
|
|
||
| if [ "$standalone_flag" = "true" ]; then | ||
| docker run -d --name apisix-test-standalone \ | ||
| -e APISIX_STAND_ALONE=true \ | ||
| -v $(pwd)/conf/config.yaml:/usr/local/apisix/conf/config.yaml:${config_mode} \ | ||
| -v $(pwd)/conf/apisix.yaml:/usr/local/apisix/conf/apisix.yaml:ro \ | ||
| ${DOCKER_IMAGE} > /dev/null 2>&1 | ||
| else | ||
| docker run -d --name apisix-test-standalone \ | ||
| -v $(pwd)/conf/config.yaml:/usr/local/apisix/conf/config.yaml:${config_mode} \ | ||
| -v $(pwd)/conf/apisix.yaml:/usr/local/apisix/conf/apisix.yaml:ro \ | ||
| ${DOCKER_IMAGE} > /dev/null 2>&1 | ||
| fi | ||
|
|
||
| sleep 5 | ||
|
|
||
| if ! docker ps | grep -q apisix-test-standalone; then | ||
| echo "Container failed to start. Logs:" | ||
| docker logs apisix-test-standalone | ||
| docker rm -f apisix-test-standalone > /dev/null 2>&1 | ||
| return 1 | ||
| fi | ||
|
|
||
| docker rm -f apisix-test-standalone > /dev/null 2>&1 | ||
| return 0 | ||
| } | ||
|
|
||
| # normal YAML format | ||
| echo ' | ||
| deployment: | ||
| role: data_plane | ||
| role_data_plane: | ||
| config_provider: yaml | ||
| apisix: | ||
| node_listen: 9080 | ||
| ' > conf/config.yaml | ||
|
|
||
| if ! run_docker_test "true"; then | ||
| echo "failed: normal YAML format 'role: data_plane' was rejected" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "passed: normal YAML format accepted" | ||
|
|
||
| # double-quoted format | ||
| echo ' | ||
| deployment: | ||
| role: "data_plane" | ||
| role_data_plane: | ||
| config_provider: yaml | ||
| apisix: | ||
| node_listen: 9080 | ||
| ' > conf/config.yaml | ||
|
|
||
| if ! run_docker_test "true"; then | ||
| echo "failed: double-quoted 'role: \"data_plane\"' was rejected" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "passed: double-quoted format accepted" | ||
|
|
||
| # single-quoted format | ||
| echo " | ||
| deployment: | ||
| role: 'data_plane' | ||
| role_data_plane: | ||
| config_provider: yaml | ||
| apisix: | ||
| node_listen: 9080 | ||
| " > conf/config.yaml | ||
|
|
||
| if ! run_docker_test "true"; then | ||
| echo "failed: single quoted \"role: 'data_plane'\" was rejected" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "passed: single-quoted format accepted" | ||
|
|
||
| # flow syntax | ||
| echo ' | ||
| deployment: {"role": "data_plane", "role_data_plane": {"config_provider": "yaml"}} | ||
shreemaan-abhishek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| apisix: | ||
| node_listen: 9080 | ||
| ' > conf/config.yaml | ||
|
|
||
| if ! run_docker_test "true"; then | ||
| echo "failed: flow syntax 'role: {\"data_plane\"}' was rejected" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "passed: flow syntax format accepted" | ||
|
|
||
| # mixed quotes | ||
| echo " | ||
| deployment: | ||
| role: \"data_plane\" | ||
| role_data_plane: | ||
| config_provider: 'yaml' | ||
| apisix: | ||
| node_listen: 9080 | ||
| " > conf/config.yaml | ||
|
|
||
| if ! run_docker_test "true"; then | ||
| echo "failed: mixed quotes format was rejected" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "passed: mixed quotes format accepted" | ||
|
|
||
| # etcd config_provider should fail in standalone mode | ||
| echo ' | ||
| deployment: | ||
| role: data_plane | ||
| role_data_plane: | ||
| config_provider: etcd | ||
| etcd: | ||
| host: | ||
| - "http://127.0.0.1:2379" | ||
| apisix: | ||
| node_listen: 9080 | ||
| ' > conf/config.yaml | ||
|
|
||
| if run_docker_test "true"; then | ||
| echo "failed: 'config_provider: etcd' should be rejected in standalone mode" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "passed: 'config_provider: etcd' was correctly rejected in standalone mode" | ||
|
|
||
| # traditional role with yaml config_provider should work | ||
| echo ' | ||
| deployment: | ||
| role: traditional | ||
| role_traditional: | ||
| config_provider: yaml | ||
| admin: | ||
| admin_key_required: false | ||
| apisix: | ||
| node_listen: 9080 | ||
| enable_admin: true | ||
| ' > conf/config.yaml | ||
|
|
||
| if ! run_docker_test "true" "rw"; then | ||
| echo "failed: traditional role with 'config_provider: yaml' was rejected" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "passed: traditional role with 'config_provider: yaml' accepted" | ||
|
|
||
| # check is APISIX_PROFILE is respected in standalone mode | ||
| echo ' | ||
| deployment: | ||
| role: data_plane | ||
| role_data_plane: | ||
| config_provider: yaml | ||
| apisix: | ||
| node_listen: 9080 | ||
| ' > conf/config-prod.yaml | ||
|
|
||
| docker run -d --name apisix-test-standalone \ | ||
| -e APISIX_STAND_ALONE=true \ | ||
| -e APISIX_PROFILE=prod \ | ||
| -v $(pwd)/conf/config-prod.yaml:/usr/local/apisix/conf/config-prod.yaml:ro \ | ||
| -v $(pwd)/conf/apisix.yaml:/usr/local/apisix/conf/apisix.yaml:ro \ | ||
| ${DOCKER_IMAGE} > /dev/null 2>&1 | ||
|
|
||
| sleep 5 | ||
|
|
||
| if ! docker ps | grep -q apisix-test-standalone; then | ||
| echo "failed: APISIX_PROFILE=prod in standalone mode was rejected" | ||
| docker logs apisix-test-standalone | ||
| docker rm -f apisix-test-standalone > /dev/null 2>&1 | ||
| exit 1 | ||
| fi | ||
|
|
||
| docker rm -f apisix-test-standalone > /dev/null 2>&1 | ||
|
|
||
| echo "passed: APISIX_PROFILE=prod in standalone mode accepted" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have changed the mode of this file, why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might've changed it when i did local testing, will revert it back