From b2cc1e29333521081f92da7e8e3d67df5a58bf48 Mon Sep 17 00:00:00 2001 From: mariorecinos Date: Sun, 28 Jul 2024 17:59:16 -0700 Subject: [PATCH 1/3] included docker-compose file with environment variable for open_ai_api Fixes #25 --- .dockerignore | 70 +++++++++++++++++++++++ .gitignore | 1 + README.md | 4 +- docker-compose.yml | 3 + src/main/resources/application.properties | 3 +- 5 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3c7c340 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,70 @@ +# Ignore .git directory +.git + +# Ignore any .env files +.env +application*.yml +application.yml + +# Ignore build directories +build/ +target/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +# Ignore Gradle cache +.gradle/ + +# Ignore logs and temporary files +*.log +*.tmp +*.swp + +# Ignore IDE specific files +.vscode/ +.idea/ +*.iws +*.iml +*.ipr +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +# Ignore OS generated files +.DS_Store +Thumbs.db + +# Ignore the Git hooks directory +.git/hooks/ + +# Ignore Docker-related files +docker-compose.yml +Dockerfile + +# Ignore README and other documentation files +README.md +HELP.md + +# Ignore setup script and pre-push hook +setup.sh +pre-push + +# STS specific files +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +# NetBeans specific files +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ diff --git a/.gitignore b/.gitignore index 30c9032..769a886 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ out/ ### Environment Variable Files ### application*.yml application.yml +.env diff --git a/README.md b/README.md index 37e440b..f13424f 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,8 @@ Unit Tests: OpenAI API Call Example: *IMPORTANT* -Create an application.yml in the src/main/resources folder(the one with application.properties) AND another application.yml in test/resources. Then get an OpenAI api key from their website -and copy it into both of the application.yml files in this format: +Create an .env file in your swarm-rest-api project directory. Then get an OpenAI api key from their website +and copy it into the .env file in this format: OPENAI_API_KEY: ABSOLUTELY DO NOT COPY THIS KEY INTO ANY OTHER FILE, OR COMMIT CODE WITH KEYS IN IT. diff --git a/docker-compose.yml b/docker-compose.yml index 2ecf479..515871a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,9 +3,12 @@ # build - Tells Docker-Compose to build an image using the Dockerfile in the current directory. # app - The name of the services to be created when docker-compose up is run. # ports - Maps port 8080 of the host to port 8080 of the container. +# environment - references variables for secret keys in .env file version: '3.8' services: app: build: . ports: - "8080:8080" + environment: + - OPENAI_API_KEY=${OPENAI_API_KEY} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index b58820f..ffe613e 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,2 +1,3 @@ spring.application.name=swarm-rest-api -spring.profiles.active=local \ No newline at end of file +spring.profiles.active=local +OPENAI_API_KEY=${OPENAI_API_KEY} From 98103c8e395feae72647c7953b4b0ec6dc697a69 Mon Sep 17 00:00:00 2001 From: mariorecinos Date: Mon, 29 Jul 2024 07:00:11 -0700 Subject: [PATCH 2/3] fixed test --- docker-compose.yml | 15 ++++++--------- src/main/resources/application.properties | 1 - 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 515871a..95d89c6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,14 +1,11 @@ -# version - Specifies the version of the Docker Compose file format. -# services - Defines the services to be created when docker-compose up is run. -# build - Tells Docker-Compose to build an image using the Dockerfile in the current directory. -# app - The name of the services to be created when docker-compose up is run. -# ports - Maps port 8080 of the host to port 8080 of the container. -# environment - references variables for secret keys in .env file -version: '3.8' services: app: build: . ports: - "8080:8080" - environment: - - OPENAI_API_KEY=${OPENAI_API_KEY} + + test: + build: . + ports: + - "8080:8080" + command: ./gradlew test \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ffe613e..c7133cf 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,2 @@ spring.application.name=swarm-rest-api spring.profiles.active=local -OPENAI_API_KEY=${OPENAI_API_KEY} From 7d4505de29eda2ffb1621d01d6cbdb0cce969b0d Mon Sep 17 00:00:00 2001 From: mariorecinos Date: Mon, 29 Jul 2024 07:34:24 -0700 Subject: [PATCH 3/3] fixed test --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index f13424f..bb22fc7 100644 --- a/README.md +++ b/README.md @@ -43,14 +43,9 @@ and see "Hello Swarm!" Unit Tests: - - OpenAI API Call Example: -*IMPORTANT* -Create an .env file in your swarm-rest-api project directory. Then get an OpenAI api key from their website -and copy it into the .env file in this format: -OPENAI_API_KEY: +IMPORTANT Create an application.yml in the src/main/resources folder(the one with application.properties) AND another application.yml in test/resources. Then get an OpenAI api key from their website and copy it into both of the application.yml files in this format: OPENAI_API_KEY: ABSOLUTELY DO NOT COPY THIS KEY INTO ANY OTHER FILE, OR COMMIT CODE WITH KEYS IN IT.