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/09/08 14:16:00 UTC

[skywalking-java] branch dockerfile updated (e000820 -> d85bc25)

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

kezhenxu94 pushed a change to branch dockerfile
in repository https://gitbox.apache.org/repos/asf/skywalking-java.git.


 discard e000820  Migrate base Docker image from JDK to JRE and remove unused classes
     new d85bc25  Migrate base Docker image from JDK to JRE and remove unused classes

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (e000820)
            \
             N -- N -- N   refs/heads/dockerfile (d85bc25)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

[skywalking-java] 01/01: Migrate base Docker image from JDK to JRE and remove unused classes

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d85bc257dcc55b6a401963e64cbeb20991b178e9
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Wed Sep 8 22:13:17 2021 +0800

    Migrate base Docker image from JDK to JRE and remove unused classes
---
 .github/workflows/publish-docker.yaml              |   3 +-
 Dockerfile                                         |  85 +++++++++++--
 Makefile                                           |  35 ++++--
 .../skywalking/apm/util/StringFormatGroup.java     |  95 --------------
 .../skywalking/apm/util/StringFormatGroupTest.java | 138 ---------------------
 docs/en/contribution/release-java-agent.md         |  16 +++
 6 files changed, 118 insertions(+), 254 deletions(-)

diff --git a/.github/workflows/publish-docker.yaml b/.github/workflows/publish-docker.yaml
index dad3a20..ff225b8 100644
--- a/.github/workflows/publish-docker.yaml
+++ b/.github/workflows/publish-docker.yaml
@@ -20,6 +20,7 @@ on:
   push:
     branches:
       - main
+      - dockerfile
 
 env:
   SKIP_TEST: true
@@ -36,7 +37,7 @@ jobs:
     timeout-minutes: 60
     strategy:
       matrix:
-        java-version: [ 8, 9, 10, 11, 12, 13, 14, 15, 16 ]
+        java-version: [ 8, 11, 12, 13, 14, 15, 16 ]
     env:
       BASE_IMAGE: adoptopenjdk/openjdk${{ matrix.java-version }}:alpine
       NAME: jdk-${{ matrix.java-version }}
diff --git a/Dockerfile b/Dockerfile
index 08f41bf..1e60724 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,20 +14,91 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-ARG BASE_IMAGE='adoptopenjdk/openjdk8:alpine'
+ARG BASE_IMAGE='adoptopenjdk/openjdk8:alpine-jre'
 
-FROM alpine AS cli
+FROM $BASE_IMAGE as cli
 
-WORKDIR /skywalking/bin
+WORKDIR /skywalking
+
+ARG SKYWALKING_CLI_VERSION=0.7.0
+ENV SKYWALKING_CLI_TGZ=skywalking-cli-$SKYWALKING_CLI_VERSION-bin.tgz
+ENV SKYWALKING_CLI_ASC=${SKYWALKING_CLI_TGZ}.asc
+ENV SKYWALKING_CLI_SHA512=${SKYWALKING_CLI_TGZ}.sha512
+
+ENV SKYWALKING_CLI_TGZ_URLS \
+        https://www.apache.org/dyn/closer.cgi?action=download&filename=skywalking/cli/$SKYWALKING_CLI_VERSION/$SKYWALKING_CLI_TGZ \
+        # if the version is outdated, we might have to pull from the dist/archive :/
+	    https://www-us.apache.org/dist/skywalking/cli/$SKYWALKING_CLI_VERSION/$SKYWALKING_CLI_TGZ \
+	    https://www.apache.org/dist/skywalking/cli/$SKYWALKING_CLI_VERSION/$SKYWALKING_CLI_TGZ \
+	    https://archive.apache.org/dist/skywalking/cli/$SKYWALKING_CLI_VERSION/$SKYWALKING_CLI_TGZ
 
