This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-docker.git
The following commit(s) were added to refs/heads/master by this push:
new 4324c5e feat: Support ENABLE_PROXY argument at building phrase for
mirror switch (#117)
4324c5e is described below
commit 4324c5e79f41313f0deeb94e7fe3f1905728ef87
Author: Joey <[email protected]>
AuthorDate: Wed Jan 13 21:21:50 2021 +0800
feat: Support ENABLE_PROXY argument at building phrase for mirror switch
(#117)
* Add USE_PROXY build args for dockerfiles
Signed-off-by: imjoey <[email protected]>
* Formalize Dockerfile of Dashboard
Signed-off-by: imjoey <[email protected]>
* Add releted docs
Signed-off-by: imjoey <[email protected]>
* Improve the guide docs
Signed-off-by: imjoey <[email protected]>
* Update README.md as reviewer suggested
Co-authored-by: 琚致远 <[email protected]>
* Fix typo
Signed-off-by: imjoey <[email protected]>
Co-authored-by: 琚致远 <[email protected]>
---
README.md | 6 +++++
all-in-one/apisix-dashboard/Dockerfile | 45 ++++++++++++++++------------------
all-in-one/apisix/Dockerfile | 9 ++++---
alpine-dev/Dockerfile | 8 ++++--
alpine/Dockerfile | 8 ++++--
5 files changed, 45 insertions(+), 31 deletions(-)
diff --git a/README.md b/README.md
index d702ab6..2740113 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,12 @@ export APISIX_VERSION=master
docker build -t apisix:${APISIX_VERSION}-alpine --build-arg
APISIX_VERSION=${APISIX_VERSION} -f alpine/Dockerfile alpine
```
+**Note:** For Chinese, the following command is always recommended. The
additional build argument `ENABLE_PROXY=true` will enable proxy to definitely
accelerate the progress.
+
+```sh
+$ docker build -t apisix:${APISIX_VERSION}-alpine --build-arg
APISIX_VERSION=${APISIX_VERSION} --build-arg ENABLE_PROXY=true -f
alpine/Dockerfile alpine
+```
+
### Manual deploy apisix via docker
[Manual deploy](manual.md)
diff --git a/all-in-one/apisix-dashboard/Dockerfile
b/all-in-one/apisix-dashboard/Dockerfile
index 13a3927..021170d 100644
--- a/all-in-one/apisix-dashboard/Dockerfile
+++ b/all-in-one/apisix-dashboard/Dockerfile
@@ -1,11 +1,13 @@
+ARG ENABLE_PROXY=false
+
FROM openresty/openresty:alpine-fat AS production-stage
ARG APISIX_VERSION=master
LABEL apisix_version="${APISIX_VERSION}"
-
+ARG ENABLE_PROXY
RUN set -x \
- && /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories \
+ && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories) \
&& apk add --no-cache --virtual .builddeps \
automake \
autoconf \
@@ -20,17 +22,18 @@ RUN set -x \
&& mv /usr/local/apisix/deps/share/lua/5.1/apisix /usr/local/apisix \
&& apk del .builddeps build-base make unzip
+
FROM alpine:3.11 AS etcd-stage
ARG ETCD_VERSION=v3.4.14
LABEL etcd_version="${ETCD_VERSION}"
WORKDIR /tmp
-
RUN wget
https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz
\
&& tar -zxvf etcd-${ETCD_VERSION}-linux-amd64.tar.gz \
&& ln -s etcd-${ETCD_VERSION}-linux-amd64 etcd
+
FROM alpine:latest as pre-build
ARG APISIX_DASHBOARD_VERSION=master
@@ -40,9 +43,10 @@ RUN set -x \
&& mkdir /usr/local/apisix-dashboard \
&& tar -xvf /tmp/apisix-dashboard.tar.gz -C /usr/local/apisix-dashboard
--strip 1
+
FROM golang:1.14 as api-builder
-ARG ENABLE_PROXY=false
+ARG ENABLE_PROXY
ARG APISIX_DASHBOARD_VERSION=master
WORKDIR /usr/local/apisix-dashboard
@@ -52,19 +56,17 @@ COPY --from=pre-build /usr/local/apisix-dashboard .
WORKDIR /usr/local/apisix-dashboard/api
RUN mkdir -p ../output/conf \
- && cp ./conf/*.json ../output/conf
-
-RUN wget https://github.com/api7/dag-to-lua/archive/v1.1.tar.gz -O
/tmp/v1.1.tar.gz \
+ && cp ./conf/*.json ../output/conf \
+ && wget https://github.com/api7/dag-to-lua/archive/v1.1.tar.gz -O
/tmp/v1.1.tar.gz \
&& mkdir /tmp/dag-to-lua \
&& tar -xvf /tmp/v1.1.tar.gz -C /tmp/dag-to-lua --strip 1 \
&& mkdir -p ../output/dag-to-lua \
- && mv /tmp/dag-to-lua/lib/* ../output/dag-to-lua/
-
-RUN if [ "$ENABLE_PROXY" = "true" ] ; then go env -w
GOPROXY=https://goproxy.io,direct ; fi
-
-RUN go env -w GO111MODULE=on \
+ && mv /tmp/dag-to-lua/lib/* ../output/dag-to-lua/ \
+ && if [ "$ENABLE_PROXY" = "true" ] ; then go env -w
GOPROXY=https://goproxy.io,direct ; fi \
+ && go env -w GO111MODULE=on \
&& if [ "$APISIX_DASHBOARD_VERSION" = "master" ] || [
"$APISIX_DASHBOARD_VERSION" \> "v2.2" ]; then CGO_ENABLED=0 go build -o
../output/manager-api ./cmd/manager; else CGO_ENABLED=0 go build -o
../output/manager-api . ; fi;
+
FROM node:14-alpine as fe-builder
ARG ENABLE_PROXY=false
@@ -75,18 +77,17 @@ COPY --from=pre-build /usr/local/apisix-dashboard .
WORKDIR /usr/local/apisix-dashboard/web
-RUN if [ "$ENABLE_PROXY" = "true" ] ; then yarn config set registry
https://registry.npm.taobao.org/ ; fi
-
-RUN yarn install
-
-RUN yarn build
+RUN if [ "$ENABLE_PROXY" = "true" ] ; then yarn config set registry
https://registry.npm.taobao.org/ ; fi \
+ && yarn install \
+ && yarn build
FROM alpine:3.11 AS last-stage
+ARG ENABLE_PROXY
# add runtime for Apache APISIX
RUN set -x \
- && /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories \
+ && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories) \
&& apk add --no-cache bash libstdc++ curl
WORKDIR /usr/local/apisix
@@ -102,16 +103,12 @@ ENV
PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/
# dashboard
-ARG ENABLE_PROXY=false
-
-RUN if [ "$ENABLE_PROXY" = "true" ] ; then sed -i
's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories ; fi
-
-RUN apk add lua5.1
+RUN if [ "$ENABLE_PROXY" = "true" ] ; then sed -i
's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories ; fi \
+ && apk add lua5.1
WORKDIR /usr/local/apisix-dashboard
COPY --from=api-builder /usr/local/apisix-dashboard/output/ ./
-
COPY --from=fe-builder /usr/local/apisix-dashboard/output/ ./
RUN mkdir logs
diff --git a/all-in-one/apisix/Dockerfile b/all-in-one/apisix/Dockerfile
index b78d791..c3dd708 100644
--- a/all-in-one/apisix/Dockerfile
+++ b/all-in-one/apisix/Dockerfile
@@ -1,11 +1,13 @@
+ARG ENABLE_PROXY=false
+
FROM openresty/openresty:alpine-fat AS production-stage
ARG APISIX_VERSION=master
LABEL apisix_version="${APISIX_VERSION}"
-
+ARG ENABLE_PROXY
RUN set -x \
- && /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories \
+ && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories) \
&& apk add --no-cache --virtual .builddeps \
automake \
autoconf \
@@ -33,9 +35,10 @@ RUN wget
https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-
FROM alpine:3.11 AS last-stage
+ARG ENABLE_PROXY
# add runtime for Apache APISIX
RUN set -x \
- && /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories \
+ && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories) \
&& apk add --no-cache bash libstdc++ curl
WORKDIR /usr/local/apisix
diff --git a/alpine-dev/Dockerfile b/alpine-dev/Dockerfile
index 0abd98a..483b68d 100644
--- a/alpine-dev/Dockerfile
+++ b/alpine-dev/Dockerfile
@@ -1,7 +1,10 @@
+ARG ENABLE_PROXY=false
+
FROM openresty/openresty:alpine-fat AS production-stage
+ARG ENABLE_PROXY
RUN set -x \
- && /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories \
+ && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories) \
&& apk add --no-cache --virtual .builddeps \
automake \
autoconf \
@@ -18,9 +21,10 @@ RUN set -x \
FROM alpine:3.11 AS last-stage
+ARG ENABLE_PROXY
# add runtime for Apache APISIX
RUN set -x \
- && /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories \
+ && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories) \
&& apk add --no-cache bash libstdc++ curl
WORKDIR /usr/local/apisix
diff --git a/alpine/Dockerfile b/alpine/Dockerfile
index d9205d1..51abb01 100644
--- a/alpine/Dockerfile
+++ b/alpine/Dockerfile
@@ -1,10 +1,13 @@
+ARG ENABLE_PROXY=false
+
FROM openresty/openresty:alpine-fat AS production-stage
ARG APISIX_VERSION=1.3
LABEL apisix_version="${APISIX_VERSION}"
+ARG ENABLE_PROXY
RUN set -x \
- && /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories \
+ && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories) \
&& apk add --no-cache --virtual .builddeps \
automake \
autoconf \
@@ -21,9 +24,10 @@ RUN set -x \
FROM alpine:3.11 AS last-stage
+ARG ENABLE_PROXY
# add runtime for Apache APISIX
RUN set -x \
- && /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories \
+ && (test "${ENABLE_PROXY}" != "true" || /bin/sed -i
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g'
/etc/apk/repositories) \
&& apk add --no-cache bash libstdc++ curl
WORKDIR /usr/local/apisix