Skip to content

Commit

Permalink
Merge Dockerfiles in apache/skywalking-docker into this codebase (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
kezhenxu94 authored Sep 9, 2021
1 parent 02458cb commit f61dff9
Show file tree
Hide file tree
Showing 17 changed files with 293 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e.jdk-versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
timeout-minutes: 90
strategy:
matrix:
jdk: [ 8, 9, 10, 11, 12, 13, 14, 15 ]
jdk: [ 8, 11, 12, 13, 14, 15 ]
env:
SW_SIMPLE_CASE: jdk
SW_AGENT_JDK_VERSION: ${{ matrix.jdk }}
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Release Notes.
#### Project

* Split javaagent into skywalking-java repository. https://github.com/apache/skywalking-java
* Merge `Dockerfile`s from apache/skywalking-docker into this codebase.

#### OAP Server

Expand Down
24 changes: 11 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@

SHELL := /bin/bash -o pipefail

export SW_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

export SW_OUT:=${SW_ROOT}/dist

SKIP_TEST?=false
DIST_NAME := apache-skywalking-apm-bin
SW_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
CONTEXT ?= ${SW_ROOT}/dist
SKIP_TEST ?= false
DIST ?= apache-skywalking-apm-bin.tar.gz
CLI_VERSION ?= 0.7.0 # CLI version inside OAP image should always use an Apache released artifact.

init:
cd $(SW_ROOT) && git submodule update --init --recursive
Expand All @@ -37,11 +36,10 @@ build.backend:
build.ui:
cd $(SW_ROOT) && ./mvnw --batch-mode clean package -Dmaven.test.skip=$(SKIP_TEST) -Pui,dist

DOCKER_BUILD_TOP:=${SW_OUT}/docker_build

HUB?=skywalking
DOCKER_BUILD_TOP:=${CONTEXT}/docker_build

TAG?=latest
HUB ?= skywalking
TAG ?= latest

.SECONDEXPANSION: #allow $@ to be used in dependency list

Expand All @@ -57,15 +55,15 @@ ifneq ($(SW_OAP_BASE_IMAGE),)
BUILD_ARGS := $(BUILD_ARGS) --build-arg BASE_IMAGE=$(SW_OAP_BASE_IMAGE)
endif

BUILD_ARGS := $(BUILD_ARGS) --build-arg DIST_NAME=$(DIST_NAME)
BUILD_ARGS := $(BUILD_ARGS) --build-arg DIST=$(DIST) --build-arg SKYWALKING_CLI_VERSION=$(CLI_VERSION)

docker.oap: $(SW_OUT)/$(DIST_NAME).tar.gz
docker.oap: $(CONTEXT)/$(DIST)
docker.oap: $(SW_ROOT)/docker/oap/Dockerfile.oap
docker.oap: $(SW_ROOT)/docker/oap/docker-entrypoint.sh
docker.oap: $(SW_ROOT)/docker/oap/log4j2.xml
$(DOCKER_RULE)

docker.ui: $(SW_OUT)/apache-skywalking-apm-bin.tar.gz
docker.ui: $(CONTEXT)/$(DIST)
docker.ui: $(SW_ROOT)/docker/ui/Dockerfile.ui
docker.ui: $(SW_ROOT)/docker/ui/docker-entrypoint.sh
docker.ui: $(SW_ROOT)/docker/ui/logback.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public enum PropertyPlaceholderHelper {
throw new UnsupportedOperationException("'placeholderPrefix or placeholderSuffix' must not be null");
}

final Map<String, String> wellKnownSimplePrefixes = new HashMap<String, String>(4);
final Map<String, String> wellKnownSimplePrefixes = new HashMap<>(4);

wellKnownSimplePrefixes.put("}", "{");
wellKnownSimplePrefixes.put("]", "[");
Expand All @@ -90,12 +90,9 @@ public enum PropertyPlaceholderHelper {
* @return the supplied value with placeholders replaced inline
*/
public String replacePlaceholders(String value, final Properties properties) {
return replacePlaceholders(value, new PlaceholderResolver() {
@Override
public String resolvePlaceholder(String placeholderName) {
return getConfigValue(placeholderName, properties);
}
});
return replacePlaceholders(value,
placeholderName -> getConfigValue(placeholderName, properties)
);
}

private String getConfigValue(String key, final Properties properties) {
Expand Down
4 changes: 3 additions & 1 deletion docker/.env
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
ES_TAG=7.4.2
ES_VERSION=7.4.2
OAP_IMAGE=skywalking/oap:latest
UI_IMAGE=skywalking/ui:latest
44 changes: 34 additions & 10 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,63 @@
This folder contains Docker files for SkyWalking developers/committers to build images manually. If you want to start a SkyWalking backend server with docker-compose for your integration, please visit https://github.com/apache/skywalking-docker repository.
# Docker Images

This folder contains Dockerfiles that are used to **build**
our [OAP Docker images](https://hub.docker.com/r/apache/skywalking-oap-server)
and [UI Docker image](https://hub.docker.com/r/apache/skywalking-ui). If you want to use the Docker images, please
check [the user guide for OAP](../docs/en/setup/backend/docker.md)
and [the user guide for UI](../docs/en/setup/backend/ui-setup.md#start-with-docker-image).

## Quickstart

You can use `Makefile` located at the root folder to build a docker image with the current codebase.

```
```shell
make docker
```

It doesn't contain the process of building a docker image but also includes all the required steps, for instance, init workspace, build artifact from scratch. It builds two images, OAP, and UI.
It not only contains the process of building a docker image but also includes all the required steps, for instance, init
workspace, build artifact from scratch. It builds two images, OAP, and UI.

```
```shell
docker image ls | grep skywalking
skywalking/ui latest a14db4e1d70d 6 minutes ago 800MB
skywalking/oap latest 2a6084450b44 6 minutes ago 862MB
```


## Building variables

There're some environment variables to control image building.
There are some environment variables to control image building.

### `CONTEXT`

The Docker build context path, under this path, there should be the distribution tar ball.

```shell
ls $CONTEXT
apache-skywalking-apm-bin.tar.gz
```

### `DIST`

The distribution tar ball name, for example, `apache-skywalking-apm-bin.tar.gz`.

### `CLI_VERSION`

### HUB
The [SkyWalking CLI](http://github.com/apache/skywalking-cli) version to be included in the OAP image, it must be an
official Apache release version.

### `HUB`

The hub of docker image. The default value is `skywalking`.

### TAG
### `TAG`

The tag of docker image. The default value is `latest`.

## Running containers with docker-compose

We can start up backend cluster by docker-compose
```
cd docker

```shell
docker compose up
```

Expand Down
50 changes: 30 additions & 20 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,51 +14,61 @@
# See the License for the specific language governing permissions and
# limitations under the License.

version: '3.5'
version: '3.8'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:${ES_TAG}
image: docker.elastic.co/elasticsearch/elasticsearch-oss:${ES_VERSION}
container_name: elasticsearch
restart: always
ports:
- 9200:9200
- "9200:9200"
healthcheck:
test: [ "CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1" ]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
environment:
discovery.type: single-node
- discovery.type=single-node
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1

oap:
image: skywalking/oap
image: ${OAP_IMAGE}
container_name: oap
depends_on:
- elasticsearch
elasticsearch:
condition: service_healthy
links:
- elasticsearch
restart: always
ports:
- 11800:11800
- 12800:12800
- "11800:11800"
- "12800:12800"
healthcheck:
test: [ "CMD-SHELL", "/skywalking/bin/swctl ch" ]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
environment:
SW_STORAGE: elasticsearch
SW_STORAGE_ES_CLUSTER_NODES: elasticsearch:9200
SW_HEALTH_CHECKER: default
SW_TELEMETRY: prometheus
healthcheck:
test: ["CMD", "./bin/swctl", "ch"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
JAVA_OPTS: "-Xms2048m -Xmx2048m"

ui:
image: skywalking/ui
image: ${UI_IMAGE}
container_name: ui
depends_on:
- oap
oap:
condition: service_healthy
links:
- oap
restart: always
ports:
- 8080:8080
- "8080:8080"
environment:
SW_OAP_ADDRESS: http://oap:12800
109 changes: 93 additions & 16 deletions docker/oap/Dockerfile.oap
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,113 @@
# See the License for the specific language governing permissions and
# limitations under the License.

ARG BASE_IMAGE='adoptopenjdk/openjdk11:alpine-jre'
ARG BASE_IMAGE='adoptopenjdk/openjdk11:alpine'

FROM apache/skywalking-base:8.7.0-es7 AS cli
FROM $BASE_IMAGE as cli

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

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

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 || true
RUN apk add --no-cache openssl

ENV JAVA_OPTS=" -Xms256M " \
SW_CLUSTER="standalone" \
SW_STORAGE="h2"
WORKDIR /skywalking

ARG DIST_NAME
ENV JAVA_OPTS=" -Xms2G "

COPY "$DIST_NAME.tar.gz" /
ARG DIST

RUN set -ex; \
tar -xzf "$DIST_NAME.tar.gz"; \
rm -rf "$DIST_NAME.tar.gz"; \
rm -rf "$DIST_NAME/config/log4j2.xml"; \
rm -rf "$DIST_NAME/bin"; rm -rf "$DIST_NAME/webapp"; rm -rf "$DIST_NAME/agent"; \
mkdir "$DIST_NAME/bin"; \
mv "$DIST_NAME" skywalking;
COPY "$DIST" .

WORKDIR skywalking
RUN set -ex; \
tar -xzf "$DIST" --strip 1; \
rm -rf "$DIST"; \
rm -rf "config/log4j2.xml"; \
rm -rf "bin"; \
rm -rf "webapp"; \
rm -rf "agent"; \
mkdir "bin";

COPY --from=cli /skywalking/bin/swctl ./bin

COPY log4j2.xml config/
COPY docker-entrypoint.sh .

RUN mkdir ext-config; \
mkdir ext-libs;

Expand Down
Loading

0 comments on commit f61dff9

Please sign in to comment.