diff --git a/src/Tre-SQL-Trino/Dockerfile b/src/Tre-SQL-Trino/Dockerfile index 01a63efb8..dc68aab17 100644 --- a/src/Tre-SQL-Trino/Dockerfile +++ b/src/Tre-SQL-Trino/Dockerfile @@ -10,28 +10,26 @@ FROM trinodb/trino:422 # apt-get remove -y wget && \ # apt-get clean + # Set working directory WORKDIR /workspace USER root:root -# Copy entrypoint script -#COPY entrypoint.sh /usr/local/bin/entrypoint.sh - -# Make entrypoint script executable -#RUN chmod +x /usr/local/bin/entrypoint.sh - -# Set entrypoint -#ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] - +RUN mkdir -p /data && chown trino:trino /data +RUN chown trino:trino /workspace # Copy entrypoint script -COPY entrypoint.sh /home/trino/entrypoint.sh +COPY entrypoint.sh /workspace/entrypoint.sh +COPY entrypoint.sh /workspace/runsql.sh # Make entrypoint script executable -RUN chmod +x /home/trino/entrypoint.sh +RUN chmod +x /workspace/entrypoint.sh +RUN chmod +x /workspace/runsql.sh USER trino:trino +RUN mkdir -p /workspace/data + # Set entrypoint -ENTRYPOINT ["/home/trino/entrypoint.sh"] +ENTRYPOINT ["/workspace/entrypoint.sh"] diff --git a/src/Tre-SQL-Trino/entrypoint.sh b/src/Tre-SQL-Trino/entrypoint.sh index ea346a1ae..ad0cc0b04 100644 --- a/src/Tre-SQL-Trino/entrypoint.sh +++ b/src/Tre-SQL-Trino/entrypoint.sh @@ -1,14 +1,18 @@ #!/bin/bash +if [[ -z "$TRINO_SERVER_URL" ]]; then + export TRINO_SERVER_URL="http://192.168.70.92:8090" +fi + +if [[ -z "$LOCATION" ]]; then + export LOCATION="/workspace/data/result.csv" +fi + # Check if required environment variables are provided -if [[ -z "$TRINO_SERVER_URL" || -z "$SQL_STATEMENT" ]]; then - echo "Please provide TRINO_SERVER_URL and SQL_STATEMENT environment variables." +if [[ -z "$SQL_STATEMENT" ]]; then + echo "SQL_STATEMENT environment variables." exit 1 fi - # Execute Trino CLI command to run SQL statement and output CSV -trino --server "$TRINO_SERVER_URL" --execute "$SQL_STATEMENT" --output-format CSV > ~/result.csv - -ls -la ~/ - +trino --server "$TRINO_SERVER_URL" --execute "$SQL_STATEMENT" --output-format CSV > $LOCATION