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: Add version ldflags for building manager-api in Dockerfile #1393

Merged
merged 2 commits into from
Jan 29, 2021
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
5 changes: 5 additions & 0 deletions .github/workflows/deploy-with-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
Expand All @@ -13,6 +16,7 @@ jobs:
- uses: actions/checkout@v2

- uses: Azure/docker-login@v1
if: ${{ github.event_name == 'push' }}
with:
login-server: apisixacr.azurecr.cn
username: ${{ secrets.REGISTRY_USERNAME }}
Expand All @@ -38,6 +42,7 @@ jobs:
run: api/test/shell/docker_deploy_test.sh

- name: Deploy
if: ${{ github.event_name == 'push' }}
run: |
docker tag dashboard:ci apisixacr.azurecr.cn/dashboard:${{ github.sha }}
docker push apisixacr.azurecr.cn/dashboard:${{ github.sha }}
26 changes: 6 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,9 @@ 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 ./cmd/manager
RUN if [ "$ENABLE_PROXY" = "true" ] ; then go env -w GOPROXY=https://goproxy.io,direct ; fi \
&& go env -w GO111MODULE=on \
&& CGO_ENABLED=0 ./api/build.sh

FROM node:14-alpine as fe-builder

Expand All @@ -57,11 +45,9 @@ 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:latest as prod

Expand Down
8 changes: 8 additions & 0 deletions api/test/shell/docker_deploy_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@

set -ex

# Version output
verline=$(docker logs docker-deploy_managerapi_1 | grep -E "^Version : [A-Za-z0-9\-\_\.]+")
if [ -z "$verline" ];then
echo "no Version output"
exit 1
fi

# web page
curl http://127.0.0.1:9000
code=$(curl -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:9000)
Expand All @@ -32,6 +39,7 @@ resp=$(curl http://127.0.0.1:9000/apisix/admin/user/login -X POST -d '{"username
token=$(echo "${resp}" | sed 's/{/\n/g' | sed 's/,/\n/g' | grep "token" | sed 's/:/\n/g' | sed '1d' | sed 's/}//g' | sed 's/"//g')
if [ -z "${token}" ]; then
echo "login failed"
exit 1
fi

# plugin orchestration
Expand Down