What changes do I have to make inorder to actually run a successful build and host my website on bluemix?
Right now, this is my Gruntfile.js, manifest.yml and package.json. The base folder 'app' is an Angular application -
module.exports = function(grunt){
grunt.initConfig({
connect: {
server: {
options: {
port: 9000,
base: 'app',
keepalive: true,
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('default', ['connect']);
};
package.json:
{
"name": "dummy",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {"grunt-cli": "^1.2.0",
"grunt": "^0.4.5",
"grunt-contrib-connect": "^0.10.1"
}
}
manifest.yml:
---
applications: #Reference http://docs.cloudfoundry.com/docs/using/deploying-apps/manifest.html
- name: dummy #Application Name. Unique to the user's Space
memory: 256M #The maximum memory to allocate to each application instance
instances: 1 #The number of instances of the application to start
path: ./ #Path to the application to be pushed
command: npm install && node_modules/.bin/grunt serve #The command to use to start the application
Few suggestions when working with node applications and Bluemix:
To start a node application it's recommended to use npm start and specify the script in the package.json.
If your application needs to build assets, specify how to do that in the postinstall script in the package.json. For example if you are using Gulp and your main task is build you will have something like:
"postinstall": "gulp build"
When running in Bluemix VCAP_APP_HOST and VCAP_APP_PORT will have the host and port where your application will run.
The files below have the fixes mentioned above:
manifest.yml:
---
applications:
- name: dummy-kartik-yadav
memory: 512M
instances: 1
path: .
command: npm start
package.json:
{
"name": "dummy",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node_modules/.bin/grunt serve",
"postinstall": "console.log('build ui assets like js, css, html...')"
},
"author": "",
"license": "ISC",
"dependencies": {
"grunt-cli": "^1.2.0",
"grunt": "^0.4.5",
"grunt-contrib-connect": "^0.10.1"
}
}
gruntfile.js:
module.exports = function(grunt){
grunt.initConfig({
connect: {
server: {
options: {
port: process.env.VCAP_APP_PORT || 9000, # listen to the port that bluemix will assign you
base: 'app',
keepalive: true
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('default', ['connect']);
};
After doing the changes mentioned above, open the project folder and run npm start. If it works locally, it will in Bluemix.
Related
I am trying to deploy my MERN application on render.com. Here is the folder structure:
root
client
-build
-src
-package.json
server
-dist
-src
-package.json
-package.json
I have created a separate folder for client-side code and server-side code.
Here is my root package.json file:
{
"name": "kneedup3.0",
"version": "1.0.0",
"description": "",
"main": "./server/dist/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "cd ./server && node dist/index.js"
},
"repository": {
"type": "git",
"url": "***********"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "********"
},
"homepage": "*********"
}
Here is the link to the repo: https://github.com/pawan-kr1997/Kneedup3.0
After successful deployment, I was provided with a link when I clicked it I get an error as cannot get /.
Please guide. Am I missing any code which needs to be added?
I am working on a website using Preact, and I am trying to proxy requests made in the browser to the development server I'm using as the back end.
When I try to run the front end application with yarn client, it errors out and informs me it cannot find the http2-Proxy module despite my installing it.
My directory structure is as follows:
Website_Root:
| package.json
|
+---dummy-api
|
+---frontend
| package.json
| README.md
| snowpack.config.mjs
|
+---public
|
+---src
| index.jsx
|
+---assets
|
+---components
|
+---routes
I'm attempting to use the Yarn Workspaces feature; as such my package.json at the root level is as follows:
{
"name": "Website",
"packageManager": "yarn#3.1.1",
"scripts": {
"client": "yarn workspace frontend dev",
"mockapi": "yarn workspace dummy-api dev",
"dev": "yarn concurrently --kill-others-on-fail \"yarn client\" \"yarn mockapi\""
},
"workspaces": [
"frontend",
"dummy-api"
],
"devDependencies": {
"concurrently": "^6.4.0"
},
"dependencies": {
"preact": "^10.6.4"
}
}
The package.json inside of the frontend workspace is as follows:
{
"name": "frontend",
"private": true,
"proxy": "http://localhost:9000/api",
"scripts": {
"dev": "snowpack dev",
"build": "snowpack build",
},
"dependencies": {
"axios": "^0.24.0",
"http2-proxy": "^5.0.53",
"preact": "^10.6.4",
"preact-router": "^3.2.1",
"react-table": "^7.7.0"
},
"devDependencies": {
"#prefresh/snowpack": "^3.0.0",
"#snowpack/plugin-dotenv": "^2.1.0",
"#snowpack/web-test-runner-plugin": "^0.2.2",
"snowpack": "^3.8.8"
}
}
And, finally, my snowpack.config.js is as follows:
import proxy from "http2-proxy";
/** #type {import("snowpack").SnowpackUserConfig } */
export default {
alias: {
react: "preact/compat",
"react-dom/test-utils": "preact/test-utils",
"react-dom": "preact/compat",
"react/jsx-runtime": "preact/jsx-runtime",
},
mount: {
public: { url: "/", static: true },
src: { url: "/dist" },
},
plugins: ["#snowpack/plugin-dotenv", "#prefresh/snowpack"],
routes: [
{
match: "all",
src: "/api/.*",
dest: (req, res) =>
proxy.web(req, res, { hostname: "localhost", port: "9000" }),
},
],
devOptions: {
open: "none",
},
};
I can't help but think I've set something up incorrectly; snowpack should be able to find http2-proxy since I've installed it, but I genuinely don't understand what the holdup is.
I've also tried installing http2-proxy at the root level to no avail.
I believe I discovered the problem.
I did not initialize the yarn workspaces correctly.
I tried out a minimum working example of preact with snowpack, and found that creating a parent yarn directory, creating the child directories, registering them in the parent package.json and then inside each child subdirectory running yarn init -y instead of yarn init -2 produced the necessary results.
I made a very simple gatsby site with AWS Amplify tho, site map was not created by 'gatsby-plugin-sitemap'.
[package.json]
{
"name": "web_matching",
"version": "1.0.0",
"private": true,
"description": "web_matching",
"author": "uekyo",
"keywords": [
"gatsby"
],
"scripts": {
"develop": "gatsby develop",
"start": "gatsby develop",
"build": "gatsby build",
"serve": "gatsby serve",
"clean": "gatsby clean"
},
"dependencies": {
"gatsby": "^2.26.1",
"gatsby-plugin-sitemap": "^2.11.0",
"react": "^16.13.1",
"react-dom": "^16.13.1"
}
}
[gatsby-config.js]
module.exports = {
siteMetadata: {
title: "web_matching",
siteUrl: `https://amp.d1aw1cuurv9iud.amplifyapp.com`,
},
plugins: [
{
resolve: `gatsby-plugin-sitemap`,
options: {
output: `/sitemap.xml`,
}
}
]
};
[amplify.yml]
version: 1
frontend:
phases:
preBuild:
commands:
- yarn install
build:
commands:
- yarn build
artifacts:
baseDirectory: public
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Do you guys have the same experience? By the way, if I enter the sitemap URL, it's moved to a top page automatically. However, it works on localhost. The problem seems to be in Amplify.
Running locally with gatsby develop will not serve up the sitemap.
You must run under production mode by running gatsby build && gatsby serve
Then the sitemap should be available via http://localhost:9000/sitemap.xml
I build a Node.js REST implementation using this tutorial .And now i am having problems deploying it on heoroku , local works fine .
Heroku logs :
I believe the problem is with my directory structure. The "main" key
of package.json and and the rest endpoints in index.js are not right
Next I was successfully able to deploy my app on Heroku but I am getting the error.My implementation is as follows :
EDIT : I removed the Procfile , compared to shown in following pics ,as I added the "start" key in package.json
Local :
Directory Structure - /webapp is the root directory :
I have package.json file at root directory and /server with different
version (about which i am not sure how they should be actually for my
ngClient and heroku confiurations )
Files contents of root , /webapp :
package.json
{
"name": "web_first_package",
"version": "0.0.0",
"description": "first node package for project storm",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start":"/myRESTApp/server/server.js"
},
"engines": {
"node": "6.9.x",
"npm": "3.10.x"
},
"author": "Divyanshu Jimmy",
"license": "ISC",
"dependencies": {
"body-parser": "^1.15.2",
"express": "^4.14.0",
"jwt-simple": "^0.5.1",
"morgan": "^1.7.0"
}
}
package.json in /myRESTApp/server:
{
"name": "web_first_package",
"version": "0.0.0",
"description": "first node package for project storm",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"engines": {
"node": "6.9.x",
"npm": "3.10.x"
},
"author": "Divyanshu Jimmy",
"license": "ISC",
"dependencies": {
"body-parser": "^1.15.2",
"express": "^4.14.0",
"jwt-simple": "^0.5.1",
"morgan": "^1.7.0"
}
}
Node version : 6.9.2 NPM Version : 3.10.9
Change start script to node ./myRESTApp/server/server.js.
I've been developing a site for a customer using angularjs as front-end. The tests were written using protractor.
When I run the site using Tomcat 8 in eclipse, the site works as expected, but when the test run using the npm http-server, my service to share data between 2 directives isn't operational. The service.variable remains undefined all the time.
I've set up a Plunker to represent the structure as much as possible
http://plnkr.co/edit/b49YHoFUlwjFUvsn2Y0C?p=preview
package.json
{
"version": "1.0.5",
"private": true,
"name": "troubleshooting-webapp",
"description": "Troubleshooting REST Service",
"devDependencies": {
"bower": "^1.4.1",
"http-server": "^0.8.5",
"protractor": "^3.0.0",
"protractor-http-mock": "^0.2.1",
"shelljs": "^0.2.6",
"tmp": "0.0.23"
},
"scripts": {
"setup": "npm install",
"start": "cd src/main && http-server -a 0.0.0.0 -p 8000",
"stop": "pkill --signal SIGINT node",
"update-webdriver": "webdriver-manager update",
"preprotractor": "npm run update-webdriver",
"protractor": "protractor src/main/webapp/js/tests/protractor-conf.js",
"preprotractor_debug": "npm run update-webdriver",
"protractor_debug": "protractor debug src/main/webapp/js/tests/protractor-conf.js"
}
}
protractor-conf.js
exports.config = {
allScriptsTimeout: 18000,
specs: [
'e2e/*.js'
],
mocks: {
dir: 'mocks'
},
onPrepare: function(){
require('protractor-http-mock').config = {
rootDirectory: __dirname, // default value: process.cwd()
protractorConfig: 'protractor-conf.js' // default value: 'protractor.conf'
};
},
capabilities: {
'browserName': 'firefox'
},
baseUrl: 'http://localhost:8000/',
framework: 'jasmine',
jasmineNodeOpts: {
defaultTimeoutInterval: 90000
}
};
Any ideas of why the filterSelection service remains undefined whould be nice.
After some more research, it seems like the mocks aren't loading either.