apisix-docker icon indicating copy to clipboard operation
apisix-docker copied to clipboard

Use named context for check_standalong_config.sh

Open qswinson opened this issue 8 months ago • 0 comments

This commit added a step to the build process to copy the utils/check_standalone_config.sh file into the targeted Docker project before being able to build the image. This is a well-meaning approach to reduce code duplication and ease maintenance. However, the problem with this approach is that it breaks the ability to use this repo as a remote Docker context as the Dockerfiles now include a COPY command for a file that does not exist in GitHub. The better way to handle this is to use named context to source the file from ./utils. This PR updates the Dockerfile definitions and the Makefile build steps. With this change, anyone can now build images from my branch like this:

docker build -t apisix --build-context utils=https://github.com/qswinson/apisix-docker.git#docker-named-context:utils https://github.com/qswinson/apisix-docker.git#docker-named-context:debian

You can also define a Docker Bake file in your own repo to customize the final APISIX image. Name the file with the contents belowdocker-bake.hcl and build it with this command: docker buildx bake apisix.

target base {
  context = "https://github.com/qswinson/apisix-docker.git#docker-named-context:debian"
  contexts = {
    "utils" = "https://github.com/qswinson/apisix-docker.git#docker-named-context:utils"
  }
  platforms = [
    "linux/amd64"
  ]
}

target apisix {
  contexts = {
    baseapisix = "target:base"
  }
  dockerfile = "Dockerfile"
  tags = ["apisix:latest"]
  platforms = [
    "linux/x86_64"
  ]
}

Being able to build images on demand is very important for addressing security vulnerabilities that are resolved in the base debian/redhat image.

qswinson avatar Jun 04 '25 17:06 qswinson