diff --git a/aphra/Dockerfile b/aphra/Dockerfile new file mode 100644 index 0000000..fdb8445 --- /dev/null +++ b/aphra/Dockerfile @@ -0,0 +1,17 @@ +FROM python:3.8-slim + +WORKDIR /app + +COPY requirements.txt ./ +COPY setup.py ./ +COPY config.example.toml ./config.toml + +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +COPY entrypoint.sh ./ + +RUN chmod +x entrypoint.sh + +ENTRYPOINT ["./entrypoint.sh"] \ No newline at end of file diff --git a/aphra/entrypoint.sh b/aphra/entrypoint.sh new file mode 100644 index 0000000..52d7b9b --- /dev/null +++ b/aphra/entrypoint.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Verify that the correct number of arguments have been passed +if [ "$#" -ne 4 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Assign arguments to variables +SOURCE_LANGUAGE=$1 +TARGET_LANGUAGE=$2 +INPUT_FILE=$3 +OUTPUT_FILE=$4 + +# Read the content of the input file +TEXT=$(cat "$INPUT_FILE") + +# Execute the translation +TRANSLATION=$(python -c " +from aphra import translate +result = translate('$SOURCE_LANGUAGE', '$TARGET_LANGUAGE', '''$TEXT''', config_file='config.toml') +print(result) +") + +# Save the translation to the output file +echo "$TRANSLATION" > "$OUTPUT_FILE" + +echo "Translation completed. See file $OUTPUT_FILE for the result." \ No newline at end of file