Add Java agent Dockerfile and build / push script (#17)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..485dee6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.idea
diff --git a/Makefile b/Makefile
index 5df0fd5..5dd813e 100644
--- a/Makefile
+++ b/Makefile
@@ -25,7 +25,7 @@
 OAP_BUILD_TARGETS := $(TAG_SUFS:%=oap-server.%)
 COMPLEX_BUILD_TARGETS := $(BASE_BUILD_TARGETS) $(OAP_BUILD_TARGETS)
 COMPOSE_TARGETS := $(TAG_SUFS:%=compose.%)
-BUILD_TARGETS := $(COMPLEX_BUILD_TARGETS) ui
+BUILD_TARGETS := $(COMPLEX_BUILD_TARGETS) ui java-agent
 
 word-dot = $(word $2,$(subst ., ,$1))
 
@@ -46,6 +46,11 @@
 	&& $(D) tag apache/skywalking-ui:$(SW_VERSION) apache/skywalking-ui:latest \
 	&& popd
 
+
+java-agent:
+	$(MAKE) -C java-agent build
+
+
 $(COMPOSE_TARGETS):
 	@echo "Booting $@"
 	$(eval imgTag := $(subst compose.,,$@))
@@ -60,6 +65,9 @@
 	$(D) push apache/skywalking-ui:$(SW_VERSION) \
 	&& $(D) push  apache/skywalking-ui:latest
 
+push.java-agent:
+	$(MAKE) -C java-agent push
+
 PUSH_TARGETS:=
 $(foreach TGT,$(BUILD_TARGETS),$(eval PUSH_TARGETS+=push.$(TGT)))
 
diff --git a/java-agent/Dockerfile b/java-agent/Dockerfile
new file mode 100644
index 0000000..42fe903
--- /dev/null
+++ b/java-agent/Dockerfile
@@ -0,0 +1,32 @@
+# 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.
+
+ARG version
+
+ARG BASE_IMAGE='adoptopenjdk/openjdk8:alpine'
+
+FROM apache/skywalking-base:${version}-es6 AS build
+
+FROM $BASE_IMAGE
+
+LABEL maintainer="kezhenxu94@apache.org"
+
+ENV JAVA_TOOL_OPTIONS=-javaagent:/skywalking/agent/skywalking-agent.jar
+
+WORKDIR /skywalking
+
+COPY --from=build /skywalking/agent /skywalking/agent
+COPY --from=build /skywalking/bin/swctl /skywalking/bin/swctl
diff --git a/java-agent/Makefile b/java-agent/Makefile
new file mode 100644
index 0000000..38a9d13
--- /dev/null
+++ b/java-agent/Makefile
@@ -0,0 +1,43 @@
+# 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.
+
+D := docker
+
+TARGETS := alpine jdk8 jdk11
+PUSH_TARGETS := $(TARGETS:%=push.%)
+
+word-dot = $(word $2,$(subst ., ,$1))
+
+build: $(TARGETS)
+push: $(PUSH_TARGETS)
+
+$(TARGETS):
+	$(D) build $(SW_BUILD_ARGS) \
+	--build-arg version=$(SW_VERSION) \
+	--build-arg BASE_IMAGE=$(BASE_IMAGE) \
+	--build-arg tag=$@ \
+	-t apache/skywalking-java-agent:${SW_VERSION}-$@ \
+	.
+
+$(PUSH_TARGETS):
+	$(eval version := $(call word-dot,$@,2))
+	@(D) push apache/skywalking-java-agent:${SW_VERSION}-$(version) \
+
+alpine: BASE_IMAGE=alpine
+
+jdk8: BASE_IMAGE=adoptopenjdk/openjdk8:alpine
+
+jdk11: BASE_IMAGE=adoptopenjdk/openjdk11:alpine
diff --git a/java-agent/README.md b/java-agent/README.md
new file mode 100644
index 0000000..af6c0f7
--- /dev/null
+++ b/java-agent/README.md
@@ -0,0 +1,69 @@
+# Apache SkyWalking Agent docker file
+
+**Docker images are not official ASF releases but provided for convenience. Recommended usage is always to build the
+source**
+
+<img src="http://skywalking.apache.org/assets/logo.svg" alt="Sky Walking logo" height="90px" align="right" />
+
+**SkyWalking**: an APM(application performance monitor) system, especially designed for microservices, cloud native and
+container-based (Docker, Kubernetes, Mesos) architectures.
+
+[![GitHub stars](https://img.shields.io/github/stars/apache/skywalking.svg?style=for-the-badge&label=Stars&logo=github)](https://github.com/apache/skywalking)
+[![Twitter Follow](https://img.shields.io/twitter/follow/asfskywalking.svg?style=for-the-badge&label=Follow&logo=twitter)](https://twitter.com/AsfSkyWalking)
+
+You could find docker file at [here](https://github.com/apache/skywalking-docker)
+
+This image only hosts the pre-built SkyWalking Java agent jars, and provides some convenient configurations for
+containerization scenarios.
+
+# How to use this image
+
+## Build your Java application image on top of this image
+
+```dockerfile
+FROM apache/skywalking-java-agent:8.5.0-jdk8
+
+# ... build your java application
+```
+
+You can start your Java application with `CMD` or `ENTRYPOINT`, but you don't need to care about the Java options to
+enable SkyWalking agent, it should be adopted automatically.
+
+## Use this image as sidecar of Kubernetes service
+
+In Kubernetes scenarios, you can also use this agent image as a sidecar.
+
+```yaml
+apiVersion: v1
+kind: Pod
+metadata:
+  name: agent-as-sidecar
+spec:
+  restartPolicy: Never
+
+  volumes:
+    - name: skywalking-agent
+      emptyDir: { }
+
+  containers:
+    - name: agent-container
+      image: apache/skywalking-java-agent:8.4.0-alpine
+      volumeMounts:
+        - name: skywalking-agent
+          mountPath: /agent
+      command: [ "/bin/sh" ]
+      args: [ "-c", "cp -R /skywalking/agent /agent/" ]
+
+    - name: app-container
+      image: springio/gs-spring-boot-docker
+      volumeMounts:
+        - name: skywalking-agent
+          mountPath: /skywalking
+      env:
+        - name: JAVA_TOOL_OPTIONS
+          value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
+```
+
+# License
+
+[Apache 2.0 License.](/LICENSE)