You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2021/08/13 04:22:19 UTC

[skywalking-infra-e2e] branch main updated: Add Dockerfile and use Docker image in GHA (#32)

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

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-infra-e2e.git


The following commit(s) were added to refs/heads/main by this push:
     new 4d0fd62  Add Dockerfile and use Docker image in GHA (#32)
4d0fd62 is described below

commit 4d0fd62d0cafd4b6d74665efe59b3a455b29fb71
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Fri Aug 13 12:22:16 2021 +0800

    Add Dockerfile and use Docker image in GHA (#32)
---
 .github/workflows/build.yaml |  3 +++
 Dockerfile                   | 59 ++++++++++++++++++++++++++++++++++++++++++++
 Makefile                     |  7 +++++-
 action.yaml                  | 19 +++-----------
 4 files changed, 72 insertions(+), 16 deletions(-)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index ce03dd8..23c5d4e 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -51,3 +51,6 @@ jobs:
 
       - name: Build
         run: make build
+
+      - name: Build Docker Image
+        run: make docker
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..1a4bba9
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,59 @@
+# Licensed to 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. Apache Software Foundation (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 golang:1.16 AS swctl
+
+ARG COMMIT_HASH=master
+ARG CLI_CODE=${COMMIT_HASH}.tar.gz
+ARG CLI_CODE_URL=https://github.com/apache/skywalking-cli/archive/${CLI_CODE}
+
+ENV CGO_ENABLED=0
+ENV GO111MODULE=on
+
+WORKDIR /cli
+
+ADD ${CLI_CODE_URL} .
+RUN tar -xf ${CLI_CODE} --strip 1
+RUN rm ${CLI_CODE}
+
+RUN VERSION=ci make linux && mv bin/swctl-ci-linux-amd64 /usr/local/bin/swctl
+
+FROM golang:1.16 AS build
+
+WORKDIR /e2e
+
+COPY . .
+
+RUN make linux
+
+FROM golang:1.16 AS bin
+
+RUN apt update; \
+    apt install -y docker-compose
+
+COPY --from=swctl /usr/local/bin/swctl /usr/local/bin/swctl
+COPY --from=build /e2e/bin/linux/e2e /usr/local/bin/e2e
+
+# Add common tools, copy from prebuilt Docker image whenever possible.
+COPY --from=stedolan/jq /usr/local/bin/jq /usr/local/bin/jq
+COPY --from=mikefarah/yq:4 /usr/bin/yq /usr/local/bin/yq
+COPY --from=docker /usr/local/bin/docker /usr/local/bin/docker
+
+WORKDIR /github/workspace/
+
+ENTRYPOINT ["/bin/e2e"]
diff --git a/Makefile b/Makefile
index e0f675b..673441a 100644
--- a/Makefile
+++ b/Makefile
@@ -16,11 +16,12 @@
 # under the License.
 #
 
-PROJECT = e2e
+PROJECT := e2e
 VERSION ?= latest
 OUT_DIR = bin
 ARCH := $(shell uname)
 OSNAME := $(if $(findstring Darwin,$(ARCH)),darwin,linux)
+HUB ?= docker.io/apache
 
 GO := GO111MODULE=on go
 GO_PATH = $(shell $(GO) env GOPATH)
@@ -70,6 +71,10 @@ clean:
 .PHONY: verify
 verify: clean lint test
 
+.PHONY: docker
+docker:
+	docker build --no-cache . -t $(HUB)/$(PROJECT):$(VERSION)
+
 release-src: clean
 	-mkdir $(RELEASE_SRC)
 	-cp ../NOTICE $(RELEASE_SRC)
diff --git a/action.yaml b/action.yaml
index b6549e4..25b9c8e 100644
--- a/action.yaml
+++ b/action.yaml
@@ -26,20 +26,9 @@ runs:
   using: "composite"
   steps:
     - shell: bash
-      run: |
-        mkdir -p /tmp/skywalking-infra-e2e/bin
-    - shell: bash
-      run: |
-        cd "$GITHUB_ACTION_PATH"
-        go mod download && make linux && mv bin/linux/e2e /tmp/skywalking-infra-e2e/bin/e2e
-    - shell: bash
-      run: |
-        cd /tmp/skywalking-infra-e2e
-        git clone https://github.com/apache/skywalking-cli.git
-        git -C skywalking-cli reset --hard 0494541890cd44a9be23e7fe091f9d0f84986613
-        cd skywalking-cli
-        make build && mv bin/swctl-*-linux-amd64 ../bin/swctl
+      run: make -C $GITHUB_ACTION_PATH docker
     - shell: bash
       run: |
-        export PATH="$PATH:/tmp/skywalking-infra-e2e/bin"
-        e2e run -c "${{ inputs.e2e-file }}"
\ No newline at end of file
+        docker run -v $(pwd):/github/workspace \
+                   -v /var/run/docker.sock:/var/run/docker.sock \
+                   docker.io/apache/e2e:latest run -c "${{ inputs.e2e-file }}"