Skip to content

Commit 5f9d967

Browse files
author
John Plaisted
authored
fix: ingestion docker image (#2027)
The environment was not set correctly, so it could not fire kafka events. It (mce-cli) always worked when running outside of docker. I also added a dev ingestion docker image / script which may be much faster if you've already built locally. Tested: 1. Cleaned docker volumes and started datahub. Verified it is empty. 2. Built with gradle. 3. Ran ./docker/ingestion/ingestion-dev.sh. Verified data shows in DataHub. 4. Ran step 1 again. 5. Ran ./docker/ingestion/ingestion.sh. Verified data shows in DataHub.
1 parent a1e7e26 commit 5f9d967

File tree

6 files changed

+51
-6
lines changed

6 files changed

+51
-6
lines changed

docker/ingestion/Dockerfile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
FROM openjdk:8 as builder
1+
# Defining environment
2+
ARG APP_ENV=prod
3+
4+
FROM openjdk:8-jre-alpine as base
5+
6+
FROM openjdk:8 as prod-build
27
COPY . datahub-src
38
RUN cd datahub-src && ./gradlew :metadata-ingestion-examples:mce-cli:build
49

5-
FROM openjdk:8-jre-alpine
6-
COPY --from=builder datahub-src/metadata-ingestion-examples/mce-cli/build/libs/mce-cli.jar ./
7-
COPY --from=builder datahub-src/metadata-ingestion-examples/mce-cli/example-bootstrap.json ./
8-
CMD java -jar mce-cli.jar -m produce example-bootstrap.json
10+
FROM base as prod-install
11+
COPY --from=prod-build datahub-src/metadata-ingestion-examples/mce-cli/build/libs/mce-cli.jar /datahub/ingestion/bin/mce-cli.jar
12+
COPY --from=prod-build datahub-src/metadata-ingestion-examples/mce-cli/example-bootstrap.json /datahub/ingestion/example-bootstrap.json
13+
14+
FROM base as dev-install
15+
# Dummy stage for development. Assumes code is built on your machine and mounted to this image.
16+
# See this excellent thread https://github.com/docker/cli/issues/1134
17+
18+
FROM ${APP_ENV}-install as final
19+
CMD java -jar /datahub/ingestion/bin/mce-cli.jar -m produce /datahub/ingestion/example-bootstrap.json
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
version: '3.5'
3+
services:
4+
ingestion:
5+
image: datahub-ingestion:debug
6+
env_file: env/docker.env
7+
build:
8+
context: .
9+
dockerfile: Dockerfile
10+
args:
11+
APP_ENV: dev
12+
volumes:
13+
- ../../metadata-ingestion-examples/mce-cli/build/libs/:/datahub/ingestion/bin
14+
- ../../metadata-ingestion-examples/mce-cli/example-bootstrap.json:/datahub/ingestion/example-bootstrap.json
15+
16+
networks:
17+
default:
18+
name: datahub_network

docker/ingestion/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version: '3.5'
33
services:
44
ingestion:
55
image: datahub-ingestion
6+
env_file: env/docker.env
67
build:
78
context: ../../
89
dockerfile: docker/ingestion/Dockerfile

docker/ingestion/env/docker.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
KAFKA_BOOTSTRAP_SERVER=broker:29092
2+
KAFKA_SCHEMAREGISTRY_URL=http://schema-registry:8081

docker/ingestion/ingestion-dev.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
# Runs the ingestion image using your locally built mce-cli. Gradle build must have been run before this script.
4+
5+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6+
cd $DIR && COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose -f docker-compose.dev.yml -p datahub up

metadata-ingestion-examples/mce-cli/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,11 @@ java -jar metadata-ingestion-examples/mce-cli/build/libs/mce-cli.jar -m produce
4848
```
4949

5050
Where `my-file.json` is some file that contains a
51-
[MetadataChangEvents](./src/main/pegasus/com/linkedin/metadata/examples/cli/MetadataChangeEvents.pdl) JSON object.
51+
[MetadataChangEvents](./src/main/pegasus/com/linkedin/metadata/examples/cli/MetadataChangeEvents.pdl) JSON object.
52+
53+
### Producing the Example Events with Docker
54+
55+
We have some example events in the `example-bootstrap.json` file, which can be invoked via the above example or in a
56+
docker environment using `docker/ingestion/ingestion.sh`. We also have a developer image
57+
(`docker/ingestion/ingestion-dev.sh`) which uses your locally built jar rather than building on the docker image itself,
58+
which may be faster if you have already built code locally.

0 commit comments

Comments
 (0)