diff --git a/deployment/api/.dockerignore b/deployment/api/.dockerignore index d21e03a..3b1b7b4 100644 --- a/deployment/api/.dockerignore +++ b/deployment/api/.dockerignore @@ -17,4 +17,6 @@ tests/ *aws* .elasticbeanstalk -sentiment-api-465411-ccfc3af56be7.json +sentiment-api-*.json + +docker-compose.yml.example diff --git a/deployment/api/.gitignore b/deployment/api/.gitignore index 534953e..d65a5bd 100644 --- a/deployment/api/.gitignore +++ b/deployment/api/.gitignore @@ -9,4 +9,4 @@ *aws* -sentiment-api-465411-ccfc3af56be7.json +sentiment-api-*.json diff --git a/deployment/api/Dockerfile b/deployment/api/Dockerfile index 2a0847b..4ecb683 100644 --- a/deployment/api/Dockerfile +++ b/deployment/api/Dockerfile @@ -15,6 +15,14 @@ RUN apt-get update && \ COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt +# Install nltk resources at build time +RUN python3 -m nltk.downloader punkt \ + && python3 -m nltk.downloader punkt_tab \ + && python3 -m nltk.downloader stopwords \ + && python3 -m nltk.downloader wordnet \ + && python3 -m nltk.downloader omw-1.4 + + # Copy app code and configs COPY . . diff --git a/deployment/api/Dockerrun.aws.json b/deployment/api/Dockerrun.aws.json deleted file mode 100644 index 1cdac16..0000000 --- a/deployment/api/Dockerrun.aws.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "AWSEBDockerrunVersion": "1", - "Image": { - "Name": "grgmdmn/sentiment_api:latest", - "Update": "true" - }, - "Ports": [ - { - "ContainerPort": "8000" - } - ], - "Logging": "/var/log/nginx" -} diff --git a/deployment/api/docker-compose.yml.example b/deployment/api/docker-compose.yml.example index fbab4dc..5df8d0b 100644 --- a/deployment/api/docker-compose.yml.example +++ b/deployment/api/docker-compose.yml.example @@ -20,6 +20,8 @@ services: SMTP_FROM_ALIAS: "${SMTP_FROM_ALIAS}" # alias (optionnel) ADMIN_EMAIL: "${ADMIN_EMAIL}" # email admin destinataire + SENTIMENT_API_BASE_URL: "${SENTIMENT_API_BASE_URL}" # public api url (used to redirect Streamlit requests to FastAPI) + # only if you have a reverse proxy server # networks: # - swag diff --git a/deployment/api/preprocessing.py b/deployment/api/preprocessing.py index 5c54737..b1c3d96 100644 --- a/deployment/api/preprocessing.py +++ b/deployment/api/preprocessing.py @@ -5,17 +5,17 @@ from nltk.corpus import stopwords from nltk.tokenize import word_tokenize from nltk.stem import WordNetLemmatizer -# Assurer que les ressources nécessaires sont disponibles -try: - stopwords.words('english') - word_tokenize("test") - WordNetLemmatizer().lemmatize("testing") -except LookupError: - nltk.download('punkt') - nltk.download('punkt_tab') - nltk.download('stopwords') - nltk.download('wordnet') - nltk.download('omw-1.4') +# # Assurer que les ressources nécessaires sont disponibles +# try: +# stopwords.words('english') +# word_tokenize("test") +# WordNetLemmatizer().lemmatize("testing") +# except LookupError: +# nltk.download('punkt') +# nltk.download('punkt_tab') +# nltk.download('stopwords') +# nltk.download('wordnet') +# nltk.download('omw-1.4') def preprocess_tweet(tweet): """