Deploy Comfy to heroku - ruby-on-rails-4

I really need help here please.
I made a rails application with the default gemfile and then followed the instructions for installation in comfy's wiki. Ran my app in the local host with webrick and sqlite3 getting no issues really, even though I am learning as I develop, but when the app was kind of ready (I judge it so it probably wasn't) for getting it up and running on heroku it failed, I checked the logs I migrated the database and tried with new apps, even tried installing psql and using unicorn as a web server (tried is emphasized cause neither of em worked for various reasons).
I've spent 6 hours (more or less) going through wikis and stuff but there really isn't much material for this CMS, please help, I even created a stack overflow account because of this issue.
I need a more detailed guide of the configuration needed for heroku.
And I have another question, what happens to the info generated by the users in heroku, how can I backup that. If I push something the differences in the cloud get erased? (Obviously the answer is no, but I want to know how and why)
Thanks a lot, this is driving me crazy.
FYI I'm an amateur.
Pd I can post some of my code's app if required.

Related

Using manage.py commands on Google App Engine

I have deployed my first web application to google cloud and I have been having a lot of difficulties on my first trip.
My main question (and reason for creating this post) is how to execute commands with manage.py like migrations? If that is not possible, how to handle migrations in the database?
I'm having trouble working in the cloud, I'm using the Cloud SQL for Postgresql and App Engine Flexible environment, I would appreciate if the more experienced ones could help me.
Thanks in advance.
Ok, problem solved. I solved it by using a local copy of Cloud SQL Proxy and actually it was pretty easy.
Found the answer here https://cloud.google.com/python/django/appengine#deploying_the_app_to_the_standard_environment_
I highlighted the most important part of this article in my TIL repository, if you are looking to a quicker answer.
https://github.com/jaocfilho/til/blob/master/google-cloud-platform/proxy-with-sql-instance.md
Thanks everyone.

Dango bootstrap styling shows up fine on dev-box, not on production

I've got a Django site which uses the "django-machina" forum software, which in its latest incarnation apparently uses Bootstrap4 styling.
After installing the package according to directions, it looks beautiful on my development box. But, when I deploy exactly the same software on production, Bootstrap obviously isn't running because nothing is properly styled.
There are no 404's and no console messages. *(Yes, I remembered to run manage.py collectstatic ...) There are some stylesheets complaints from Firefox but they're identical in both cases. But ... the display is not!
Can anyone suggest what I might do in order to solve this problem? I'm stumped!
Well, once again I answered my own question!
I correctly guessed that, since I was maintaining the remote site from my own box using rsync, there might be some garbage left over on the remote side that wasn't being swept-up. (I can't use rsync --delete for fear of smashing directories that contain images and uploaded materials.) I guess it would probably be smarter for me to start using an external repo so that git can do for me what it's designed to do ...
But anyway, when I deleted selected directories containing the central and most-often updated directories, then used rsync to replace them with clean copies, the interference went away and production now looks correct.

Selecting a git workflow for my situation

