Skip to content

Commit

Permalink
add dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLMS committed Aug 7, 2024
1 parent 5b08fae commit b06887f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
17 changes: 17 additions & 0 deletions aphra/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
28 changes: 28 additions & 0 deletions aphra/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Verify that the correct number of arguments have been passed
if [ "$#" -ne 4 ]; then
echo "Usage: $0 <source_language> <target_language> <input_file> <output_file>"
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."

0 comments on commit b06887f

Please sign in to comment.