FROM 086679231553.dkr.ecr.us-east-1.amazonaws.com/docker-parent-images:kafka-connect77

USER root

RUN yum install unzip -y

# From https://github.com/streamthoughts/kafka-connect-file-pulse
ENV S3_CONNECTOR_VERSION=2.16.0
RUN mkdir /usr/share/plugins && \
    wget -O /usr/share/plugins/streamthoughts-kafka-connect-file-pulse-2.16.0.zip https://github.com/streamthoughts/kafka-connect-file-pulse/releases/download/v2.16.0/streamthoughts-kafka-connect-file-pulse-2.16.0.zip \
    && unzip -d /usr/share/plugins /usr/share/plugins/streamthoughts-kafka-connect-file-pulse-2.16.0.zip

COPY entry_point.sh /usr/local/bin/entry_point.sh
RUN chmod +x /usr/local/bin/entry_point.sh

USER appuser

# Add the config file
COPY config.template.json /tmp/

# Generic Kafka-connect config
ENV CONNECTOR_NAME='s3_pulse_source'
ENV CONNECT_KEY_CONVERTER='org.apache.kafka.connect.storage.StringConverter'
ENV CONNECT_VALUE_CONVERTER='org.apache.kafka.connect.json.JsonConverter'
ENV CONNECT_PLUGIN_PATH='/usr/share/java,/usr/share/confluent-hub-components/,/usr/share/plugins/'
ENV KAFKA_PRODUCER_MAX_REQUEST_SIZE=15728640
ENV CONNECT_PRODUCER_MAX_REQUEST_SIZE=15728640
ENV KAFKA_S3_REGION='us-east-1'
# folder name in bucket where files are located
ENV KAFKA_S3_BUCKET_OBJECT_PREFIX='kafka_incoming'
ENV KAFKA_S3_FILE_EXTENSION="json"
ENV SKIP_HEADER_ROWS="0"
# other options: move, delete . Ref: https://streamthoughts.github.io/kafka-connect-file-pulse/docs/developer-guide/cleaning-completed-files/
ENV KAFKA_S3_ACTION_AFTER_READ='delete'
# uniquely identifying an object file in S3, so they dont get re-read. If you dont want to re-read files with same name ever, use 'uri' only.
ENV KAFKA_S3_STATUS_IDENTIFIER='uri+lastModified'
# Field to use for kafka message key value. Eg: $value.globalParticipantUuid
ENV KAFKA_MESSAGE_KEY_FIELDNAME=''
# In case you want to rename a field from the input json to another field name in the output json, use these two vars.
ENV KAFKA_MESSAGE_RENAME_TO_FIELDNAME=''
ENV KAFKA_MESSAGE_RENAME_FROM_FIELDNAME=''

EXPOSE ${CONNECT_REST_PORT}

ENTRYPOINT  ["/usr/local/bin/entry_point.sh"]

#FORCE REDEPLOY:1