I'm new to git. I've read the well-written intro book. But gee, it's still not a trivial topic. I've been bumbling around, experiencing various problems. I realized it might be because I'm unaware of workflow, and specifically, "what are the best practices for doing what I'm trying to do?"
I started out developing a django project on my win7 with Pycharm. Great way to get the initial 95% written.
But then I need to deploy it to my production machine at PythonAnywhere.
So I created a private Github repository, pushed my win7 codebase to github.
Then in pythonAnywhere, I cloned the github repository.
For now, no others work on this project. It will not be released to the public.
Now that the server is running on PythonAnywhere, I still need to tweak settings, which is best done on the PythonAnywhere codebase side. But there are other improvements (new pages, or views) that I'd rather do inside Pycharm IDE on my win7 than in vim on python anywhere.
So I've been kind of clumsily pushing and fetching these changes. It's been kind of ham-handed, and I've managed to lose some minor changes through ignorance.
So I'm wondering if anyone can point to a relatively simple workflow that would handle the various tasks I mentioned:
1) improving functionality of the site (best done in Pycharm IDE)
2) production server issues and tweaks (best done on PythonAnywhere)
3) keeping everythign safely backed-up on Github
The other issue is that I have another django app that I want to build. It's easiest to temporarily hang it off the django project I've already built. But I'd prefer to keep it in its own repository.
So I have Original_Project, Original_App stored in Original_Repository
I want to make new_app, and have it, for the time being, run in Original_Project, but I want to version control it in New_Repository.
I think/hope that I could put a .gitignore in the Original_Repository, saying ignore the new_app/ Then I git init new_app/ as its own repository. Is that sound or mad?
You should avoid editing your code on the production server as much as possible, and never commit from the production server. If you end up having to tweaks things on the server (you shouldn't but well, shit happens and sometimes it's indeed easier to first get the code back to work on the server), then once it's working manually report your edits to your local repo, clear up the changes on the server and deploy the fixed code again. Here the github repo should be considered as the "master" repository for deployments, ie you work on your local repo, push to github, and on the server pull from github. This make sure you keep the github repo in sync.
wrt/ the "improving functionality" (aka "features") vs "server issues and tweaks" (aka "hotfixes"), git flow is a (mostly) sane workflow IMHO but that's a bit opinion-based here (some dislike it and have sensible arguments too).
Finally if you want to factor out one of your apps, the best is to have it in it's own (github) repo with all the proper python packaging stuff and make it a requirement of your main project. On your local dev environment you install it as an editable package, and for the production setup you install it as normal package pinned to the last stable version. Note that in both cases I assume you're using virtualenvs (and if you dont, well that's the very first issue you should address).
Update:
What are the downsides of of editing directly on the production server and committing from the production server?
Well quite simply a production server is not the place for coding - "production" means that you have users trying to do something with your website and they don't want to have the site breaking on them, their data lost or whatever because you are "tweaking" things. You should only deploy stable, well tested code on production, and the one and only one case where editing anything on the server might be a last resort option is when it's already broken and you want to get it back online asap whatever it takes (case of "first make it work, then make it clean").
Point is, I'm a professional developer working on projects that are business criticals and a broken site is not an option, so I'm very strict on this - but even if it's a hobby project, your users deserve some respect (at least if you expect to see them back).
A proper production chain actually involves at least three environments: your local dev environment, a staging server (which should closely mirror the production server - system, system package versions, configurations etc etc) to test out / showcase / eventually do minor config tweak, and the production server which should only ever see stable tested code.
I have always struggled with git, knowing it well enough to get thigs working, but never being sure I am doing thing well.
I would suggest installing git flow (it is probably available in your package manager if you are on Linux). Its a set of extensions that simplify a standard git worklfow. Since using it, this has pretty much been all the documentation I have needed.
https://danielkummer.github.io/git-flow-cheatsheet/

How to work with a local development server and deploy to a production server in django?

I want to work locally on my django(1.7) project and regularly deploy updates to a production server. How would you do this? I have not found anything about this in the docs. I am confused about that because it seems like many people would want to do that and there should be some kind of standard solution to this. Or am I getting the whole workflow wrong?
I should note that I'm not expecting a step-by-step guide. I am just trying to understand the concept.
Assuming you already have your deployment server setup, and all you need to do is push code to your server, then you can just use git as a form of deployment.
Digital Ocean has a good tutorial at this link https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps
Push sources to a git repository from a dev machine.
pull sources on a production server. Restart uwsgi/whatever.
There is no standard way of doing this, so no, it cannot be included with Django or be thoroughly described in the docs.
If you're using a PaaS how you deploy depends on the PaaS. Ditto for a container like docker, you must follow the rules of that particular container.
If you're old-school and can ssh into a server you can rsync a snapshot of the code to the correct place after everything else is taken care of: database, ports, webserver setup etc. That's what I do, and I control stuff with bash scripts utilizing a makefile.
REMOETHOST=user#yourbox
REMOTEPATH=yourpath
REMOTE=$REMOTEHOST:$REMOTEPATH
make rsync REMOTE_URI=$REMOTE
ssh $REMOTEHOST make -C $REMOTEPATH deploy
My "deploy"-action is a monster but might be as easy as something that touches the wsgi-file used in order to reload the site. My medium complex ones cleans out stale files, run collectstatic and then reloads the site. The really complex ones creates a timestamped virtualenv, cloned database and remote code tree, a new server-setup that points to this, runs connection tests on the remote and if they succeed, switches the main site to point to the new versioned site, then emails me the version that is now in production, with the git hash and timestamp.
Lots of good solutions. Heroku has a good tutorial: https://devcenter.heroku.com/articles/getting-started-with-django
Check out a general guide for deploying to multiple PaaS providers here: http://www.paascheatsheet.com

Installing Railo on Media Temple

I have a reseller account with Media temple. It doesn't support Railo ( http://www.getrailo.com/ ) out of the box but I really do want to use their service, but with some sites using Railo of course.
First port of call was Media temple to assist me...but they don't offer support with resellers on the DV with regards to installing software.
I also Googled and the only thing I can find is this (which looked perfect):
http://jakemauer.com/weblog/railo-on-mediatemple-dv-server/
However, it's out-dated somewhat and I simply do not posses enough technical skill to achieve it (I'm mainly a designer / front-end dev, offering reseller to my clients). One of the first things that guide requires is to get YUM going, but even that I was stuck on. The terminal threw up errors about other files it needed as 'dependencies' and I have no idea how to get that going. I found the process quite complicated. I'm not a server admin :(
I'd be happy to pay someone to do this, but would rather figure it out myself as I'm eager to learn too.
If anyone has experience doing this and can offer insight I'd appreciate it so much.
Thanks,
Michael.
The Railo installer should work just fine on a Media Temple VPS. Documentation on how to launch the Railo installer on a linux machine can be found here:
http://wiki.getrailo.com/wiki/Installation:InstallerDocumentation:LinLaunching
If you don't have a GUI on your server, don't worry, just SSH to your server and run the commands that are posted in the "Command-Line Install" sections.
If you have any problems with any aspect of the install process as outlined in the documentation, I'd recommend the Railo mailing list. The community there (like this one) is quite friendly and can walk you through almost any problems you encounter.