This is an automated email from the ASF dual-hosted git repository.

kvn 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 6941e78  feat: add dockerfile for apisix and dashboard with all 
dependencies (#99)
6941e78 is described below

commit 6941e78a91c26dc1270972cf2153ddee380f5f79
Author: kv <[email protected]>
AuthorDate: Fri Dec 11 15:46:29 2020 +0800

    feat: add dockerfile for apisix and dashboard with all dependencies (#99)
    
    * feat: add dockerfile for apisix and dashboard with all dependencies
    
    * chore: add document about all-in-one docker
    
    * fix: dashboard config error
    
    * add EOL
    
    * CI: remove the execution of pr phase
    
    * doc: add tips for port conflict
    
    * doc: add dashboard version description in readme
---
 .github/workflows/apisix_all_in_one_ci.yaml    |  19 ++++
 .github/workflows/dashboard_all_in_one_ci.yaml |  20 ++++
 .gitignore                                     |   1 +
 README.md                                      |  24 +++++
 all-in-one/apisix-dashboard/Dockerfile         | 122 +++++++++++++++++++++++++
 all-in-one/apisix-dashboard/conf.yaml          |  28 ++++++
 all-in-one/apisix/Dockerfile                   |  56 ++++++++++++
 all-in-one/apisix/config.yaml                  |   6 ++
 example/docker-compose.yml                     |   6 +-
 9 files changed, 277 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/apisix_all_in_one_ci.yaml 
b/.github/workflows/apisix_all_in_one_ci.yaml
new file mode 100644
index 0000000..390c1cf
--- /dev/null
+++ b/.github/workflows/apisix_all_in_one_ci.yaml
@@ -0,0 +1,19 @@
+name: apisix all in one docker
+
+on:
+  push:
+    branches:
+      - master
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Build and Test
+        run: |
+          docker build -t apache/apisix:whole -f 
./all-in-one/apisix/Dockerfile .
+          docker run -v 
`pwd`/all-in-one/apisix/config.yaml:/usr/local/apisix/conf/config.yaml -p 
9080:9080 -p 2379:2379 -d apache/apisix:whole
+          sleep 30
+          curl http://127.0.0.1:9080/apisix/admin/schema/service -H 
'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1'
diff --git a/.github/workflows/dashboard_all_in_one_ci.yaml 
b/.github/workflows/dashboard_all_in_one_ci.yaml
new file mode 100644
index 0000000..cee0cad
--- /dev/null
+++ b/.github/workflows/dashboard_all_in_one_ci.yaml
@@ -0,0 +1,20 @@
+name: apisix dashboard all in one docker
+
+on:
+  push:
+    branches:
+      - master
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Build and Test
+        run: |
+          docker build -t apache/apisix-dashboard:whole -f 
./all-in-one/apisix-dashboard/Dockerfile .
+          docker run -v 
`pwd`/all-in-one/apisix/config.yaml:/usr/local/apisix/conf/config.yaml -v 
`pwd`/all-in-one/apisix-dashboard/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml
 -p 9080:9080 -p 2379:2379 -p 9000:9000 -d apache/apisix-dashboard:whole
+          sleep 30
+          curl http://127.0.0.1:9080/apisix/admin/schema/service -H 
'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1'
+          curl http://127.0.0.1:9000
diff --git a/.gitignore b/.gitignore
index 485dee6..090a1f0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
 .idea
+.DS_Store
diff --git a/README.md b/README.md
index 1059266..4a69094 100644
--- a/README.md
+++ b/README.md
@@ -35,3 +35,27 @@ $ docker-compose -p docker-apisix up -d
 
 You can refer to [the docker-compose example](example/README.md) for more try.
 
+### Quick test with all dependencies in one Docker container
+
+* All in one Docker container for Apache APISIX
+
+```shell
+$ docker build -t apache/apisix:whole -f ./all-in-one/apisix/Dockerfile .
+$ docker run -v 
`pwd`/all-in-one/apisix/config.yaml:/usr/local/apisix/conf/config.yaml -p 
9080:9080 -p 2379:2379 -d apache/apisix:whole
+```
+
+* All in one Docker container for Apache apisix-dashboard
+
+**The latest version of `apisix-dashboard` is 2.1.1 and should be used with 
APISIX 2.1. It is not recommended to use with other APISIX versions.**
+
+```shell
+$ docker build --build-arg APISIX_VERSION=2.1 --build-arg 
APISIX_DASHBOARD_VERSION=v2.1.1 -t apache/apisix-dashboard:whole -f 
./all-in-one/apisix-dashboard/Dockerfile .
+$ docker run -v 
`pwd`/all-in-one/apisix/config.yaml:/usr/local/apisix/conf/config.yaml -v 
`pwd`/all-in-one/apisix-dashboard/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml
 -p 9080:9080 -p 2379:2379 -p 9000:9000 -d apache/apisix-dashboard:whole
+```
+
+Tips: If there is a port conflict, please modify the host port through `docker 
run -p`, e.g.
+
+```shell
+$ docker run -v 
`pwd`/all-in-one/apisix/config.yaml:/usr/local/apisix/conf/config.yaml -v 
`pwd`/all-in-one/apisix-dashboard/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml
 -p 19080:9080 -p 12379:2379 -p 19000:9000 -d apache/apisix-dashboard:whole
+```
+
diff --git a/all-in-one/apisix-dashboard/Dockerfile 
b/all-in-one/apisix-dashboard/Dockerfile
new file mode 100644
index 0000000..68d63e0
--- /dev/null
+++ b/all-in-one/apisix-dashboard/Dockerfile
@@ -0,0 +1,122 @@
+FROM openresty/openresty:alpine-fat AS production-stage
+
+ARG APISIX_VERSION=master
+LABEL apisix_version="${APISIX_VERSION}"
+
+
+RUN set -x \
+    && /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 \
+    libtool \
+    pkgconfig \
+    cmake \
+    git \
+    && luarocks install 
https://github.com/apache/apisix/raw/master/rockspec/apisix-${APISIX_VERSION}-0.rockspec
 --tree=/usr/local/apisix/deps \
+    && cp -v 
/usr/local/apisix/deps/lib/luarocks/rocks-5.1/apisix/${APISIX_VERSION}-0/bin/apisix
 /usr/bin/ \
+    && bin='#! /usr/local/openresty/luajit/bin/luajit\npackage.path = 
"/usr/local/apisix/?.lua;" .. package.path' \
+    && sed -i "1s@.*@$bin@" /usr/bin/apisix \
+    && 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=v2.0
+
+RUN set -x \
+    && wget 
https://github.com/apache/apisix-dashboard/archive/${APISIX_DASHBOARD_VERSION}.tar.gz
 -O /tmp/apisix-dashboard.tar.gz \
+    && 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
+
+WORKDIR /usr/local/apisix-dashboard
+
+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 \
+    && 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 \
+    && CGO_ENABLED=0 go build -o ../output/manager-api .
+
+FROM node:14-alpine as fe-builder
+
+ARG ENABLE_PROXY=false
+
+WORKDIR /usr/local/apisix-dashboard
+
+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
+
+
+FROM alpine:3.11 AS last-stage
+
+# 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 \
+    && apk add --no-cache bash libstdc++ curl
+
+WORKDIR /usr/local/apisix
+
+COPY --from=production-stage /usr/local/openresty/ /usr/local/openresty/
+COPY --from=production-stage /usr/local/apisix/ /usr/local/apisix/
+COPY --from=production-stage /usr/bin/apisix /usr/bin/apisix
+
+COPY --from=etcd-stage /tmp/etcd/etcd /usr/bin/etcd
+COPY --from=etcd-stage /tmp/etcd/etcdctl /usr/bin/etcdctl
+
+ENV 
PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
+
+# 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
+
+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
+
+EXPOSE 9080 9443 2379 2380 9000
+
+CMD ["sh", "-c", "(nohup etcd >/tmp/etcd.log 2>&1 &) && sleep 10 && 
(/usr/local/apisix-dashboard/manager-api &) && /usr/bin/apisix init && 
/usr/bin/apisix init_etcd && /usr/local/openresty/bin/openresty -p 
/usr/local/apisix -g 'daemon off;'"]
+
+STOPSIGNAL SIGQUIT
diff --git a/all-in-one/apisix-dashboard/conf.yaml 
b/all-in-one/apisix-dashboard/conf.yaml
new file mode 100644
index 0000000..c70134f
--- /dev/null
+++ b/all-in-one/apisix-dashboard/conf.yaml
@@ -0,0 +1,28 @@
+conf:
+  listen:
+    host: 0.0.0.0     # `manager api` listening ip or host name
+    port: 9000          # `manager api` listening port
+  etcd:
+    endpoints:          # supports defining multiple etcd host addresses for 
an etcd cluster
+      - 127.0.0.1:2379
+
+                        # etcd basic auth info
+    # username: "root"    # ignore etcd username if not enable etcd auth
+    # password: "123456"  # ignore etcd password if not enable etcd auth
+  log:
+    error_log:
+      level: warn       # supports levels, lower to higher: debug, info, warn, 
error, panic, fatal
+      file_path:
+        logs/error.log  # supports relative path, absolute path, standard 
output
+                        # such as: logs/error.log, /tmp/logs/error.log, 
/dev/stdout, /dev/stderr
+authentication:
+  secret:
+    secret              # secret for jwt token generation.
+                        # NOTE: Highly recommended to modify this value to 
protect `manager api`.
+                        # if it's default value, when `manager api` start , it 
will generate a random string to replace it.
+  expire_time: 3600     # jwt token expire time, in second
+  users:
+    - username: admin   # username and password for login `manager api`
+      password: admin
+    - username: user
+      password: user
diff --git a/all-in-one/apisix/Dockerfile b/all-in-one/apisix/Dockerfile
new file mode 100644
index 0000000..b78d791
--- /dev/null
+++ b/all-in-one/apisix/Dockerfile
@@ -0,0 +1,56 @@
+FROM openresty/openresty:alpine-fat AS production-stage
+
+ARG APISIX_VERSION=master
+LABEL apisix_version="${APISIX_VERSION}"
+
+
+RUN set -x \
+    && /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 \
+    libtool \
+    pkgconfig \
+    cmake \
+    git \
+    && luarocks install 
https://github.com/apache/apisix/raw/master/rockspec/apisix-${APISIX_VERSION}-0.rockspec
 --tree=/usr/local/apisix/deps \
+    && cp -v 
/usr/local/apisix/deps/lib/luarocks/rocks-5.1/apisix/${APISIX_VERSION}-0/bin/apisix
 /usr/bin/ \
+    && bin='#! /usr/local/openresty/luajit/bin/luajit\npackage.path = 
"/usr/local/apisix/?.lua;" .. package.path' \
+    && sed -i "1s@.*@$bin@" /usr/bin/apisix \
+    && 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:3.11 AS last-stage
+
+# 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 \
+    && apk add --no-cache bash libstdc++ curl
+
+WORKDIR /usr/local/apisix
+
+COPY --from=production-stage /usr/local/openresty/ /usr/local/openresty/
+COPY --from=production-stage /usr/local/apisix/ /usr/local/apisix/
+COPY --from=production-stage /usr/bin/apisix /usr/bin/apisix
+
+COPY --from=etcd-stage /tmp/etcd/etcd /usr/bin/etcd
+COPY --from=etcd-stage /tmp/etcd/etcdctl /usr/bin/etcdctl
+
+ENV 
PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin
+
+EXPOSE 9080 9443 2379 2380
+
+CMD ["sh", "-c", "(nohup etcd >/tmp/etcd.log 2>&1 &) && sleep 10 && 
/usr/bin/apisix init && /usr/bin/apisix init_etcd && 
/usr/local/openresty/bin/openresty -p /usr/local/apisix -g 'daemon off;'"]
+
+STOPSIGNAL SIGQUIT
diff --git a/all-in-one/apisix/config.yaml b/all-in-one/apisix/config.yaml
new file mode 100644
index 0000000..4fba0f9
--- /dev/null
+++ b/all-in-one/apisix/config.yaml
@@ -0,0 +1,6 @@
+apisix:
+  node_listen: 9080              # APISIX listening port
+  enable_ipv6: false
+
+  allow_admin:                  # 
http://nginx.org/en/docs/http/ngx_http_access_module.html#allow
+    - 0.0.0.0/0              # We need to restrict ip access rules for 
security. 0.0.0.0/0 is for test.
diff --git a/example/docker-compose.yml b/example/docker-compose.yml
index bb5cfd0..a6f73d1 100644
--- a/example/docker-compose.yml
+++ b/example/docker-compose.yml
@@ -2,11 +2,7 @@ version: "3"
 
 services:
   apisix:
-    build:
-      context: ./..
-      dockerfile: alpine/Dockerfile
-      args:
-        APISIX_VERSION: master
+    image: apache/apisix:2.1-alpine
     restart: always
     volumes:
       - ./apisix_log:/usr/local/apisix/logs

Reply via email to