Forums

Staging site

Hey guys,

How might I create a staging site for my application using PA and git hub?

I now have beta testers on my application so I could do with working on a test site and pushing changes in bulk, but not sure how to get started.

Might make a decent blog post?

Thanks

You're right, that would make a great blog post!

The way I'd set it up would be:

  • Two PythonAnywhere webapps at www.yourdomain.com and staging.yourdomain.com
  • Each one uses code from a different clone of the GitHub repository.
  • I'd suggest using different databases for them if you can (as having different codebases talking to different databases can cause problem).
  • When you have changes in your dev instance that you want to put onto staging (I'm assuming you're developing on your own machine) then you push to github, then pull into the clone into the staging website's clone of the repository, then reload the staging website.
  • If you want to patch something in staging, you can just do it there then push to github, pull back to local.
  • When you want to go live, just pull into the live website's clone of the codebase and reload the site.

Let me know if any of that's unclear -- a bit of Q&A here and we'll probably have the core of the blog post :-)

+1 on the blog post!

Is there a way to restrict acces to the staging site (white-listed IPs), or do you think the built in password protection feature for web apps would be sufficient?

The password protection will prevent the staging site from being picked up by crawlers, so it won't be indexed. If you need better security for your staging site, you should implement a user auth system on the site in addition to the password protection.

Thanks Giles,

I have questions but I think I'll start with having a go and seeing how I get on. I think it would be good if each app could have a testing app to go with it as you'll quickly run out - not sure qhat the implications for you are though.

Should I have two separate repositories one for live and one for staging or should I be using branches?

Yea, thinking about it, I'll want to have my one repo with a staging branch which I can pull into my staging site and then I can push pull as required... I think :)

Yes, you probably want staging and live to be 2 different branches in the same repo. There's some more detail about the whole process in a blog post

Thanks!

Thanks Giles,

Got everything set up in about half an hour, pretty good considering I've not done it before - PA made it a painless experience and I'm finally appreciating the power of git hub as well as not bothering my beta testers with constant reloads (I develop, mostly, direct in the browser).

Really appreciate the time and explanations.

Excellent! Glad you got it working. Did you hit any problems that you think would be worth covering in the blog post?

I think just making it clear regarding subdomain within PA - easy when you know how though a link to the docs will be enough (could be a tool tip within the application?).

Part of it is learning github or git but I think you can get away with knowing pull, push, add, commit and branch and you're good to go - I'm just learning as I'm going.

OK, thanks! Out of interest, did you find any decent git tutorials? I learned using Git Immersion, but I think that might be a kind of niche thing -- it's very much targeted towards people who learn bottom-up rather than top-down.

I just ran through this... https://guides.github.com/activities/hello-world/ but I took the time to actually set up a hello world repo and that was it - still getting the hang of branches, I keep forgetting to 'check-(it)out' lol. Enjoying it though.

Thanks! Will take a look.