Not Relevant - But interesting deployment option

38 views
Skip to first unread message

Fotis Paraskevopoulos

unread,
May 16, 2012, 9:46:50 AM5/16/12
to apostr...@googlegroups.com
Hello All,

Lately we have been digging into FB apps and all the "scaling" requirements that come along. For this reason I started looking into deploying an Apostrophenow project on Heroku (http://heroku.com), and see what sort of walls I would encounter. Heroku applications are deploying using "git push" so there is not a lot of control over the environment.

This is going to be a bit longwinded, so bear with me.

I started off by reading this http://blog.pajap.com/?p=102, which seemed simple enough, migrate .htaccess to the root of the project, work the Rewrite magic ( way beyond my comfort zone) and wallah! all done. At least that is what I thought so initially :), but 15 hours later I just gave up.

The first hurdle came with the database. On heroku you get a ClearDB Mysql instance for you to play with. So from my local command line I was able to create a "prod" environment in database.yml and run the appropriate doctrine commands. This successfully built the necessary tables on the the remote database. The problem started when I noticed that doing a "symfony cc --env=prod" would not empty the "a_cache_item" table in the remote database I had to do this manually. 

Once I figured that one out I moved onto my next problem which was routing. For the life of me I couldn't get my request to look like this (htaccess attached)

"http://host/[a_page_slug]" instead of  "http://host/web/[a_page_slug]" ( which does work).

The problem with this was  that assets such as images would be requested like so "http://host/images/...blah". Of course some others where being requested as "http://host/web/images/...blah", so in order to get over this hurdle I introduced a RewriteRule to make the first case match the second ( which contains  [web] in path).

Now the final issues (2 to be exact) was with asset-cache. I noticed that the "asset-cache" was not being created, even though a_project_root/web/uploads/ was empty. As it turned out it was because "a_cache_item" was not being emptied by the "cc" command, and aHelper would not create the files. 

Once I fixed this, I came to the last issue which beat me to the ground, and eventually I gave up. When the assets (css,js) are combined into a single file all the urls in the resulting "asset-cache/{hash}.[css | js ]" files had "/uploads/cache/" PRE-PENDED. So "url(/images/hello.jpg)" would become "url(/uploads/cache//images/hello.jpg)" in the css file. The interesting part is that in the "a_item_cache" the css was correct, at some point when this information is written this occurs but I can fathom where.

I know this is not symfony/apostrophenow/http specific, but it was a little bit of everything. To conclude I would like to know if anyone is willing to get me through this. I promise an article by the end quoting all of you  :) .


Best,
Fotis


.htaccess

Tom Boutell

unread,
May 16, 2012, 10:01:44 AM5/16/12
to apostr...@googlegroups.com
There are actually ways to deal with this stuff, we have some projects
that run in subdirectories. But first... is it really necessary???
Does heroku really make you stuff things under subdirectory URLs? And
why?
--
Tom Boutell
P'unk Avenue
215 755 1330
punkave.com
window.punkave.com

Fotis Paraskevopoulos

unread,
May 17, 2012, 7:14:27 AM5/17/12
to apostr...@googlegroups.com
Hello Tom,

Heroku allows you to deploy to a single directory (only via git push) which is the one exposed to the web so the directory structure is:


/
- apps
- bla blah
- more blah blah
- web

so http://mysuperapp.heroku.com/apps is accessible!

I only wan to expose the "web" directory, but seeing as I wasn't able to do so using .htaccess ( because of a lack of knowledge) I stumbled upon the assets-cache issue I described bellow.

Best,
Fotis

Tom Boutell

unread,
May 17, 2012, 8:54:53 AM5/17/12
to apostr...@googlegroups.com
You should definitely solve this problem the right way (webserver
configuration) and not the wrong way (by forcing your apostrophe site
to appear in a subdirectory).

If you really need to do the latter for a good reason though, there
are app.yml options to cope with it. See the Apostrophe scaling guide,
which uses those options for a slightly different purpose (keeping
static files and media files in the cloud):

http://trac.apostrophenow.org/wiki/ManualScaling

On Thu, May 17, 2012 at 7:14 AM, Fotis Paraskevopoulos

Fotis Paraskevopoulos

unread,
May 17, 2012, 11:34:32 AM5/17/12
to apostr...@googlegroups.com
Hello Tom,

Maybe I haven't explained my current situation well enough.

1) I don't want to force apostrophe to apear in a subdirectory, given the opportunity I wouldn't have to, it is just that Heroku in particular works this way
2) Where does the assets-cache "/uploads/asset-cache" prefix get prepended to the output css from a_cache_item.
3) Does a_cache_item get emptied upon symfony cc?
4) I have dealt with general apostrophe scaling issues, my current "quest :)" is deploying specifically on Heroku.

If I manage to do so I will let you know, thanks for the app.yml tip.

Best,
Fotis

Tom Boutell

unread,
May 17, 2012, 11:35:55 AM5/17/12
to apostr...@googlegroups.com
I do not believe that Heroku really can't serve your site as its own
home directory (: Surely this is not what every single ruby app in the
world must go through!

symfony cc --env=prod will clear a_cache_item if the prod settings
point to the right database and you're allowed to access it, yes.

On Thu, May 17, 2012 at 11:34 AM, Fotis Paraskevopoulos
Reply all
Reply to author
Forward
0 new messages