Skip to content

Commit 27fe7ea

Browse files
committed
Merge branch 'docs'
2 parents 553bc5e + a423960 commit 27fe7ea

File tree

6 files changed

+149
-5
lines changed

6 files changed

+149
-5
lines changed

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
### Essential Python Tools
22

33
[Essential Python Tools](https://books.agiliq.com/projects/essential-python-tools/en/latest/)
4+
5+
https://books.agiliq.com/projects/essential-python-tools/en/latest/

source/deployment/aws.rst

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,62 @@ Amazon Web Services
55

66
AWS is a Cloud platform service offering compute power, data storage, and a wide array of other IT solutions and utilities for modern organizations. AWS was launched in 2006, and has since become one of the most popular cloud platforms currently available.
77

8+
We should have an account in `AWS <https://aws.amazon.com/>`_ to use aws services.
89
It offers many featured services for compute, storage, networking, analytics, application services, deployment, identity and access management, directory services, security and many more cloud services.
910

10-
To use AWS for python, check `this <https://aws.amazon.com/developer/language/python/>`_
11+
To use AWS for python, check `https://aws.amazon.com/developer/language/python/ <https://aws.amazon.com/developer/language/python/>`_
1112

12-
We use `Boto3 <https://github.com/boto/boto3>`_ (python package) which provides interfaces to Amazon Web Services, it makes us easy to integrate our Python application, library, or script with AWS services
13+
We can use `Boto3 <https://github.com/boto/boto3>`_ (python package) which provides interfaces to Amazon Web Services, it makes us easy to integrate our Python application, library, or script with AWS services
1314

1415
Boto3 is the Amazon Web Services (AWS) Software Development Kit (SDK) for Python, which allows Python developers to write software that makes use of services like Amazon S3(Simple storage service) and Amazon EC2(Elastic Compute Cloud).
1516

16-
.. Boto provides an easy to use, object-oriented API as well as low-level direct service access.
17+
.. Boto provides an easy to use, object-oriented API as well as low-level direct service access.
18+
19+
20+
21+
22+
Amazon Elastic Cloud Compute (EC2)
23+
++++++++++++++++++++++++++++++++++++++++++
24+
`Amazon Elastic Compute Cloud (Amazon EC2) <https://aws.amazon.com/ec2/>`_ is a web service that provides resizeable computing capacity.
25+
26+
We use Amazon EC2 to launch a virtual servers and also configure security , networking, and manage storage. It enables us to scale up or down depending the requirement.
27+
28+
+ It provides virtual computing environments called as `instances`
29+
+ Various configurations of CPU, memory, storage, and networking capacity are available for our instances, known as instance types.
30+
31+
32+
33+
34+
35+
Amazon Elastic Beanstalk
36+
++++++++++++++++++++++++++++++++++
37+
`AWS Elastic Beanstalk <https://aws.amazon.com/elasticbeanstalk/>`_ is a service for deploying and scaling web applications and services.
38+
Elastic Beanstalk will also run instances (Computing environments) EC2, and it has some additional components like Elastic Load Balancer, Auto-Scaling Group, Security Group.
39+
40+
We pay only for the EC2 instances or S3 buckets and aws-DB we use and the other features like Elastic Load Balancer, Auto-Scaling Group, Security Group in Elastic Beanstalk do not cost anything.
41+
42+
43+
44+
45+
46+
Amazon Lambda
47+
++++++++++++++++++++++++++++++++++
48+
`Amazon Lambda <https://aws.amazon.com/lambda/>`_ is a computing service which automatically manages the server. AWS Lambda executes our code only when needed and scales automatically, from a few requests per day to thousands per second.
49+
50+
We only pay for the compute time we comsume , and there will be no charge if the code is not running.
51+
52+
The initial purpose of lambda is to simplify building on-demand applications that are responsive to events.
53+
AWS starts a Lambda instance within milliseconds of an event.
54+
55+
56+
57+
58+
Deployment in AWS services:
59+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60+
Once we connect with the server using ssh , then the deployment will be same for all services. Which is same as in the example mentioned in the next chapter
61+
62+
63+
64+
.. A comparision of the aws-services
65+
++++++++++++++++++++++++++++++++++++++++
66+

source/deployment/docker.rst

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,94 @@ Containerization is an approach in which an application or service, its dependen
1313
The containerized application can be tested as a unit and deployed as a container image instance to the host operating system (OS).
1414

1515
Docker is an open-source tool for automating the deployment of applications.
16+
17+
18+
19+
Docker Compose
20+
++++++++++++++++++++
21+
`Compose <https://docs.docker.com/compose/overview/>`_ is a tool for running multi-container applications like for example a container with a DataBase and an application.
22+
We can start/stop multiple services using compose with a single command.
23+
24+
We can create multiple compose files each for production, staging, development, testing, as well as CI,
25+
and each will be isolated with each other.
26+
27+
To use compose
28+
29+
+ Create a :code:`Dockerfile` where all our environment configuration and initial packages are mentioned.
30+
+ Create a file :code:`docker-compose.yml` , and mention all the services which we would be using.
31+
+ Finally run :code:`docker-compose up` .
32+
33+
34+
:code:`Dockerfile`
35+
36+
.. code-block:: shell
37+
38+
FROM python:3.4-alpine # 1
39+
ADD . /code #2
40+
WORKDIR /code #3
41+
ADD requirements.txt /code/ #4
42+
RUN pip install -r requirements.txt #5
43+
44+
45+
46+
In the above file we
47+
48+
+ In :code:`#1` we are building an image starting with the Python 3.4 image
49+
+ In :code:`#2` and :code:`#3` we are adding directory :code:` . ` into the path :code:`/code` in the image and making it the working directory.
50+
+ In :code:`#4` and :code:`#5` we adding the requirements file to the :code:`/code/` directory and installing all requirements.
51+
52+
.. + In :code:`#6` we are running the command :code:`python app.py`
53+
54+
:code:`docker-compose.yml`
55+
56+
.. code-block:: shell
57+
58+
version: '3' # 1
59+
60+
services: # 2
61+
web:
62+
build: . # 3
63+
command: python3 manage.py runserver 0.0.0.0:8000 #4
64+
volumes: # 5
65+
- .:/code
66+
ports: #6
67+
- "8000:8000"
68+
depends_on: #7
69+
- db
70+
db:
71+
image: postgres
72+
73+
74+
+ In :code:`#1` we mention the docker version (which is 3)
75+
+ :code:`#2` defines two services, web and db.
76+
77+
+ The :code:`web` service uses an image that’s built from the Dockerfile
78+
+ The :code:`db` service uses a public Postgres image pulled from the Docker Hub registry.
79+
80+
+ :code:`#3` tells to find the the dockerfile in the current directory
81+
+ :code:`#4` is a command to run the service .
82+
+ :code:`#5` tells the host paths for that service.
83+
+ :code:`#6` forwards the exposed port 8000 on the container to port 8000 on the host machine.
84+
+ :code:`#7` mentions the dependency between services
85+
86+
87+
88+
To use the docker compose , we use commands
89+
90+
.. code-block:: shell
91+
92+
$ docker-compose up # to create and start the containers
93+
94+
$ docker-compose build #to build or rebuild services
95+
96+
$ docker-compose up --build # build the services and start the containers
97+
98+
99+
100+
.. example of docker for deploying/development/testing for django/flask
101+
102+
103+
104+
**We write different `docker-compose` files for each Development, Testing, & Production.**
105+
106+

source/deployment/example_of_django_deployment.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Deploying a Django application using Gunicorn, Nginx, and Supervisord
1+
Deploying a Django application
22
------------------------------------------------------------------------------------------------------------
33

44
This chapter tells the basics of deploying a `django application <https://www.djangoproject.com/>`_ using gunicorn, nginx and supervisord.

source/deployment/fabric.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ stopping and restarting processes.**
1616
To install fabric :code:`pip install fabric`
1717

1818
Fabric, provides a command line utility, :code:`fab` which looks for a fabfile.py, which is a file containing Python code.
19+
1920
example fabfile:
2021

2122
.. code-block:: python

source/deployment/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Deployment
66
:caption: Various Deployment Options:
77

88
docker
9-
ansible
109
fabric
10+
ansible
1111
gcp
1212
aws
1313
example_of_django_deployment

0 commit comments

Comments
 (0)