apisix 官方并没有提供deb文件,需要自己去编译,简单记录下编译过程
总结:
- Makefile 里面不清楚居于什么原因 有docker system prune -a -f ,不修改的话你所有的image可能都会消失,建议移除
- make 本质是通过3个docker build 实现deb文件输出
- 如果修改了或者clone了apisix ,需要修改对应的repo配置或者先下载好放到本地,使用local_code_path参数指定
- luarocks很容易失败,可以手动去多次下载,成功后保存起来后加装到dockerfile中
- 以上种种问题,在海外买个虚拟机可能都更容易解决
- deb文件在output目录下
repo指定
apisix_repo=“https://github.com/apache/apisix”
dashboard_repo=“https://github.com/apache/apisix-dashboard”
build apisix:
关注Makefile里的如下内容:
.PHONY: build-apisix-rpm
build-apisix-rpm:
ifeq ($(local_code_path), 0)
git clone -b $(checkout) $(apisix_repo) ./apisix
$(call build,apisix,apisix,rpm,"./apisix")
rm -fr ./apisix
else
$(call build,apisix,apisix,rpm,$(local_code_path))
endif
luarocks
luarocks执行代码在install-common.sh中,具体如下:
luarocks make ./rockspec/apisix-master-${iteration}.rockspec --tree=/tmp/build/output/apisix/usr/local/apisix/deps --local
${iteration}值为零,可以添加–server https://luarocks.cn加速下载,但还会牵涉到github的很多访问,会有各种https错误,包括超时等等。
/usr/local/apisix文件不存在
将对应版本的源代码,加载到/usr/local/apisix就可以。
执行命令
make package type=deb app=apisix version=2.2 checkout=2.2 local_code_path=./apisix
Dockerfile.apisix.deb
修改后的Dockerfile.apisix.deb内容如下
ARG IMAGE_BASE="ubuntu"
ARG IMAGE_TAG="20.04"
FROM ${IMAGE_BASE}:${IMAGE_TAG}
COPY ./utils/install-common.sh /install-common.sh
COPY ./utils/determine-dist.sh /determine-dist.sh
COPY ./utils/sources.list /etc/apt/sources.list
ARG iteration="0"
ARG apisix_repo="https://github.com/apache/apisix"
ARG checkout_v
ARG IMAGE_BASE
ARG IMAGE_TAG
ARG CODE_PATH
# install dependencies
#RUN /install-common.sh install_apisix_dependencies_deb
RUN /install-common.sh install_dependencies_deb
RUN /install-common.sh install_openresty_deb
RUN apt-get install -y unzip git sudo
#RUN /install-common.sh install_luarocks
COPY ./utils/linux-install-luarocks.sh ./linux-install-luarocks.sh
ENV LUAROCKS_SERVER=https://luarocks.cn
ADD ./luarocks-apisix-master-0.rockspec.tar.gz /tmp/build/
RUN ./linux-install-luarocks.sh
ENV checkout_v=${checkout_v}
ENV iteration=${iteration}
ENV apisix_repo=${apisix_repo}
ENV IMAGE_BASE=${IMAGE_BASE}
ENV IMAGE_TAG=${IMAGE_TAG}
COPY ${CODE_PATH} /apisix
# install apisix
COPY ./apache-apisix-2.13.1-src /usr/local/apisix
RUN /install-common.sh install_apisix # determine dist and write it into /tmp/dist file
RUN /determine-dist.sh
DockerImage
成功后应该有如下image(不删除前提下)
REPOSITORY TAG IMAGE ID CREATED SIZE
apache/apisix-packaged-deb 2.2 67f134ea3d40 2 hours ago 521MB
apache/apisix-deb 2.2 d137b88cf37a 2 hours ago 960MB
api7/fpm latest 86f633075834 3 hours ago 513MB
ubuntu 20.04 53df61775e88 8 hours ago 72.8MB
ubuntu focal 53df61775e88 8 hours ago 72.8MB