-
Notifications
You must be signed in to change notification settings - Fork 527
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
feat: deploy with Docker #657
Merged
Merged
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
835807c
feat: added Docker
juzhiyuan 7c77cf0
feat: added License header
juzhiyuan 92ac8cd
feat: added line in docs
juzhiyuan 87884b0
Update test-docker.yml
juzhiyuan 936118b
feat(doc): update docs
juzhiyuan c1cfdf7
feat: added extra line
juzhiyuan 331a7e4
feat: added Go Proxy in Dockerfile
juzhiyuan 8b344db
feat: update Dockerfile
juzhiyuan 105a5f6
chore: update docs
juzhiyuan ea75bf7
fix: copy correct files
juzhiyuan c68a4c4
feat: improve Dockerfile
juzhiyuan 1f99463
Revert "feat: improve Dockerfile"
juzhiyuan 1099024
fix run fail
johzchen d028a4c
feat: update docs
juzhiyuan 8782e3f
fix: compatible with Golang conf
juzhiyuan 93d38ee
Squashed commit of the following:
juzhiyuan 1624aef
Revert "Squashed commit of the following:"
juzhiyuan 9cc74ce
feat: remove output from ignore files
juzhiyuan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/node_modules | ||
**/output | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Deploy with Docker | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- v2.0 | ||
pull_request: | ||
branches: | ||
- master | ||
- v2.0 | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run with Docker | ||
run: | | ||
docker build -t apisix-dashboard:dev . | ||
docker run -d -p 8081:8080 apisix-dashboard:dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
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 \ | ||
juzhiyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
&& 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 \ | ||
&& go build -o ../output/manager-api . | ||
juzhiyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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/frontend | ||
|
||
RUN if [ "$ENABLE_PROXY" = "true" ] ; then yarn config set registry https://registry.npm.taobao.org/ ; fi | ||
|
||
RUN yarn install | ||
|
||
RUN yarn build | ||
|
||
FROM alpine:latest as prod | ||
|
||
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/ ./ | ||
|
||
EXPOSE 8080 | ||
|
||
CMD [ "/bin/ash", "-c", "manager-api" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!-- | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
--> | ||
|
||
# Deploy with Docker | ||
|
||
1. Build image | ||
|
||
```sh | ||
# NOTE: $tag should be set manually | ||
$ docker build -t apisix-dashboard:{$tag} . | ||
``` | ||
|
||
2. Run container | ||
|
||
```sh | ||
$ docker run -d -p 80:8080 --name apisix-dashboard apisix-dashboard:{$tag} | ||
``` | ||
|
||
## Note | ||
|
||
1. After building the image, if you want to modify the configuration file, you can use the `docker -v /local-path-to-conf-file:/conf/conf.json` parameter to specify the configuration file required for `manager-api` to be loaded dynamically when the container is started. | ||
2. For users in China, we could use the `ENABLE_PROXY` flag to speed up dependencies downloading. | ||
|
||
```sh | ||
$ docker build -t apisix-dashboard:{$tag} . --build-arg ENABLE_PROXY=true | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!-- | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
--> | ||
|
||
# 使用 Docker 部署 | ||
|
||
1. 构建镜像 | ||
|
||
```sh | ||
# 注意:需手动指定 $tag | ||
$ docker build -t apisix-dashboard:{$tag} . | ||
juzhiyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
2. 启动容器 | ||
|
||
```sh | ||
$ docker run -d -p 80:8080 --name apisix-dashboard apisix-dashboard:{$tag} | ||
``` | ||
|
||
## 注意 | ||
|
||
1. 构建镜像后,如需修改配置文件,可通过使用 `docker -v /local-path-to-conf-file:/conf/conf.json` 参数指定 `manager-api` 所需要的配置文件,以便启动容器时动态加载配置文件。 | ||
2. 中国用户可使用 `ENABLE_PROXY` 指令以加速所需依赖的下载。 | ||
|
||
```sh | ||
$ docker build -t apisix-dashboard:{$tag} . --build-arg ENABLE_PROXY=true | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ignore this directory?
output
is looks like the build result.If it is just a test result or other files unnecessary, we can rename it more meaningful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this folder here is because when building and using the current folder's sources codes, this folder will be copied to the image unexpectedly, we should remove this because we are using codes from release, this issue will neverr occur. Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just removed this.