AOT-Technologies / forms-flow-ai-deployment

Deployment base for forms-flow-ai
Apache License 2.0
7 stars 26 forks source link

Build and run on an M1 Mac #35

Open bnowacky opened 1 year ago

bnowacky commented 1 year ago

Trying to get this running on my M1, and the docker build process is not working. I have used the quick build process as well as the detailed process.. Both with Docker.

Right now, I can get key cloak and redash running fine, but the forms-flow-webapi continues to fault and restart every 5 seconds, which also seems to force forms-flow-bpm to restart at the same interval + ~1s.

Has anyone gotten a full build running on an M1 ? I've made edits to Dockerfile to update a few dependancies and ass the --platform linux/amd64 to actually get the container to build, but still no luck.

Seeing if anyone else has had any luck running a local install on an M1 recently.

Hafflgav commented 1 year ago

I can just agree to what @bnowacky says. I have tried to run FormsFlow on my M1 Mac today and run into the exact same issue. Even trying to edit and run the shell script did not lead to a solution. It somehow always ends up in the described crash-loop.

Hafflgav commented 1 year ago

FYI, I somehow fixed that the web-api keeps crashing. Nevertheless, I still face problems with Camunda. Here is a section of the error log:

forms-flow-bpm | 2023-02-03 12:20:43.582 ERROR 1 --- [ main] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'OAuth2LoginSecurityConfig': Unsatisfied dependency expressed through method 'setContentNegotationStrategy' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.OAuth2ClientConfiguration$OAuth2ClientWebMvcSecurityConfiguration': Unsatisfied dependency expressed through method 'setClientRegistrationRepository' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientRegistrationRepository' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2ClientRegistrationRepositoryConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository]: Factory method 'clientRegistrationRepository' threw exception; nested exception is java.lang.IllegalArgumentException: Unable to resolve Configuration with the provided Issuer of "http://192.168.1.52:8080/auth/realms/forms-flow-ai"

Seeing that you, @sumesh-aot did the last commit to fix the deployment for M1 - maybe you can help here? :) Thank you a lot in advance!

sumesh-aot commented 1 year ago

@Hafflgav @bnowacky Were you using https://github.com/AOT-Technologies/forms-flow-ai-deployment/blob/main/docker-compose/docker-compose-arm64.yml ? Quick installation won't work with M1 yet, we are working on it. For now, please use the above docker compose.

Hafflgav commented 1 year ago

Thanks for your reply @sumesh-aot! Steps to reproduce my issue:

Second thing I tried out was:

I tested the installation on my windows machine - it runs fine there. To me it seems that the windows script creates other .env variables. I want to try out whether manually changing them on MacOS helps.

Hafflgav commented 1 year ago

Hey @bnowacky - we managed to get forms-flow up and running. Since it is rather a "workaround" we pushed it to one of our own repositories.

To me it seems that the .env variables & config.js is filled with the wrong attributes on startup. Especially since the bash script is not working.

There is also a readme in here who should tell you what exactly you need to do: https://github.com/FlowSquad/miranum-consulting/tree/main/forms-flow-showcase/forms-flow-ai

Lmk if this solves your problem! :) (Would be cool to get this officially fixed though)

sumesh-aot commented 1 year ago

@Hafflgav Thank you for the feedback. I have modified the script to pull correct IP address and to fix other issues. Could you please give a try and see if it's working on your end ?

Hafflgav commented 1 year ago

Hey @sumesh-aot! Thanks a lot for the update :) When trying to run the script it complains about invalid identifies. This can easily be fixed by changing function names like "forms-flow-web" to "formsFlowWeb". Using "-" seems to be forbidden in function names. (I wanted to push this to the branch but apparently do not have permissions to do so. :(

After having changed this I was able to run the script. I do not get container crashes anymore. Though when logging into keycloak with the default login I do get a "Error: Request failed with status code 503" So far I am not sure why this exactly happens.

I have noticed that

Another thing I saw is that the keys in the config.js file have been in quotation marks. Windows outputs:

window["_env_"] = {
    NODE_ENV:"production",
    REACT_APP_API_SERVER_URL:"http://192.168.1.52:3001",
    REACT_APP_API_PROJECT_URL:"http://192.168.1.52:3001",
    REACT_APP_KEYCLOAK_CLIENT:"forms-flow-web",
    REACT_APP_KEYCLOAK_URL_REALM:"forms-flow-ai",
    REACT_APP_KEYCLOAK_URL:"http://192.168.1.52:8080",
    REACT_APP_WEB_BASE_URL:"http://192.168.1.52:5000",
    REACT_APP_BPM_URL:"http://192.168.1.52:8000/camunda",
    REACT_APP_WEBSOCKET_ENCRYPT_KEY:"giert989jkwrgb@DR55",
    REACT_APP_APPLICATION_NAME:"formsflow.ai",
    REACT_APP_WEB_BASE_CUSTOM_URL:"",
    REACT_APP_USER_ACCESS_PERMISSIONS:{accessAllowApplications:false,accessAllowSubmissions:false}
};

Having changed these three things (identifiers in shell script, from default project url and config.js) leads to an accessible FormsFlow. 👍
Let me know what you think about these findings :)

sumesh-aot commented 1 year ago

@Hafflgav Thanks again for the feedback. I have a PR (https://github.com/AOT-Technologies/forms-flow-ai-deployment/pull/37/) in place to fix the quote and identifier issue (works on my M1 without those changes, weird). Formio project URL was getting populated in all scenarios I tried.