Skip to content
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

fix: apisix-debian-dev image failed to run #537

Merged
merged 2 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/apisix_dev_docker_local_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ on:
- 'release/apisix-2.15.**'

env:
APISIX_IMAGE_TAG: "local"
APISIX_IMAGE_TAG: "local-debian-dev"
APISIX_VERSION: "local"

jobs:

Expand All @@ -35,9 +36,10 @@ jobs:
git clone https://github.com/apache/apisix.git

- name: Build image
env:
LOCAL_CODE_PATH: ./apisix
run: |
tag="apache/apisix:$APISIX_IMAGE_TAG"
docker build -t $tag -f debian-dev/Dockerfile.local .
make build-on-debian-local-dev

- name: use docker-compose
run: docker-compose -p docker-apisix -f example/docker-compose.yml up -d
Expand Down
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ APISIX_VERSION ?= 3.7.0
MAX_APISIX_VERSION ?= 3.7.0
IMAGE_NAME = apache/apisix
IMAGE_TAR_NAME = apache_apisix
APISIX_REPO = https://github.com/apache/apisix
APISIX_REPO_BRANCH = master
LOCAL_CODE_PATH = 0

APISIX_DASHBOARD_VERSION ?= $(shell echo ${APISIX_DASHBOARD_VERSION:=3.0.1})
APISIX_DASHBOARD_IMAGE_NAME = apache/apisix-dashboard
Expand Down Expand Up @@ -60,6 +63,12 @@ define func_echo_success_status
printf "[$(_color_green) info $(_color_wipe)] %s\n" $(1)
endef

define build_image_dev
$(ENV_DOCKER) build -t $(ENV_APISIX_IMAGE_TAG_NAME)-debian-dev \
--build-arg CODE_PATH=$(1) \
--build-arg ENTRYPOINT_PATH=debian-dev/docker-entrypoint.sh \
-f ./debian-dev/Dockerfile.local .
endef

### build-on-redhat : Build apache/apisix:xx-redhat image
.PHONY: build-on-redhat
Expand All @@ -75,6 +84,19 @@ build-on-debian-dev:
$(ENV_DOCKER) build -t $(ENV_APISIX_IMAGE_TAG_NAME)-debian-dev -f ./debian-dev/Dockerfile debian-dev
@$(call func_echo_success_status, "$@ -> [ Done ]")

### build-on-debian-local-dev : Build apache/apisix:xx-debian-dev image
.PHONY: build-on-debian-local-dev
build-on-debian-local-dev:
@$(call func_echo_status, "$@ -> [ Start ]")
ifeq ($(LOCAL_CODE_PATH), 0)
ifeq ($(shell test -d ./apisix && echo -n yes), )
git clone -b $(APISIX_REPO_BRANCH) $(APISIX_REPO) ./apisix
endif
$(call build_image_dev,"./apisix")
else
$(call build_image_dev,$(LOCAL_CODE_PATH))
endif
@$(call func_echo_success_status, "$@ -> [ Done ]")

### build-on-debian : Build apache/apisix:xx-debian image
.PHONY: build-on-debian
Expand Down
75 changes: 26 additions & 49 deletions debian-dev/Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -17,71 +17,48 @@

# Use this dockerfile to create a docker image of your apisix local/patched codebase

FROM api7/apisix-runtime:dev AS build
FROM debian:bullseye-slim AS build

ARG ENABLE_PROXY=false
ARG CODE_PATH

ENV DEBIAN_FRONTEND noninteractive
ENV ENV_INST_LUADIR /usr/local/apisix

# replace the source path with the location of apisix related directories in your host machine
# refer: https://web.archive.org/web/20230604150902/https://www.jamestharpe.com/docker-include-files-outside-build-context/
COPY ${CODE_PATH} /apisix

COPY apisix/apisix /usr/local/apisix/apisix
COPY apisix/conf /usr/local/apisix/conf
COPY apisix/bin/apisix /usr/bin/apisix
COPY apisix/apisix-master-0.rockspec /usr/local/apisix/apisix-master-0.rockspec
COPY apisix/utils/linux-install-luarocks.sh /usr/local/apisix/linux-install-luarocks.sh
COPY debian-dev/docker-entrypoint.sh /docker-entrypoint.sh
WORKDIR /apisix

RUN set -x \
&& apt-get -y update --fix-missing \
&& apt-get install -y \
make \
git \
sudo \
&& ls -al \
&& make deps \
&& mkdir -p ${ENV_INST_LUADIR} \
&& cp -r deps ${ENV_INST_LUADIR} \
&& make install

WORKDIR /usr/local/apisix
FROM debian:bullseye-slim

SHELL ["/bin/bash", "-c"]
ARG ENTRYPOINT_PATH=./docker-entrypoint.sh

RUN set -x \
&& DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y libreadline-dev lsb-release libpcre3 libpcre3-dev libldap2-dev libssl-dev perl build-essential \
&& DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends wget gnupg ca-certificates
COPY --from=build /usr/local/apisix /usr/local/apisix
COPY --from=build /usr/local/openresty /usr/local/openresty
COPY --from=build /usr/bin/apisix /usr/bin/apisix

RUN set -x \
&& wget -O - https://openresty.org/package/pubkey.gpg | apt-key add - \
&& wget -O - http://repos.apiseven.com/pubkey.gpg | apt-key add - \
&& echo "deb http://openresty.org/package/debian bullseye openresty" | tee /etc/apt/sources.list.d/openresty.list \
&& echo "deb http://repos.apiseven.com/packages/debian bullseye main" | tee /etc/apt/sources.list.d/apisix.list \
&& DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y apisix-runtime
ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin

RUN set -x \
&& (test "${ENABLE_PROXY}" != "true" || /bin/sed -i 's,http://deb.debian.org,http://mirrors.aliyun.com,g' /etc/apt/sources.list) \
&& apt-get -y update --fix-missing \
&& apt-get install -y curl \
gawk \
git \
libldap2-dev \
liblua5.1-0-dev \
lua5.1 \
sudo \
unzip \
wget \
make \
libssl-dev \
&& curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
&& source "$HOME/.cargo/env" \
# rust version 1.69.0 required to compile lua-resty-ldap
&& rustup install 1.69.0 \
&& rustup default 1.69.0 \
&& bash ./linux-install-luarocks.sh \
&& luarocks config variables.OPENSSL_INCDIR /usr/include/ \
&& luarocks config variables.PCRE_DIR /usr/local/openresty/pcre \
&& luarocks install apisix-master-0.rockspec --tree=/usr/local/apisix/deps --deps-only \
&& mkdir /usr/local/apisix/logs && touch /usr/local/apisix/logs/error.log && touch /usr/local/apisix/logs/access.log
WORKDIR /usr/local/apisix

ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
RUN ln -sf /dev/stdout /usr/local/apisix/logs/access.log \
&& ln -sf /dev/stderr /usr/local/apisix/logs/error.log

EXPOSE 9080 9443


RUN ["chmod", "+x", "/docker-entrypoint.sh"]
COPY ${ENTRYPOINT_PATH} /docker-entrypoint.sh

ENTRYPOINT ["/docker-entrypoint.sh"]

Expand Down
4 changes: 4 additions & 0 deletions debian-dev/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ _EOC_
rm -f "/usr/local/apisix/conf/config_listen.sock"
fi

if [ -e "/usr/local/apisix/logs/worker_events.sock" ]; then
rm -f "/usr/local/apisix/logs/worker_events.sock"
fi

exec /usr/local/openresty/bin/openresty -p /usr/local/apisix -g 'daemon off;'
fi

Expand Down
Loading