|
| 1 | +--- |
| 2 | +id: build-apisix-dev-environment-on-mac |
| 3 | +title: Build development environment on Mac |
| 4 | +description: This paper introduces how to use Docker to quickly build the development environment of API gateway Apache APISIX on Mac. |
| 5 | +--- |
| 6 | + |
| 7 | +<!-- |
| 8 | +# |
| 9 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 10 | +# contributor license agreements. See the NOTICE file distributed with |
| 11 | +# this work for additional information regarding copyright ownership. |
| 12 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 13 | +# (the "License"); you may not use this file except in compliance with |
| 14 | +# the License. You may obtain a copy of the License at |
| 15 | +# |
| 16 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 17 | +# |
| 18 | +# Unless required by applicable law or agreed to in writing, software |
| 19 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 20 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 21 | +# See the License for the specific language governing permissions and |
| 22 | +# limitations under the License. |
| 23 | +# |
| 24 | +--> |
| 25 | + |
| 26 | +If you want to quickly build and develop APISIX on your Mac platform, you can refer to this tutorial. |
| 27 | + |
| 28 | +:::note |
| 29 | + |
| 30 | +This tutorial is suitable for situations where you need to quickly start development on the Mac platform, if you want to go further and have a better development experience, the better choice is the Linux-based virtual machine, or directly use this kind of system as your development environment. |
| 31 | + |
| 32 | +You can see the specific supported systems [here](install-dependencies.md#install). |
| 33 | + |
| 34 | +::: |
| 35 | + |
| 36 | +## Quick Setup of Apache APISIX Development Environment |
| 37 | + |
| 38 | +### Implementation Idea |
| 39 | + |
| 40 | +We use Docker to build the test environment of Apache APISIX. When the container starts, we can mount the source code of Apache APISIX into the container, and then we can build and run test cases in the container. |
| 41 | + |
| 42 | +### Implementation Steps |
| 43 | + |
| 44 | +First, clone the APISIX source code, build an image that can run test cases, and compile the Apache APISIX. |
| 45 | + |
| 46 | +```shell |
| 47 | +git clone https://github.com/apache/apisix.git |
| 48 | +cd apisix |
| 49 | +docker build -t apisix-dev-env -f example/build-dev-image.dockerfile . |
| 50 | +``` |
| 51 | + |
| 52 | +Next, start Etcd: |
| 53 | + |
| 54 | +```shell |
| 55 | +docker run -d --name etcd-apisix --net=host pachyderm/etcd:v3.5.2 |
| 56 | +``` |
| 57 | + |
| 58 | +Mount the APISIX directory and start the development environment container: |
| 59 | + |
| 60 | +```shell |
| 61 | +docker run -d --name apisix-dev-env --net=host -v $(pwd):/apisix:rw apisix-dev-env:latest |
| 62 | +``` |
| 63 | + |
| 64 | +Finally, enter the container, build the Apache APISIX runtime, and configure the test environment: |
| 65 | + |
| 66 | +```shell |
| 67 | +docker exec -it apisix-dev-env make deps |
| 68 | +docker exec -it apisix-dev-env ln -s /usr/bin/openresty /usr/bin/nginx |
| 69 | +``` |
| 70 | + |
| 71 | +### Run and Stop APISIX |
| 72 | + |
| 73 | +```shell |
| 74 | +docker exec -it apisix-dev-env make run |
| 75 | +docker exec -it apisix-dev-env make stop |
| 76 | +``` |
| 77 | + |
| 78 | +:::note |
| 79 | + |
| 80 | +If you encounter an error message like `nginx: [emerg] bind() to unix:/apisix/logs/worker_events.sock failed (95: Operation not supported)` while running `make run`, please use this solution. |
| 81 | + |
| 82 | +Change the `File Sharing` settings of your Docker-Desktop: |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | +Changing to either `gRPC FUSE` or `osxfs` can resolve this issue. |
| 87 | + |
| 88 | +::: |
| 89 | + |
| 90 | +### Run Specific Test Cases |
| 91 | + |
| 92 | +```shell |
| 93 | +docker exec -it apisix-dev-env prove t/admin/routes.t |
| 94 | +``` |
0 commit comments