-ARG CLI_VERSION=0.6.0
+ENV SKYWALKING_CLI_ASC_URLS \
+        https://www.apache.org/dyn/closer.cgi?action=download&filename=skywalking/$SKYWALKING_CLI_VERSION/$SKYWALKING_CLI_ASC \
+        # if the version is outdated, we might have to pull from the dist/archive :/
+	    https://www-us.apache.org/dist/skywalking/cli/$SKYWALKING_CLI_VERSION/$SKYWALKING_CLI_ASC \
+	    https://www.apache.org/dist/skywalking/cli/$SKYWALKING_CLI_VERSION/$SKYWALKING_CLI_ASC \
+	    https://archive.apache.org/dist/skywalking/cli/$SKYWALKING_CLI_VERSION/$SKYWALKING_CLI_ASC
 
-ADD https://archive.apache.org/dist/skywalking/cli/${CLI_VERSION}/skywalking-cli-${CLI_VERSION}-bin.tgz /
-RUN tar -zxf /skywalking-cli-${CLI_VERSION}-bin.tgz -C / ; \
-    mv /skywalking-cli-${CLI_VERSION}-bin/bin/swctl-${CLI_VERSION}-linux-amd64 /skywalking/bin/swctl
+ENV SKYWALKING_CLI_SHA512_URLS \
+        https://www.apache.org/dyn/closer.cgi?action=download&filename=skywalking/$SKYWALKING_CLI_VERSION/$SKYWALKING_CLI_SHA512 \
+        # if the version is outdated, we might have to pull from the dist/archive :/
+	    https://www-us.apache.org/dist/skywalking/cli/$SKYWALKING_CLI_VERSION/$SKYWALKING_CLI_SHA512 \
+	    https://www.apache.org/dist/skywalking/cli/$SKYWALKING_CLI_VERSION/$SKYWALKING_CLI_SHA512 \
+	    https://archive.apache.org/dist/skywalking/cli/$SKYWALKING_CLI_VERSION/$SKYWALKING_CLI_SHA512
+
+
+RUN set -eux; \
+	\
+	apk add --no-cache --virtual .fetch-deps \
+		gnupg \
+		ca-certificates \
+		openssl \
+	; \
+	\
+	wget --timeout=20 -O KEYS https://downloads.apache.org/skywalking/KEYS; \
+	gpg --import KEYS; \
+	\
+	success=; \
+	for url in $SKYWALKING_CLI_TGZ_URLS; do \
+		if wget --timeout=20  -O ${SKYWALKING_CLI_TGZ} "$url"; then \
+			success=1; \
+			break; \
+		fi; \
+	done; \
+	[ -n "$success" ]; \
+	\
+	success=; \
+	for url in $SKYWALKING_CLI_SHA512_URLS; do \
+		if wget --timeout=20  -O ${SKYWALKING_CLI_SHA512} "$url"; then \
+			success=1; \
+			break; \
+		fi; \
+	done; \
+	[ -n "$success" ]; \
+	\
+	sha512sum -c ${SKYWALKING_CLI_SHA512}; \
+	\
+	success=; \
+	for url in $SKYWALKING_CLI_ASC_URLS; do \
+		if wget --timeout=20  -O ${SKYWALKING_CLI_ASC} "$url"; then \
+			success=1; \
+			break; \
+		fi; \
+	done; \
+	[ -n "$success" ]; \
+	\
+	gpg --batch --verify ${SKYWALKING_CLI_ASC} ${SKYWALKING_CLI_TGZ}; \
+	tar -xvf ${SKYWALKING_CLI_TGZ}; \
+    mkdir "bin/"; \
+	mv skywalking-cli-${SKYWALKING_CLI_VERSION}-bin/bin/swctl-${SKYWALKING_CLI_VERSION}-linux-amd64 bin/swctl; \
+	chmod 755 bin/*; \
+	command -v gpgconf && gpgconf --kill all || :; \
+	ls -la .;
 
 FROM $BASE_IMAGE
 
+RUN apk add --no-cache openssl
+
 LABEL maintainer="kezhenxu94@apache.org"
 
 ENV JAVA_TOOL_OPTIONS=-javaagent:/skywalking/agent/skywalking-agent.jar
diff --git a/Makefile b/Makefile
index 6a927f6..b24d2c2 100644
--- a/Makefile
+++ b/Makefile
@@ -19,22 +19,11 @@ SHELL := /bin/bash -o pipefail
 HUB ?= skywalking
 NAME ?= skywalking-java
 TAG ?= latest
-AGENT_PACKAGE = skywalking-agent
-
-BASE_IMAGE ?= adoptopenjdk/openjdk8:alpine
-SKIP_TEST ?= false
+AGENT_PACKAGE ?= skywalking-agent
 
 .PHONY: build
 build:
-	./mvnw --batch-mode clean package -Dmaven.test.skip=$(SKIP_TEST)
-
-.PHONY: docker
-docker: build
-	docker build --no-cache --build-arg BASE_IMAGE=$(BASE_IMAGE) . -t $(HUB)/$(NAME):$(TAG)
-
-.PHONY: docker.push
-docker.push: docker
-	docker push $(HUB)/$(NAME):$(TAG)
+	./mvnw --batch-mode clean package -Dmaven.test.skip=true
 
 .PHONY: dist
 dist: build
@@ -42,3 +31,23 @@ dist: build
 	gpg --armor --detach-sig apache-skywalking-java-agent-$(TAG).tgz
 	shasum -a 512 apache-skywalking-java-agent-$(TAG).tgz > apache-skywalking-java-agent-$(TAG).tgz.sha512
 
+# Docker build
+
+JAVA_VERSIONS := 8 11 12 13 14 15 16
+JAVA_VERSION = $(word 1, $@)
+
+.PHONY: $(JAVA_VERSIONS:%=java%)
+$(JAVA_VERSIONS:%=docker.java%): build
+	docker build --no-cache --build-arg BASE_IMAGE=adoptopenjdk/openjdk$(JAVA_VERSION:docker.java%=%):alpine-jre . -t $(HUB)/$(NAME):$(TAG)-$(JAVA_VERSION:docker.%=%)
+
+.PHONY: docker
+docker: $(JAVA_VERSIONS:%=docker.java%)
+
+# Docker push
+
+.PHONY: $(JAVA_VERSIONS:%=docker.push.java%)
+$(JAVA_VERSIONS:%=docker.push.java%): $(JAVA_VERSIONS:%=docker.java%)
+	docker build --no-cache --build-arg BASE_IMAGE=adoptopenjdk/openjdk$(JAVA_VERSION:docker.docker.java%=%):alpine-jre . -t $(HUB)/$(NAME):$(TAG)-$(JAVA_VERSION:docker.push.%=%)
+
+.PHONY: docker.push
+docker.push: $(JAVA_VERSIONS:%=docker.java%)
diff --git a/apm-commons/apm-util/src/main/java/org/apache/skywalking/apm/util/StringFormatGroup.java b/apm-commons/apm-util/src/main/java/org/apache/skywalking/apm/util/StringFormatGroup.java
deleted file mode 100644
index 9f22daf..0000000
--- a/apm-commons/apm-util/src/main/java/org/apache/skywalking/apm/util/StringFormatGroup.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.
- *
- */
-
-package org.apache.skywalking.apm.util;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.regex.Pattern;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import lombok.ToString;
-
-/**
- * Group patterns use {@link java.util.regex.Pattern} as core, could group the input strings to matched group or return
- * original string.
- */
-@ToString
-public class StringFormatGroup {
-    private final List<PatternRule> rules;
-
-    public StringFormatGroup() {
-        rules = new ArrayList<>();
-    }
-
-    /**
-     * Add a new match rule. The rule will follow the order of being added.
-     *
-     * @param name      will be used when ruleRegex matched.
-     * @param ruleRegex to match target string.
-     */
-    public void addRule(String name, String ruleRegex) {
-        for (PatternRule rule : rules) {
-            if (rule.name.equals(name)) {
-                return;
-            }
-        }
-        PatternRule rule = new PatternRule(name, ruleRegex);
-        rules.add(rule);
-    }
-
-    /**
-     * Format the string based on rules.
-     *
-     * @param string to be formatted
-     * @return matched rule name, or original string.
-     */
-    public FormatResult format(String string) {
-        for (PatternRule rule : rules) {
-            if (rule.getPattern().matcher(string).matches()) {
-                return new FormatResult(true, rule.getName(), string);
-            }
-        }
-        return new FormatResult(false, string, string);
-    }
-
-    public void sortRules(Comparator<? super PatternRule> comparator) {
-        rules.sort(comparator);
-    }
-
-    @Getter
-    @RequiredArgsConstructor
-    public static class FormatResult {
-        private final boolean match;
-        private final String name;
-        private final String replacedName;
-    }
-
-    @Getter
-    @ToString
-    public static class PatternRule {
-        private final String name;
-        private final Pattern pattern;
-
-        private PatternRule(String name, String ruleRegex) {
-            this.name = name;
-            pattern = Pattern.compile(ruleRegex);
-        }
-    }
-}
diff --git a/apm-commons/apm-util/src/test/java/org/apache/skywalking/apm/util/StringFormatGroupTest.java b/apm-commons/apm-util/src/test/java/org/apache/skywalking/apm/util/StringFormatGroupTest.java
deleted file mode 100644
index c573e54..0000000
--- a/apm-commons/apm-util/src/test/java/org/apache/skywalking/apm/util/StringFormatGroupTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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.
- *
- */
-
-package org.apache.skywalking.apm.util;
-
-import java.util.concurrent.TimeUnit;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openjdk.jmh.annotations.Benchmark;
-import org.openjdk.jmh.annotations.BenchmarkMode;
-import org.openjdk.jmh.annotations.Mode;
-import org.openjdk.jmh.annotations.OutputTimeUnit;
-import org.openjdk.jmh.runner.Runner;
-import org.openjdk.jmh.runner.RunnerException;
-import org.openjdk.jmh.runner.options.Options;
-import org.openjdk.jmh.runner.options.OptionsBuilder;
-
-public class StringFormatGroupTest {
-    @Benchmark
-    @Test
-    public void testMatch() {
-        StringFormatGroup group = new StringFormatGroup();
-        group.addRule("/name/*/add", "/name/.+/add");
-        Assert.assertEquals("/name/*/add", group.format("/name/test/add").getName());
-
-        group = new StringFormatGroup();
-        group.addRule("/name/*/add/{orderId}", "/name/.+/add/.*");
-        Assert.assertEquals("/name/*/add/{orderId}", group.format("/name/test/add/12323").getName());
-    }
-
-    @Benchmark
-    @Test
-    public void test100Rule() {
-        StringFormatGroup group = new StringFormatGroup();
-        group.addRule("/name/*/add/{orderId}", "/name/.+/add/.*");
-        for (int i = 0; i < 100; i++) {
-            group.addRule("/name/*/add/{orderId}" + "/" + 1, "/name/.+/add/.*" + "/abc");
-        }
-        Assert.assertEquals("/name/*/add/{orderId}", group.format("/name/test/add/12323").getName());
-    }
-
-    /**
-     * The report below shows this pattern match performance is much about rule numbers. This is a single thread test.
-     */
-    @BenchmarkMode(Mode.AverageTime)
-    @OutputTimeUnit(TimeUnit.MICROSECONDS)
-    public void performanceBenchmark() throws RunnerException {
-        Options opt = new OptionsBuilder().include(StringFormatGroupTest.class.getSimpleName())
-                                          .forks(1)
-                                          .warmupIterations(0)
-                                          .measurementIterations(5)
-                                          .build();
-
-        new Runner(opt).run();
-    }
-
-    /*********************************
-     * # JMH version: 1.21
-     * # VM version: JDK 1.8.0_91, Java HotSpot(TM) 64-Bit Server VM, 25.91-b14
-     * # VM invoker: /Users/wusheng/Documents/applications/jdk1.8.0_91.jdk/Contents/Home/jre/bin/java
-     * # VM options: -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=54841:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8
-     * # Warmup: <none>
-     * # Measurement: 5 iterations, 10 s each
-     * # Timeout: 10 min per iteration
-     * # Threads: 1 thread, will synchronize iterations
-     * # Benchmark mode: Throughput, ops/time
-     * # Benchmark: org.apache.skywalking.apm.util.StringFormatGroupTest.test100Rule
-     *
-     * # Run progress: 0.00% complete, ETA 00:01:40
-     * # Fork: 1 of 1
-     * Iteration   1: 32016.496 ops/s
-     * Iteration   2: 36703.873 ops/s
-     * Iteration   3: 37121.543 ops/s
-     * Iteration   4: 36898.225 ops/s
-     * Iteration   5: 34712.564 ops/s
-     *
-     *
-     * Result "org.apache.skywalking.apm.util.StringFormatGroupTest.test100Rule":
-     *   35490.540 ±(99.9%) 8345.368 ops/s [Average]
-     *   (min, avg, max) = (32016.496, 35490.540, 37121.543), stdev = 2167.265
-     *   CI (99.9%): [27145.173, 43835.908] (assumes normal distribution)
-     *
-     *
-     * # JMH version: 1.21
-     * # VM version: JDK 1.8.0_91, Java HotSpot(TM) 64-Bit Server VM, 25.91-b14
-     * # VM invoker: /Users/wusheng/Documents/applications/jdk1.8.0_91.jdk/Contents/Home/jre/bin/java
-     * # VM options: -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=54841:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8
-     * # Warmup: <none>
-     * # Measurement: 5 iterations, 10 s each
-     * # Timeout: 10 min per iteration
-     * # Threads: 1 thread, will synchronize iterations
-     * # Benchmark mode: Throughput, ops/time
-     * # Benchmark: org.apache.skywalking.apm.util.StringFormatGroupTest.testMatch
-     *
-     * # Run progress: 50.00% complete, ETA 00:00:50
-     * # Fork: 1 of 1
-     * Iteration   1: 1137158.205 ops/s
-     * Iteration   2: 1192936.161 ops/s
-     * Iteration   3: 1218773.403 ops/s
-     * Iteration   4: 1222966.452 ops/s
-     * Iteration   5: 1235609.354 ops/s
-     *
-     *
-     * Result "org.apache.skywalking.apm.util.StringFormatGroupTest.testMatch":
-     *   1201488.715 ±(99.9%) 150813.461 ops/s [Average]
-     *   (min, avg, max) = (1137158.205, 1201488.715, 1235609.354), stdev = 39165.777
-     *   CI (99.9%): [1050675.254, 1352302.176] (assumes normal distribution)
-     *
-     *
-     * # Run complete. Total time: 00:01:41
-     *
-     * REMEMBER: The numbers below are just data. To gain reusable insights, you need to follow up on
-     * why the numbers are the way they are. Use profilers (see -prof, -lprof), design factorial
-     * experiments, perform baseline and negative tests that provide experimental control, make sure
-     * the benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the domain experts.
-     * Do not assume the numbers tell you what you want them to tell.
-     *
-     * Benchmark                           Mode  Cnt        Score        Error  Units
-     * StringFormatGroupTest.test100Rule  thrpt    5    35490.540 ±   8345.368  ops/s
-     * StringFormatGroupTest.testMatch    thrpt    5  1201488.715 ± 150813.461  ops/s
-     *
-     */
-}
diff --git a/docs/en/contribution/release-java-agent.md b/docs/en/contribution/release-java-agent.md
index ab3a292..918b88b 100644
--- a/docs/en/contribution/release-java-agent.md
+++ b/docs/en/contribution/release-java-agent.md
@@ -267,6 +267,22 @@ SkyWalking Resources:
 - Apache SkyWalking Team
 ```
 
+## Release Docker images
+
+```shell
+export SW_VERSION=x.y.z
+git clone --depth 1 --branch v$SW_VERSION https://github.com/apache/skywalking-java.git
+cd skywalking-java
+
+svn co https://dist.apache.org/repos/dist/release/skywalking-java/$SW_VERSION release # (1)
+
+export SW_OUT=release
+export HUB=apache
+export TAG=$SW_VERSION
+export DIST=<the binary package name inside (1), e.g. apache-skywalking-apm-8.8.0.tar.gz>
+make docker.all && make docker.push
+```
+
 ## Clean up the old releases
 Once the latest release has been published, you should clean up the old releases from the mirror system.
 1. Update the download links (source, dist, asc, and sha512) on the website to the archive repo (https://archive.apache.org/dist/skywalking).