How are you guyz managing production/development

Greetings,
so i have a cloud server with gunicorn, nginx and django.
It is starting with the production settings as per settings file.
But how can i have seperated production and development and then just push to production.
Please advice. Thank you :slight_smile:
I am using lets encrypt certificate and i need the development to be with https
As it will be the same database. And maybe i need to makemigration all the time?
Is there some automatic tool?
Because when it is in production and i change someting, sometime the change is in production rightaway (i think)

“Just push to production” really isn’t a “Django” issue. There’s nothing within Django to do or facilitate that, because it’s extremely dependent upon the particular environment to which it’s being deployed.

What you really want to ensure is that your production environment is as separated from your development, testing, staging, qa, etc environments as possible. The less you share between them, the safer you will be.

Having said that, right now we have two different ways we’re deploying production Django systems - a straight “git checkout” followed by migrate and collectstatic commands, and a docker-compose build system (currently in the “still being developed” stage, about 50% manual effort while it’s being battle-tested).

There are automated tools to assist with this. We use gitlab as our main repository, and it has a comprehensive CI/CD suite that we’re trying to build from - but these types of systems take a bit of work to make them really useful and robust. This is not a trivial topic.

I hope this doesn’t mean that you’re doing development in the same directory from which you’re running production. If so, that’s the first thing you want to change.

Greetings,
Thank you for a detailed answer.

This is exactly how i am doint now. I just started and when i need development i put firewall to allow only my IP. As i was doing it i understand that this is not the best case. Therefor i’m writing for a suggestion :))

So lets say two seperate folders for develop and one for production. Lets say seperate DB???
But there must be nginx forwarding, so i must make additional entry for other port than 443?
I am understanding it correctly?

But what if you need a debug with the DB data on production? You would move the DB from production to devel and test it with that DB? Is it ussual for programmers to do like that?
I would say easier keep the same DB?
I was trying to google this stuff, but didn’t found specifics. Just some tutorials that didn’t answered my question fully.

You are doing git checkout, but if you need server side code to be internal not on public online platform, even if its lets say private?

I am not using docker. Would you suggest it as a mandatory thing due experience?

Lots of questions, hope I don’t miss any of the important ones.

Yes, absolutely! And, if you really want to be safe and avoid an embarrassing mistake, I’d even go so far as to running multiple instances of the database engine.

Yes and no. With nginx and uwsgi, you’ve got a number of different options:

  • Separate entries for different ports
  • Separate entries for different DNS names.
  • Multiple nginx instances (each on a different port)
  • Running your different versions under different uwsgi mount points.

There may be more - these are just the options we’re using.

Yes. You can also keep a third copy of your application - a mirrored copy of production pointing to a “debug” database - where that debug database exists in the same database engine as production. (PostgreSQL makes it really easy to replicate a database.)

Easier and more dangerous. It all depends upon how concerned you are with the integrity of your production database - and 40 years of experience have convinced me that you can’t be too careful with your data.

We don’t use github. We have a private gitlab server that stores our code - nothing is “public”.

“Mandatory”? No. Or at least “not yet”. Get comfortable with understanding deployment environments before adding another layer on top of it. But, at some point in time, yes, I would suggest becoming familiar with containers.

1 Like

Omg man, thank you for your time. Everything now make sence.
<3

Hi !
One quick question.
I have made changes on nginx, that if the IP of the connected user is not my own, then nginx will redirect to static under_construction.html file. What do you think can i use this solution when i am developing,then remove the redirect when im in production?

I wouldn’t worry about “removing it” between your development and production environments.

Typically, your production server has configuration files in a “sites-available” directory. One or more of those files are symlinked in your “sites-enabled” directory.

You could have both the redirect and regular configurations in separate files in “sites-available” and then swap between them as necessary in “sites-enabled”. It doesn’t hurt to have that kind of facility available at any time.

(Note: There may be a “cleaner” / “slicker” way of handling it, I’m not an nginx expert by any means.)

Thank you for info! <3

Good to read this. @ukrolelo
Thanks for sharing this I looking for this. I find this stuff here.