Spring Boot deployed on Elastic Beanstalk(Corretto 17 running on 64bit Amazon Linux 2). Need to modify Ngnix to allow large files(>1MB). CI/CD through Github Actions

0

Similar question has been asked before but I did not find relevant answers so here I am hoping for a proper answer.

So, I too wanted to upload files basically images that are greater than 1MB. I manually tried changing the 'nginx.conf' file to include "client_max_body_size 30M;" in the server{} block. I have three microservices under a single root project. I thought changing the NGINX config only on the media microservice would do the trick but to my surprise, had to change configurations of every microservice.

This was still okay but what I found out later is that after each deploy i.e. a new push to main branch, all the configs that I changed got overridden just like that and I was back to square one.

I saw this post "https://repost.aws/knowledge-center/elastic-beanstalk-nginx-configuration" and I tried following the same. I tried including both ".ebextensions" and ".platform" as root folders/packages under each microservice and tried changing the build.gradle for the regular java jar to include these folders in its root folders as well.

My comprehensive explanation starts from down below :

I had both ".ebextensions" and ".platform" packages(folders) under each of my microservice. FYI, I have three microservices for example sake let's call them 'A', 'B' and 'C'. A, B and C are under a main parent project folder let's say "ABC".

The stack I am working with is "SpringBoot" and the language I am using is "Java".

At first, I tried including both ".ebextensions" and ".platform" in the regular java jar that gets created. I tried including these two folders as the root folders of the decompressed JAR after the build.

For that I had to change my build.gradle(I use gradle as the build tool) file for each of my microservice and had to do something like this :

bootJar { //Include .platform as root folders

duplicatesStrategy = 'exclude'

from(".platform") {
    into(".platform")
}

from(".platform") {
    into(".platform")
}

}

When I built everything locally and "unzipped/decompressed" my regular java jar(jar that goes to Elastic BeanStalk), the two folders i.e. ".ebextensions" and ".platform" were included as root folders along with "BOOT-INF" and "META-INF" like I wanted.

I thought this would actually solve the problem and thought that this would actually create a new "client_max_body_size.conf" file inside "conf.d" folder in my cloud.

But to my surprse, When I tried to run CI/CD through github actions, the steps named "Deploy A to EB", "Deploy B to EB" and "Deploy C to EB", all of these failed.(A, B and C are the name of my microservices, EB is Elastic BeanStalk. Down below I have shown my github actions workflow as well).

When I checked the "eb-engine.log" the error said something like this :

"[ERROR] An error occurred during execution of command [app-deploy] - [CheckProcfileForJavaApplication]. Stop running the command. Error: there is no Procfile and no .jar file at root level of your source bundle"

I tried excluding ".ebextensions" folder after reading the above mentioned post and only included ".platform" in my jar and still I got the same error i.e.

"[ERROR] An error occurred during execution of command [app-deploy] - [CheckProcfileForJavaApplication]. Stop running the command. Error: there is no Procfile and no .jar file at root level of your source bundle"

What does this error actually mean?

I have several questions regarding this and I have been stuck in this problem for about 4 days now.

Questions 1 : Should I be including ".platform" folder as a root folder in my java jar that goes to elastic beanstalk? I am confused because everytime I do this, my CI/CD from github action fails.

Question 2: Should I update my workflow and should I edit anything there so that my build does not fail everytime and it actually sends the "client_max_body_size.conf" file in the cloud under "conf.d"?

Question 3 : Is Github actions really the problem here? My workflow looks something like this for say microservice 'A'. Down below is the job that fails first at the second step i.e. at "Deploy A to EB"

Workflow :

  • deploy-A:
    • needs: ABC (The root project under which everything is present)
    • name: Deploy A Service
    • runs-on: ubuntu-latest
    • steps:
      • Step 1:
        • name: Download A JAR
        • uses: actions/download-artifact@v3
        • with:
          • name: artifact-A
      • Step 2:
        • name: Deploy A to EB
        • uses: einaregilsson/beanstalk-deploy@v21
        • with:
          • aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
          • aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          • region: us-east-1
          • use_existing_version_if_available: true
          • application_name: BlaBla (Random Name)
          • environment_name: BlaBla-A-dev
          • version_label: ${{github.SHA}}-A
          • deployment_package: A-service-0.0.1-SNAPSHOT.jar
      • Step 3:
        • name: Delete A artifact
        • uses: geekyeggo/delete-artifact@v2
        • with:
          • name: artifact-A

Should I be changing anything here, like maybe adding a "cp" command or anything. Is this the problem because accoriding to the above blog I mentioned, only adding ".platform" should have done the trick.

Question 4: Including ".platform" in my java jar did not work, Not including ".platform" in my java jar also did not work because not including it in the jar successfully helped running all the pipeline but nothing got sent under "conf.d" folder in the cloud. How do I actually solve this problem? What am I missing?

Question 5 : Like I already mentioned, I have a root folder "ABC" under which I have my three microservices present? Should I create the very ".platform" folder under the root parent folder "ABC" as well. Because I have only included ".platform" under each microservices.

Question 6 : I tried manually chaning the conf under "\etc\nginx\vi nginx.conf and I set the "client_max_body_size" : 20mb, I had to do these for every microservice's nginx configuration and only then I could persist image greater than 1MB. But along with every new deploy, new changes in my CICD, everything got overriden in the nginx configuration folder. So how do I fix this as well?

Question 7 : Locally I am using Java 11 and my application in Elastic beanstalk as you might already know runs on "Corretto 17 running on 64bit Amazon Linux 2/3.4.7". Is this creating an issue because before this everything was running smoothly even when the versions were mismatched in the two environments i.e. local and EBS.

Am I missing something that should be done through Elastic BeanStalk? Am I missing something in the application code itself? I have 6 questions all in all and if anyone could help me, I would be so thankful. I am kind of a beginner when it comes to devops so I think I am missing something.

Any help would be highly appreciated.

kazi
asked a year ago139 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions