yzevm / sync-postgresql-with-elasticsearch-example

🔄 Sync PostgreSQL to Elasticsearch via Debezium
95 stars 22 forks source link

Better Dockerfile #7

Closed unikzforce closed 11 months ago

unikzforce commented 4 years ago

would you please change the Dockerfile to this: (multi staged Dockerfile)


FROM maven:3.5.2-jdk-8-alpine AS MAVEN_TOOL_CHAIN
COPY pom.xml /tmp/
WORKDIR /tmp/
RUN mvn install dependency:copy-dependencies

#https://raw.githubusercontent.com/debezium/debezium-examples/master/unwrap-smt/debezium-jdbc-es/Dockerfile

FROM debezium/connect:1.0

ENV KAFKA_CONNECT_ES_DIR=$KAFKA_CONNECT_PLUGINS_DIR/kafka-connect-elasticsearch/

# Deploy Confluent Elasticsearch sink connector
RUN mkdir $KAFKA_CONNECT_ES_DIR
COPY --from=MAVEN_TOOL_CHAIN /tmp/target/dependency/* $KAFKA_CONNECT_ES_DIR

the pom file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <groupId>nl.amis.streams.countries</groupId>
  <artifactId>Country-Events-Analyzer</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>

  <repositories>
    <repository>
      <id>confluent</id>
      <url>http://packages.confluent.io/maven/</url>
    </repository>
  </repositories>

  <dependencies>
     <dependency>
      <groupId>io.confluent</groupId>
      <artifactId>kafka-connect-elasticsearch</artifactId>
      <version>5.5.0</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

It's far easier to manager and change the versions

unikzforce commented 4 years ago

off course I've omitted the postgresql for making it more simple for my own purpose.