How to deploy parse dashboard to heroku - heroku

I have deployed the parse server on heroku (https://github.com/ParsePlatform/parse-server) but can't find anything to deploy the parse dashboard on heroku. Any reference is appreciated!!

You shouldn't have to clone the parse-dashboard repository. Here is a better way using parse-dashboard as a node module.
Create a new node app:
mkdir my-parse-dashboard
cd my-parse-dashboard
npm init
Fill out the details it asks for.
Create a git repository:
git init
Additionally you can push this git repository to a remote server (e.g. Bitbucket). Note this repository should be private since it will contain your master key.
Install the parse-dashboard package:
npm install parse-dashboard --save
Create an index.js file with the following line:
require('parse-dashboard/Parse-Dashboard/index.js');
Create a parse-dashboard-config.json file which looks like this:
{
"apps": [
{
"serverURL": "your parse server url",
"appId": "your app Id",
"masterKey": "your master key",
"appName": "My Parse App"
}
],
"users": [
{
"user":"username",
"pass":"password"
}
]
}
Update your package.json file and add this section (or modify it if it already exists):
"scripts": {
"start": "node ./index.js --config ./parse-dashboard-config.json --allowInsecureHTTP=1"
}
Note: The allowInsecureHTTP flag seems to be required on Heroku. Thanks to #nsarafa for this.
Commit all your changes and merge them into master.
Create a new Heroku app: heroku apps:create my-parse-dashboard
Run git push heroku master to deploy your app to Heroku.
Remember to generate a strong password as your dashboard is accessible to anyone on the internet. And make the dashboard only accessible through SSL else your password will be sent in clear text. Read this tutorial on how to force all traffic over SSL on Heroku with Cloudflare for your domain.

I just managed to get this working. Here are the steps I took.
Clone parse-dashboard to your local machine.
Run npm install inside that directory.
Update package.json and change the "start" script to:
"start": "node ./Parse-Dashboard/index.js --config ./Parse-Dashboard /parse-dashboard-config.json --allowInsecureHTTP=1"
(Thanks to nsarafa's answer above for that).
Edit your .gitignore file and remove the following three lines:
bundles/Parse-Dashboard/public/bundles/Parse-Dashboard/parsedashboard-config.json
Edit your config file in Parse-Dashboard/parse-dashboard-config.json, making sure URLs and keys are correct. Here is an example :
{
"apps": [
{
"serverURL": "https://dhowung-fjird-52012.herokuapp.com/parse",
"appId": "myAppId",
"masterKey": "myMasterKey",
"appName": "dhowung-fjird-40722"
}
],
"users": [
{
"user":"myUserName",
"pass":"Str0ng_?Passw0rd"
}
]
}
Remove the cache from your heroku parse server app :
heroku config:set NODE_MODULES_CACHE=false --app yourHerokuParseServerApp
if we follow the example above
yourHerokuParseServerApp = dhowung-fjird-40722
(Again, thanks to nsarafa).
Add, commit and push your changes.
Deploy to Heroku again using their CLI or the dashboard.
Step 4 was the key for me because I wasn't committing my config file, and it took me a while to realise.
Also, as stated above, make sure you have user logins and passwords in your config file, following the parse-dashboard docs:
PS: on your heroku parse server make sure your SERVER_URL looks like this https://yourHerokuParseServerAppName.herokuapp.com/parse

Update brew brew update
Install heroku-cli brew install heroku-toolbelt
Login via command line with your heroku credentials heroku login
Make sure your app is there heroku list and note YOURHEROKUAPPSNAME containing the parse-dashboard deployment
Tell Heroku to ignore the cache from previous deploys heroku config:set NODE_MODULES_CACHE=false --app YOURHEROKUAPPSNAME
Go to your package.json and change start: node ./Parse-Dashboard/index.js to start node./Parse-Dashboard/index.js --config ./Parse-Dashboard/parse-dashboard-config.json --allowInsecureHTTP=1"
Delete your Procfile rm Procfile
Add, commit and merge to your master branch
Run git push heroku master
The start script inside your package.json overrides whatever you declare inside of the Procfile. This process should enable a clean deploy to Heroku. Please be cautious and generate user logins with strong passwords before performing this deployment per the parse-dashboard documentation.

Related

pm2 deploy fails after full fetch

I want to deploy a simple app to my ec2 instance but I got this error:
bash: line 0: cd: /home/ubuntu/source: No such file or directory
fetch failed
Deploy failed
1
I don't understand why is there a 'source' directory when i haven't created it on my virtual or local machine. It's like pm2 created it on its own. Can someone explain why is it there and how can I deploy it successfully?
My ecosystem.config.js:
module.exports = {
apps: [{
name: 'puk',
script: 'project/'
}],
deploy: {
production: {
user: 'ubuntu',
host: 'ec2-35-180-119-129.eu-west-3.compute.amazonaws.com',
key: '~/.ssh/id_rsa.pub',
ref: 'origin/master',
repo: 'git#github.com:nalnir/pukinn.git',
path: '/home/ubuntu/',
'post-deploy': 'npm install && pm2 startOrRestart ecosystem.config.js'
}
}
}
Full log after pm2 deploy production command:
--> Deploying to production environment
--> on host ec2-35-180-119-129.eu-west-3.compute.amazonaws.com
○ deploying origin/master
○ executing pre-deploy-local
○ hook pre-deploy
○ fetching updates
○ full fetch
bash: line 0: cd: /home/ubuntu/source: No such file or directory
fetch failed
Deploy failed
1
I have faced the same issue and got this thread, but the above answer/comments are not very helpful for me. There is no helpful document on the PM2 website too. So I do one by one all steps from initial:
Do first setup before calling update command on any existing folder. Because PM2 create their own folder structure: [Current, Source, Shared] (Read here)
pm2 deploy ecosystem.config.js stage setup
When you want to deploy new code then do with the below command:
pm2 deploy ecosystem.config.js stage update --force
Why --force?
You may have some changes in your local system that aren’t pushed inside your git repository, and since the deploy script get the update via git pull they will not be on your server. If you want to deploy without pushing any data, you can append the --force option:
My deploy object in ecosystem.config.js file :
deploy : {
stage : {
// Deploy New: pm2 deploy ecosystem.config.js stage setup
// Update: pm2 deploy ecosystem.config.js stage update --force
user : '_MY_SERVER_USER_NAME_', // remote server username
host : '_MY_REMOTE_SERVER_IP_', // remote server ip
ref : 'origin/stage', // remote repo name
repo : 'git#bitbucket.org:_MY_REPO_SSH_CLONE_URL_.git', // repo url
path : '_REMOTE_DIRECTIVE_', // src root paths like /home/ubuntu/
'pre-deploy-local': '',
'post-deploy' : 'npm install && pm2 reload ecosystem.config.js --only MyAppName',
'pre-setup': ''
}
}
I Hope, It will helpful for others.
script parameter expects the actual script path, not the directory
You should change it to the name of your main script, for example: script: './index.js'
You should also update your deploy.production.path to something like /home/ubuntu/project
As stated in the Ecosystem file reference, script expects the Path of the script to launch

Ionic PWA deploy

I'm trying to deploy a Progressive Web App version of my Ionic 2 project to Heroku but it doesn't seem to work. What I'm trying is to use "Ionic build browser --prod" and then deploy the www folder, but I'm not getting any response from Heroku (Seems that nothing has being deployed)
The steps you are supposed to take:
Ionic build browser --prod - creates the main.js file to be deployed
Go to .gitignore file and remove the mentions of www/ so git picks it up and add these two lines so platforms browsers folder is picked up
platforms/*
!platforms/browser/
!platforms/browser/www
!platforms/browser/www/plugins
Add these 2 libraries to your package.json (don't forget to run npm install)
"connect": "^3.5.0",
"serve-static": "^1.11.1"
Add a start to your npm scripts in package.json
"start": "node server.js"
Add server.js to your project folder with the following code:
var connect = require('connect'),
serveStatic = require('serve-static');
var app = connect();
app.use(serveStatic("platforms/browser/www"))
app.listen(process.env.PORT || 5000);
Please note this code is only for ionic apps and not normal angular apps.
At this point you can write npm start or node server.js in your cmd and you can test to see how it will run.
Commit your code to heroku git using git push heroku master. Please note to have the heroku git on your remote list. You may do git remote -v to check if thats the case. If not get the url from the website and add it.
Optional - Put the www/ folder back in .gitignore and git rm --cached -r ./www to delete them from your git. This is so your co workers wont have merge conflicts on your main.js everytime you commit. The same for platforms/browser.
You are supposed to see heroku installing and deployed a node application in your enviornment after pushing to their git
NOTE If you are using Heroku you could probably do this with Heroku builds rather than playing with your git. https://github.com/heroku/heroku-builds
An update, as i ran the same task today:
It may be preferable to avoid
Adding and maintaining "server" code along with your app.
Pushing the built app (www/) in your version control system.
You can rely just on the heroku buildpacks. To do that you would need two buildpacks:
https://github.com/heroku/heroku-buildpack-nodejs.git
https://github.com/heroku/heroku-buildpack-static.git
Your app will be detected first as node app and will build, and later as a static site and served.
First, build the app up on heroku, don't add www to your version control system:
The first buildpack will detect your app as node app, and run the build after the postbuild script.
you need to add this line to you package.json scripts:
"heroku-postbuild": "ionic build --prod"
and add the ionic cli to your dev-dependencies so it can be available for heroku on the build process
npm install ionic --save-dev
Second, serve the static files generated:
The second buildpack will serve the static files generated in www. For that you need to tell the buildpack how to serve the files with a static.json file: (this one is somewhat equivalent to the config for firebase in the ionic docs)
/static.json:
{
"routes": {
"/**": "index.html"
},
"headers": {
"ngsw-worker.js": {
"Cache-Control": "no-cache"
},
"/build/app/**": {
"Cache-Control": "public, max-age=31536000"
}
},
"root": "www/"
}
Looks like the new Ionic doesn't generate the 'www/build/app/...' directory anymore, just added to be consistent with the above mentioned docs.
Just those two changes, along with the buildpacks are enough to run the PWA on heroku / dokku

Deploying Angular-fullstack app on Heroku using Codeship

I'm trying to deploy a website via CodeShip unto Heroku. The site is built with Yeoman's Angular-Fullstack generator, which is pushed to GitHub. Codeship detects the push, builds the entire thing and then the trouble start.
Angular-Fullstack is set up so that the dist/ folder contains the entire Heroku app, so blindly deploying everything will not work on Heroku.
Locally, I can use the Heroku toolbelt to login, add a remote inside the dist folder, and then use grunt buildcontrol to deploy the entire thing unto Heroku.
But in Codeship there are a few caveats:
* I cannot install the Heroku toolbelt with wget because it needs sudo and Codeship doesn't support that
* If I could, I couldn't login to Heroku using the CLI because I cannot interact with the shell in Codeship
* I cannot go into the dist/ folder and after adding the remote, simply push to Heroku because I need to enter my credentials.
Is there a way that I missed here? I'd like to let Codeship handle everything from building to deployment to Heroku (only on the master branch).
Figured it out!
I skipped the step where I was trying to install the Heroku Toolbelt, and just added the repo on Heroku as remote:
git remote add heroku ssh://git#heroku.com/[your-heroku-app-name].git
Codeship has public keys available for every build. So, I added that publick key to my Heroku account.
Then I noticed that Git was still trying to push using HTTPS instead of SSH, so I added this to the deployment script:
git config --global url.ssh://git#heroku.com/.insteadOf https://git.heroku.com/
This made sure that Git uses the SSH url for Heroku. I then let Codeship build the entire project and push it with grunt buildcontrol:heroku.

How to deploy meteor 0.6.0 + to heroku

Im trying to deploy my meteor 0.6.3 app to heroku i tried using https://github.com/jordansissel/heroku-buildpack-meteor.git it only supports meteor 0.5.9 i also tried bundling my app in a .tgz file as suggested by the meteor docs but was not able to deploy I kept getting the no cedar app detected?
I had to do a bit of work to get Meteor 0.8.2 to deploy properly to Heroku. I'm posting the sequence of steps that worked for me. You could turn this into a parameterized Bash script, if you were so inclined.
# Define Meteor/Heroku app name:
export APP_NAME='Your-App-Name-Here'
# Create Meteor app:
meteor create --example leaderboard "${APP_NAME}"
cd "${APP_NAME}"
git init .
git add .
git commit -m 'Initial commit'
if ( heroku apps | egrep --silent "^${APP_NAME}$" )
then
# If re-using an existing Heroku app:
echo "Heroku app '${APP_NAME}' already exists; configuring..."
git remote remove heroku
heroku git:remote -a "${APP_NAME}"
heroku config:set \
BUILDPACK_URL=https://github.com/oortcloud/heroku-buildpack-meteorite.git
else
# If creating the Heroku app for the first time:
echo "Creating Heroku app '${APP_NAME}'..."
heroku create --stack cedar --app "${APP_NAME}" \
--buildpack https://github.com/oortcloud/heroku-buildpack-meteorite.git
fi
heroku config:add ROOT_URL="http://${APP_NAME}.herokuapp.com"
# Make sure you have a verified account to enable the mongohq:sandbox add-on
heroku addons:add mongohq:sandbox
# Visit: https://addons-sso.heroku.com/apps/${APP_NAME}/addons/mongohq:sandbox
open "https://addons-sso.heroku.com/apps/${APP_NAME}/addons/mongohq:sandbox"
# - Click 'add a database user'
# - Enter a user name and password, and click 'Add user'
# - Click 'Overview' tab
# Set the following variables appropriately, based on the user name, password, and
# values within the 'Mongo URI' string in the Overview tab
export MONGO_DB_HOST='kahana.mongohq.com'
export MONGO_DB_PORT='db-port'
export MONGO_DB_NAME='db-name'
export MONGO_DB_USER='db-user'
export MONGO_DB_PASS='db-pass'
# Calculate connection string and URL:
export MONGO_DB_CONN="${MONGO_DB_HOST}:${MONGO_DB_PORT}/${MONGO_DB_NAME}"
export MONGO_DB_URL="mongodb://${MONGO_DB_USER}:${MONGO_DB_PASS}#${MONGO_DB_CONN}"
# If you have mongo client installed, verify the connection:
export MONGO_CMD='mongo'
"${MONGO_CMD}" "${MONGO_DB_CONN}" -u "${MONGO_DB_USER}" -p"${MONGO_DB_PASS}"
heroku config:add MONGO_URL="${MONGO_DB_URL}"
# Verify configs look okay:
heroku config
# Configure a public/private SSH key pair in order to perform builds:
export HEROKU_RSA_NAME='id_rsa#herokuapp.com'
export HEROKU_RSA_FILE=~/.ssh/"${HEROKU_RSA_NAME}"
# If creating the keys for the first time:
[[ -f "${HEROKU_RSA_FILE}" ]] || {
ssh-keygen -t rsa -f "${HEROKU_RSA_FILE}"
ssh-add "${HEROKU_RSA_FILE}"
}
heroku keys:add "${HEROKU_RSA_FILE}.pub"
# Deploy the Meteor app via Git and the custom build pack:
git push heroku master
# Any errors?
heroku logs
# Make sure the Heroku app is running using one web dyno:
heroku ps:scale web=1
# Test the app
heroku open
Use this, works like a charm.
https://github.com/oortcloud/heroku-buildpack-meteorite
To those having trouble with the bash: node: command not found issue, I went through that too and I solved it by deleting the Procfile.
Apparently, the Procfile indicates Heroku to run the app using node main.js but node is not a valid command since it is not included in the PATH varialbe, or similar.
By deleting the Procfile, Heroku detects that the app is a meteor app and runs it using the node binary with the full path.
Sorry for posting an answer instead of a comment, but my reputation doesn't let me comment.
Also, remember the ROOT_URL must be set begining with http://
I am running two Meteor applications on Heroku (both apps are connected to mongolab, so external MongoDB instances).
Here I have documented how I did it:
.../how-to-deploy-meteor-on-heroku-with.html

How to attach my repo to heroku app

I create a heroku app and then my machine crashed. I have a new machine. How do I attach my existing app to heroku app. When I visit heroku page the url for my app is like this
git#heroku.com:myapp.git
I can't do clone this app because I already have myapp from github. So I need to add heroku as remote to my existing github app. Anyone knows the syntax.
If you've heroku toolbelt:
If you're using the Heroku Toolbelt, the newer syntax is
heroku git:remote -a project
See this for more.
Credits: user101289's solution
Else if you don't have heroku toolbelt:
First do this:
git remote add heroku git#heroku.com:{heroku-app-name}.git
Then do this:
git push heroku master
heroku open
If you're using the Heroku Toolbelt, the newer syntax is
heroku git:remote -a project
See this for more.
If you're using just Git without installing the Heroku Toolbelt, you can also create a new application.
Login to your account and go to this link
https://dashboard.heroku.com/apps
Look at the plus sign on the top right corner then select
Create new app
Leave the application name blank to let heroku choose one for you.
Let say your heroku app name is new-app-xxxxx, so to test on adding a file in to it you may try the following command:
git clone https://git.heroku.com/<new-app-xxxxx>.git
cd <new-app-xxxxx>
echo "my test file" > test.txt
git add .
git commit . -m "my test on commit"
git push
Put empty (blank) when the Git prompt for username, and your API Key for the password. You can get your API Key by showing it from the link below.
https://dashboard.heroku.com/account
Note: You cannot authenticate with the Heroku HTTP Git endpoint using your Heroku username (email) and password. Use an API key as described here.

Resources