#
# SnapLogic - Data Integration
#
# Copyright (C) 2018, SnapLogic, Inc.  All rights reserved.
#
# This program is licensed under the terms of
# the SnapLogic Commercial Subscription agreement.
#
# "SnapLogic" is a trademark of SnapLogic, Inc.

# This is the dockerfile for SnapLogic Python Server
#

FROM ubuntu:20.04

ENV REMOTE_PYTHON_EXECUTOR_DIR="/opt/remote_python_executor_data/"
ENV REMOTE_PYTHON_EXECUTOR_CRT="/opt/remote_python_executor_data/remote_python_executor.crt"
ENV REMOTE_PYTHON_EXECUTOR_KEY="/opt/remote_python_executor_data/remote_python_executor.key"
ENV REMOTE_PYTHON_EXECUTOR_LOG="/opt/remote_python_executor_log/remote_python_executor.log"
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y \
    software-properties-common \
    curl
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update && apt-get install -y \
    python3.8 \
    python3-pip

COPY requirements.txt /tmp/
RUN pip install --no-cache-dir -r /tmp/requirements.txt && rm -f /tmp/requirements.txt

RUN mkdir -p $REMOTE_PYTHON_EXECUTOR_DIR
COPY run.sh remote_python_executor.py $REMOTE_PYTHON_EXECUTOR_DIR

RUN openssl req -x509 -newkey rsa:4096 -sha256 -nodes \
    -keyout $REMOTE_PYTHON_EXECUTOR_KEY \
    -out $REMOTE_PYTHON_EXECUTOR_CRT -subj "/CN=dev.snaplogic.com" -days 10950

CMD ${REMOTE_PYTHON_EXECUTOR_DIR}run.sh
