Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
Disclaimer: I am a newbie to web development.
I built a program using Python, on Django framework. I am at a point where I feel ready to deploy my site, and make it go live.
After extensive research, I've noticed that every possible path to deployment requires me to use Git.
The problem is that Git is so hard to manipulate on my computer. I have the wrong version (I guess) installed, and my attempts to fix compatibility issue has been a nightmare (Im using Mac 10.7.5, and for some reason cant upgrade to newer MAC El Captain)
My question is this: Is there a way to deploy WITHOUT using Git? Evenmore, is there a way to deploy without the use of version control (I'm the only one building this site).
I just want the easiest path to deployment possible, since I am a complete newbie.
PS Please dont direct me to this link: Is git branches necessary for a single developer?
my questions is about the importance of using Git altogether.
For some platforms, git is required for deployment. Heroku, in particular, requires git for pushing changes to a remote defined on the command heroku create. See here for more details.
In other instances, you have more options, with the caveat that you may spend a lot of time configuring a system to do so and that you may suffer from the inability to have continuous deployment without downtime.
For example, using an Amazon EC2 instance or DigitalOcean, you essentially have a bare-bones Ubuntu installation upon which you control pretty much all facets of configuration, you would be able to send files to your remote instance via SSH or using one of their clients. In this case, you would generally do the following:
Shut down your Django server
Backup your existing application and DB, just in case
Upload the files for your updated application
Run any manage.py commands for migrations and updates
pip install -r requirements.txt to check for updated dependencies
Start your server up again
As stated before, git is not required for deployment, but most Django devs would highly, highly suggest you find the root of the issue you are having with git as it helps to protect against potentially devastating problems down the line and can greatly simplify deployment when your production environment is set up correctly.
EDIT: It's worth noting that git can provide deployment functionality when your deployment environment is set up properly, but deployment often is too complex a task to rely on git alone. A commonly used method is to use Fabric with a custom fabfile to automate deployment tasks. In tandem with git you gain version control, simplified deployment commands, and the ability to run tasks as part of your deployment.
Related
I just decided to jump into using docker to test out building a microservice application using AWS fargate.
My question really relates to hearing about many development teams using Docker to avoid people saying the phrase "works on my machine" when committing code. Although I see the solution to that problem being solved, I still do not see how Docker images actually can be used in development environment.
The workflow for anything above production baffles me. Example of my thinking is...
team of 10 devs all use docker, each pull the image from the repo to there container, with the source code, if they all have a individual version of the image, that means any edits they make to that image is their own and when they push back to the repo where none of the edits can be merged (along with that to edit a image source code is not easily done as well).
I am thinking of it in the say way as git -GitHub, where code is pushed to a branch and then merged to master to create a finished product.
I guess if you pull the code from the GitHub master and create the Docker image is the way for it to be used, but again that points back to my original assumption of Docker being used for Production environments over development.
Is docker being used in development, more so the dev can just test the feature on the container that ever other dev on the team is using so all the environments match across the team?
I just really do not understand the workflow of development environments with docker.
I'd highlight three cases where I've found Docker particularly useful, prior to a production deploy:
Docker is really useful for installing local dependencies. If your application needs a database, docker run postgresql with appropriate options. Need a clean start? Delete the container. Running two microservices that need separate databases? Start two containers. The second microservice is maintained by another team? Run it in a container too.
Docker is useful for capturing the build environment in the CI system. Jenkins, for example, can run build steps inside a container, bind-mounting the current work tree in, so it's useful to build an image that just contains build-time dependencies (which can be updated independently of the CI system itself).
If you're running Docker in production, you can test the exact thing you're about to run. You're guaranteed the install environment will be the same in the QA and prod environments, because it's encapsulated inside the same Docker image. A developer can debug problems against the production-installed code without actually being in production.
In the basic scenario you describe, an important detail to note is that you never "edit an image"; you always docker build a new image from its Dockerfile and other source code. In compiled languages (C++, Go, Java, Rust, Haskell) the source code won't be in the image. Even if you're "using Docker in development" the actual source code will be in some other system (frequently Git), and typically you will have a CI system that builds "official" images from that source code.
Where I see Docker proposed for day-to-day development, it's either because the language ecosystem in use makes it hard to have multiple versions concurrently installed, or to avoid installing software on the host system. You need specific tooling support to "develop inside a container", and if developers choose their own IDE, this support is not universal. Conversely, in between OS package managers (APT, Homebrew) and interpreter version managers (rbenv, nvm) it's usually straightforward to install a couple of things on the host. If your application isn't that sensitive to, say, the specific version of Node, it's probably easier to use whichever version is already installed on your host than to try to insert Docker into the process.
I am new to Docker and am experimenting with developing a Django App on Docker.
I have followed the example in this link here:
Currently I am developing my app and have made changes to various files within the web directory. For now in order to test my changes I have had to remove all my running containers, stop my docker machine, start my docker machine, attach docker machine, run docker-compose up. This is a timely process and is unproductive especially if I need to keep testing after small changes.
My question is if I make changes to the image (changes in the web directory) how can I update my container to reflect those changes or should I be doing things differently?
How do other people develop using Docker? what are your best practices?
You could use volumes to map host directory in container's web directory. Any changes in host directory will be reflected immediately without restarting container. See below post.
How to make a docker container directory accesible from host?
You can use docker-compose up --build to rebuild the image and container after making changes. It will automatically rebuild and restart any changed containers. There shouldn't be any reason to stop docker machine. If you are using a Mac or Windows PC, you can try the new beta app, which is a bit easier to use than prior versions.
Also see: https://docs.docker.com/compose/reference/
As for best practices, this probably isn't really the right forum unless you have a more specific question.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Is not efficient :).
I'm trying to learn django by building a simple app. I bought a hosting plan on webfaction, set up github account and a putty on my Windows machine. I'm writing the "code" on my Windows, pushing it to github repo, then connecting via putty to my webfaction account to pull from github.
This is extremely tedious and boring process and I can't help but wonder that I'm doing something wrong. Even fixing a simple typo takes a lot of time. Are developers writing everything server-side using vim? This sound even less encouraging. Can I do something to improve my workflow? How it's done by professionals?
To summarise Kit Sunde's answer: you shouldn't be deploying to the server until you've actually got a site to deploy. Normal development and testing is done locally, using manage.py runserver and a local db. This works fine on Windows.
You need to stop wasting your own time, which you are if you are editing code on the server. There are many reasons why you shouldn't deploy code that way the most important ones is that you'll waste time and also importantly is that you'll break things while users are looking at the site.
Setup a development server locally, this is why the django manage.py runserver exists. If you for some reason can't run it on windows, then install a server in virtualbox, mount the folder in windows where your code is and run it off that (this is what we do for our designers although we have a lot of dependencies).
There are IDE's out there that enables you to run Django via a GUI that you might find more comfortable, I use PyCharm and I hear good things about eclipse.
You'd save time if you learned how fabric worked so you can automate your deploy process. I am unsure how well fabric works on windows, but I'm sure you can use cygwin or similar to get it working.
A fairly basic example would be this one:
from fabric.api import *
env.hosts = ['ubuntu#example.org']
def deploy():
pid_file = "~/myproject/process.pid"
with cd('~/myproject/'):
run('git pull')
run('src/city_nomads/manage.py collectstatic --noinput')
# If the process isn't up we don't want the thing to exit.
with settings(warn_only=True):
run("cat {} | xargs kill -TERM".format(pid_file))
run("src/myproject/manage.py runfcgi "
"method=threaded "
"host=127.0.0.1 "
"port=8000 "
"pidfile={} "
"--settings=myproject.settings_release".format(pid_file))
It'll SSH into my server, pull the source, collectstatic, kill the process if it's there and then run django as fastcgi. I'm assuming you have nginx or apache set up to connect to Django on port 8000.
I have a django project (a django module/app some other modules that are used from the django one) that uses SQLite. This project is for a University course and now I am asked to supply it in such a way so that it may be installed on some server in our faculty. I'm not the one who's going to install it, and I will not be contacted in case of failure, so I am looking for the easiest, simplest way to supply the project for installation.
I have come across django-jython which supposedly allows one to create WAR files from django projects. However, in the Database Backends section, it says:
SQLite3
Experimental. By now, use it only if you are working on improving it. Or if you are really adventurous.
My overall goal is to deliver this project and I would appreciate any helpful advice. In particular:
Is there another way to pack a django project into a WAR file that supports SQLite?
Is it safe to use SQLite with django-jython in spite of this warning? If so, then how?
Is there any other simple way to pack a django project so that it'll be a piece of cake to install?
If the above answers are "no", then what does it take to change the configuration of the project to use MySQL instead?
You should look into Fabric for easy deployment. I haven't used it myself, but I've heard good things.
I've also had good success quickly and easily setting up servers using Gunicorn with Nginx as a reverse-proxy.
As others have said, using virtualenv, with pip, can quickly
get all your dependencies installed via requirements.txt (from virtualenv).
Some of these blog posts may help:
Tools of the modern Python hacker - virtualenv, pip, fabric
Basic Django Deployment - virtualenv, pip, fabric, rsync
Easy Django Deployment - very quick nginx and gunicorn setup
Edit:
As I reread your post I saw your last bullet point/question. Django is designed to be loosely coupled, meaning that there shouldn't (in most cases) be reasons that one app is dependant on sqlite vs mysql. If you don't need to save the data in the db, changing to MySQL is as easy as starting a mysql server on your machine, and changing the settings.py of your django project. This SO question may help
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I'm looking to deploy a django app on AWS (since I have some credit coupon) and am looking for a good place to read about it - mostly b/c I never used it before. thanks
looking for a good place to read about it
Here you go
I am a developer at BitNami, you may want to take a look at our free Django AMI. It is compatible with the AWS free tier.
2 new tutorials are given
realpython doc
and
Ashok Fernandez blog
The simplest approach is to simply spin up an EC2 instance, install nginx (mysql? and any other dependencies you might have) then follow the steps on the django site: https://code.djangoproject.com/wiki/DjangoAndNginx to deploying it. This basically goes through setting up a script to run "python [your app directory]/manage.py runfcgi host=127.0.0.1 port=8080" and setting up nginx to proxy requests to that port.
Another approach is to simply use a 3rd party tool like http://nudow.com to automate the deployment. For now the initial deployment I believe has to be done manually, however subsequent deployments can be done with one click. (and has other benefits like versioning)
I usually use Nginx on an EC2 instance
If you wish to deploy your Django app ASAP, without scratching your head :
You can use this script that I wrote:
Safely deploy your Django app in less 1 minute!
Instructions
Installing the DeployDjango script
$ wget https://raw.githubusercontent.com/yask123/DeployDjango/master/deploydjango.sh && chmod +x deploydjango.sh
From your Django App’s root directory (Where manage.py file exists).
$ sudo ./deploydjango.sh project_name
Done!
Visit http://ip-address-of-your-instance to see your web app live!