How to hide `/var/app/current` source code in elastic beanstalk? - node.js

I am trying to deploy a basic react application in elastic beanstalk and when I inspect the browser I can see the source code:
The content of the react app is the default one from create-react-app with default package.json scripts.
The platform on elastic beanstalk is that one Node.js 16 running on 64bit Amazon Linux 2/5.6.3.
Despite I tried to add GENERATE_SOURCEMAP=false in npm build script, and try to configure nginx using proxy.conf, I'm unable to hide the var/app/current folder that is being deployed and has the source code of my react application.
Does someone know how avoid source code to be exposed on elastic beanstalk when deploying it in Node.js platform?

Related

Problem while running Angular project project on AWS EC2

When I run my Angular project on AWS ec2 in production, it automatically gets changed to the host AWS IP address. I am unable to run my service. Has anyone faced this issue previously? Please help
Console screenshot
You no need to run the environment in the EC2,
Create a production build and deploy the code in the AWS >> Instance >> /var/www/html folder.
Command to build production: ng build --prod --aot
Just checkout the public URL of your EC2 Instance. It should be something like below:
http://ec2-52-204-122-132.compute-1.amazonaws.com
Now, in your Angular code, you must be having a base URL of the API. You should use the base URL of your API something like below:
API Base URL: http://ec2-52-204-122-132.compute-1.amazonaws.com/API-Application
This way, there won't be any IP conversion automatically.

Heroku deployment confusion: Vue.js frontend with Flask backend

I currently a web app involving a Vue.js frontend with a Flask backend acting as a REST API. They are divided into the client and server folders in my repo, respectively. I am looking to deploy it to Heroku via the Github deployment feature but am running into some errors and questions I need clarified.
All code can be found in this Github Repo: https://github.com/justintranjt/thrive-test
In development, I have been running the application like so:
In one terminal run thriveApp.py. In another terminal run npm run dev. Navigate to localhost:8080 which is the local server running
the Vue.js application.
Is this how the application will be run on Heroku? Or is the Vue application run using npm run build? In that case I would have to take the produced build folder and serve it in the Flask application, correct?
In addition, some of my links between the frontend and backend specify localhost:8080 and localhost:5000 (8080 is Vue and 5000 is Flask) which work locally. But will this work when deployed to Heroku?
<b-form>
<b-button variant="primary" href="http://localhost:5000/loginPage">Login via CAS</b-button>
</b-form>
As you can see here, I have a button in my Vue application that links to a login page routed by my Flask application. Will I have to change the portion of the URL that says localhost:5000 when running on Heroku?
Finally, When I currently try to build the application on Heroku only the Python portion of the code is recognized as modules from the Vue app specified by package.json are not installed while plugins for Python specified by requirements.txt ARE installed by Heroku.
I have a feeling all of these questions are generally related to each other. Any other advice or tips regarding Heroku deployment would also be helpful as I'm quite confused about deployment at the moment.
Is this how the application will be run on Heroku?
No! npm run dev spins up an entire development server with vue in dev mode and hot reloading. That's a lot of overhead, especially when it comes to file sizes.
Or is the Vue application run using npm run build?
Kind of. Vue doesn't need to run on your server at all, it's all client-side. npm run build bundles and minifies your files to a dist folder, you'll be left with only html, css and javascript - this is all of the frontend code that needs to be on your production environment - no need to deploy any of the source files. All you need to do is serve those static files from any server. This could be done by your flask, or just any apache, nginx etc.
But will this work when deployed to Heroku?
That will be very tricky to setup. It's one of the reasons why I would not deploy front- and backend on the same (virtual) server.
modules from the Vue app specified by package.json are not installed
If you deploy your bundled frontend instead of the source code this wont be an issue anymore. I still recommend serving the frontend from a different environment.

Amazon AWS Elastic Beanstalk NodeJS app

I have created a NodeJS app in Amazon AWS Elastic Beanstalk. Everytime I deploy the app I get following error (in logs):
2016-09-06T15:56:48.332Z] INFO [17369] : Command processor returning results:
{"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"/bin/sh: npm: command not found. \ncontainer_command 01-install-dependencies in .ebextensions/install.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI","returncode":127,"events":[]}]}
Any idea what must be causing it?
When deploying a NodeJS application to elastic beanstalk npm install is run automatically for you. You haven't posted the contents of your 01-install-dependencies but guessing from the name and the error message that script runs npm install.
I did some investigation a while back into which npm scripts are automatically run by elastic beanstalk - npm scripts on elastic beanstalk

Amazon Elastick BeanStalk error: Failed to create the AWS Elastic Beanstalk application version

I have today a strange issue for Amazon Elastick BeanStalk: for my instances I cannot upload application:
XXX#-Vostro-2520:~/git_projects/ProjectBlog (test-env)$ git aws.push --environment Project-Blog-test
Updating the AWS Elastic Beanstalk environment Project-Blog-test...
Error: Failed to create the AWS Elastic Beanstalk application version
I did test it for 2 instances: PHP and RoR apps.
I solved this on my own:)
Amazon EB allows only for 500 Application Versions. So I logged in to console -> Elastick BeanStalk -> Action -> View Application Versions
On these page I selected and deleted some of olded files uploaded to Amazon EB. After it I was able to upload new versions with EB scripts.
Heads up that the error may also appear if you have invalid characters in the commit description. Not sure what these are to AWS, but I got the same error with the characters "http://".

Deploy yeoman node.js application to Elastic Beanstalk

I have a NodeJS application that I developed using a Yeoman generator that I'm attempting to deploy to an Elastic Beanstalk instance. I'm fairly new to this stack so my apologies if the question seems scattered. I was able to deploy my application using this process: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs_express.html. However, when I hit my homepage I just have a blank Node application. I'm guessing this is because the deploy comes straight from my Git repository and my Grunt build process hasn't been run. Is there any way to tell Elastic Beanstalk to run Grunt build after receiving the deployable?
You'll need to setup Grunt to run with a deployment hook on AWS. This is done with container commands.
Checkout this answer: How to automatically restart delayed_job when deploying a rails project on Amazon Elastic Beanstalk?
And this relevant blog post: http://junkheap.net/blog/2013/05/20/elastic-beanstalk-post-deployment-scripts/

Resources