#How to deploy Django using Git for Docker?

58 messages ยท Page 1 of 1 (latest)

coral wagon
#

And another one, here we go

#

What do you mean, like CI/CD?

lavish ravine
#

Dang. The technical question response doesn't work in threads

#

Hi. You'll find people are more willing to help if you provide some details about your problem. A good starting point is answering what are you trying to do, what you expect to happen and what actually happened. If your answers are something like "Login to the site. To be logged in. It doesn't work", you're not providing enough detail. If you have an error, include the full error message and the traceback. For a more thorough discussion on how to ask good technical questions see:

https://www.freecodecamp.org/news/how-to-ask-good-technical-questions/ 
coral wagon
#

So like CI/CD, gotcha

Alright what you mean is how can you push your code to your servers. In other words, how you automate your deployment
Or in other, more used terms, You want to continuously do that

Putting those two terms together (drum roll please):
Continuous Deployment, CD

(Just to give the relevance of the terms used)

#

100 Points, yep

#

There is a billion ways of doing it, and a thousand right ways of doing it

I'd recommend looking into stuff like the gitlab-runner and jenkins (two big ones used for that stuff) and trying them out, see what you like best and what suits your needs

coral wagon
#

Those are two well known ones

They're popular for their own reasons
If you're using GitHub, then consider their pipeline automation stuff as well

#

CI/CD is a bit of a pain to get working sometimes, but its definitely worth the weight in frequently updating environments and multi-instance setups

#

For practically all of my customers, yes

It has become "the proper" way of doing things these days

lavish ravine
#

If you're building something small, it's fine to ssh into your instance and run a script. It doesn't have to be automated.

coral wagon
#

Anything where the time required to setup automation is somewhat on par with the development time, or time spent manually deploying

lavish ravine
#

If you're running everything on one instance

coral wagon
#

Is what i would say ๐Ÿ™‚

#

Without the dockerfile and/or the docker-compose we can't really help

But it sounds like the postgres database path wasn't mounted to the folder you thought it was

#

They aren't magic, mistakes can happen with CI/CD as well (even potentially worse, as its automated, if you ignore safeguards or don't properly handle errors)

But if you do something right once, CI/CI will let you replicate that behavior without human error in the middle

#

Looks pretty standard, i can't see why it wouldn't use the right folder, apart from the fact that you might share the database between environments (prod, dev, etc.)

#

I'd just guess that the database container didn't get recreated everytime and the container kept on running, you probably used the same credentials for all environments, so it was still able to connect

#

You can, and there is nothing bad about it

For dev it can be a bit annoying having different environments using some same resource, but i would consider it to be ok for a database (one database shouldn't have any influence on another anyways)

coral wagon
#

I don't really have a preference, i'm pretty much stuck with whatever that particular customer is using amyways

I'm running a forked version of gitea personally and i automated a lot of stuff using jenkins or custom scripts

coral wagon
#

Some customer just told me they are using jenkins and they use it for all their stuff

And off i went to read up some docs, set a test server up using docker and just try it out

coral wagon
#

Anything can be run in a container, its not some special thing

coral wagon
#

Just try it out on your machine, its gonna be fine

You won't need nearly as much

#

No, i just mean set it up, don't worry about the specs

Using docker makes trying out this stuff trivial

coral wagon
#

Progress though

#

I'm quite sure that it wont work tbh

coral wagon
#

Oooook i guess

coral wagon
#

I just used the default dockerfile back then iirc

I didn't have the time, or even inclination to rebuild all of that stuff tbh xD

coral wagon
#

Do try around, just because i did something differently, doesn't mean you won't get there (or even that i did it right to begin with)

coral wagon
#

They're certainly nice things to have

coral wagon
#

"Bare minimum" kind of depends on what you want to automate specifically, but a git repo surely is a good thing to have regardless.

A django web server (i'm guessing you just mean any server on which you can run your stuff) is also great to have

Jenkins is a requirement if you want to use jenkins of course ๐Ÿ˜›

scenic fog
#

I had the same problem, it's about the permissions of the .sh file.
I hope it helps!

coral wagon
#

chmod +x to the entrypoint possibly?
or what do you mean?

coral wagon
#

Just skip windows

If you have to use windows, or REALLY want to, use wsl for some stuff

It can become a chore to develop on windows (thats not to say its impossible or anything though)

coral wagon
#

What container image did you end up using for letsencrypt?

#

there are a few popular options out there, just wondering

#

ahh certbot, aight

#

Nothing ever is, pat it on the head and keep going

#

Don't worry about too many details, you're still trying to get this to work to begin with

You won't be able to get everything perfect on the first run (quite impossible)

Iterate over it and keep going

#

Why?

#

What's there to update?
You just have to write your nginx.conf once and you're done

Just make sure certbot keeps putting the files at the same location with the same name, and nginx is reloaded when the certs are rotated

#

there are even "ready" docker containers for that stuff, which basically take care of that for you

#

That one seems popular ๐Ÿ˜›

#

acme-companion + nginx-proxy + nginx = seems ok

#

If you deploy your project on some platform which takes care of the certs for you, you can then just don't include the first two containers in your docker-compose and your stuff will still work

All has its place in that sense

coral wagon
#

Yep

A lot of people use services like cloudflare to just take core of that stuff for them

Although you should imo understand how that stuff works as you maybe don't always want to depend on a third party for everything

coral wagon
#

Imagine a big, fat nginx infront of your service
Now rewrite that in go, because nginx is actually not fast enough for cloudflare anymore (which makes you appreciate the sheer scale they are working at)
Nginx is the most efficient of its kind, yet not enough for cloudflare

They have a lot (like thousands - or more) of proxies which all load balance between each other, they just swap the cert practically during runtime iirc

#

Nope; Cloudflare is a cloud service

#

You just expose your stuff to only their endpoints and then you set your DNS entries to point to their load balancers

#

Request -> Cloudflare -> Internet -> Your machine

#

Thats the gist of it anyways

#

huh?

#

I had no idea

But a lot of companies are using cloudflare for ddos protection in that sense

#

As cloudflare sits infront of your service, and they are HUGE, like absolutely enormous, they can just chew through a lot of ddos attacks

They just have the bandwidth for those kinds of things

#

They also do some other stuff like trying to figure out if something sent by the user is obviously malicious (those features can be disabled, of course)

#

They have a free tier

#

Loads of individuals are using it too

This isn't something just for big companies