I would like to deploy my django project to AWS Elastic Beanstalk. My project was not create through eb-virt. Do I need to redo the project again in eb-virt? I have no idea of how to deploy my project directly.
It is always recommended to work on a virtual environment. it is important because you can have your very own python environment with all the modules you need for the app installed. The good news is that it's not yet late to create the virtual environment.
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html
to setup the project
goto your folder
create the virtual environment using virtualenv ~/eb-virt
activate the virtual environment source ~/eb-virt/bin/activate
install django pip install django==2.1.1
create the requirements.txt file by running pip freeze > requirements.txt. because elasticbeanstalk can install the dependecies mentioned in this file.
do the 3rd to 5th steps from the link above
to deploy
follow the deploy section, basically
init the project eb init -p python-3.6 django-tutorial
create an environment eb create django-env, we used to have Dev, staging and production environments
continue steps 4th to 7th
Related
I made a website using mezzanine-Django , and used conda env to contain it (I should have used virtual env).
but the fabric file is tuned to only deploy virtual envs. What should I do to get my conda env up in the VPS , is there an easy way or should I be installing every packages inside manually?
I would assume you have already created the virtual environment, then what you have to do is:
Put all python packages you want to install for your project inside requirements.txt
from fabric import task
#task(hosts=["servername"])
def do_things(c):
with c.cd('your_dir'):
# assuming you already added myenv to your path
with c.prefix('source activate myenv'):
c.run('pip3.6 install -r requirements.txt') #for example if you have pip3.6
You have to use with c.prefix() to enable using that environment! And remember you have to run everything within the scope of with c.prefix('source activate myenv'): if you want to use the virtual environment.
I'm not sure if this is Docker, the Elastick Beanstalk, or docker image issue related, but my problem is that I'm running the command eb local run to start the local environment alongside with docker.
Expected behavior
The command runs seamlessly
Actual behavior
ERROR: DockerVersionError - Your local host has the 'docker-py' version 1.10.6 Python package installed on it.
When you run a Multicontainer Docker application locally, the EB CLI requires the 'docker' Python package.
To fix this error:
Be sure that no applications on your local host require 'docker-py', and then run this command:
pip uninstall docker-py
The EB CLI will install 'docker' the next time you run it.
$ eb --version : EB CLI 3.12.2 (Python 2.7.1)
$ docker -v : Docker version 17.12.0-ce, build c97c6d6
If you want to launch multi-container Dockers using eb local run, you need to have uninstalled docker-py, and installed docker
As the error message indicates:
perform pip uninstall docker-py ** if you don't need it **.
run pip install "docker>=2.6.0,<2.7" immediately after
docker and docker-py cannot coexist. These release notes highlight the change in the package name. These release notes allude to the breakage the change in package name caused.
Not to be confused with Docker, the engine/client, docker-py/docker is a Python wrapper around the Docker client which the EBCLI relies on.
Good day.
I'm a newbie to Django and I have a slight confusion:
When deploying my Django app, do I need to deploy it with all the Python 'come-with' modules, or the hosts already have them installed.
Also, I installed PIL for image manipulation. Would they also have it installed or i have to find a way to install it on their servers. Thanks in advance
do I need to deploy it with all the Python 'come-with' modules
Never do that. It might conflict with the dependencies on the server. Instead issue the following command to create a dependency file (requirements.txt).
pip freeze > requirements.txt (issue this command where manage.py is located)
On the server create a new virtual environment. Now copy django project to the server (you can do this using git clone or just plain old Filezilla). Activate virtual environment. Then change you current working directory to the where manage.py is located. to install all the dependencies issue the following command.
pip install -r requirements.txt
This will install the required dependencies on on server.
I am trying to deploy a django website project with 3 apps on heroku. In the heroku website it is mentioned to activate virtual environment before deploying apps. But the venv file is taking a lot of space (actually it is taking the 50% of the space of my project) and deploying it is taking a lot of time. I hope for a nice answer. :)
Whether you use a virtualenv in your local development is up to you, but in either case you'll have to specify a requirements.txt file so Heroku knows what Python packages/dependencies to install.
Creating a minimal requirements.txt is very easy using a virtualenv, as outlined in Heroku's tutorial for Django.
pip freeze > requirements.txt
I'm using Elastic Beanstalk to deploy my application as a Single Docker Application.
My Dockerfile does composer install while deploying, but I get a Could not authenticate against github.com error.
I use these lines in my Dockerfile to install my dependencies:
WORKDIR /www
RUN ["composer", "install", "-o"]
How would I solve this issue?
I think you need to configure composer inside your container with your key or something like that, remember that inside your container you're basically on another os and you don't have public keys etc.
I'd try to install it from source rather than from git (as you don't have keys).
try this:
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer ()