GithubHelp home page GithubHelp logo

dickermoshe / zappadock Goto Github PK

View Code? Open in Web Editor NEW
18.0 4.0 3.0 59 KB

A CLI tool for running Zappa in AWS Lambda-like Docker containers.

License: GNU General Public License v3.0

Python 100.00%
python python3 django flask zappa zappa-flask zappa-django docker aws-lambda aws

zappadock's Introduction

ZappaDock

Downloads

Install

It's dead simple :

$ pip install zappadock

Usage

  1. Check that the Docker daemon is running by typing docker info command from a terminal.

  2. Set your AWS credentials in environmental variables or in the ~/.aws folder. See the Amazon Docs for more information.

  3. Run zappadock in the directory you wish to run your Zappa commands.
    Your directory will be loaded in a docker container, and a virtual environment will be created and activated.

  4. To run the built-in servers:

  • Django:
    python manage.py runserver 0.0.0.0:8000
  • Flask:
    flask run --host=0.0.0.0 --port=8000

If you have any problems, open a issue and we'll figure it out.

About

This package makes dealing with Zappa a walk in the park.

How ?

Zappa runs Flask/Django web apps on AWS Lambda.
We LOVE Zappa. However it's not the MOST user-friendly application ever.

Why ?

You see, Zappa builds all your requirements before uploading your app to AWS Lambda. However, pip downloads the packages that are compatible with the computer it is running on, so when Zappa uploads it to AWS Lambda, many packages don't work (notably psycopg2 among others).

What's the solution ?

The solution recommend by the The Django Guide for Zappa is to run your Zappa commands in a docker container similar to the one that AWS Lambda uses.
This will ensure that all the dependencies will be AWS Lambda compatible. This ZappaDock streamlines the workflow.

What Does ZappaDock Do ?

ZappaDock does 3 things.

  1. Run a docker container with your code mounted.
  2. Load your AWS Credentials from the ~/.aws folder and environmental variables into the container.
  3. Create and activate a virtual environment inside the container.

So now you can test and deploy your code confident that it will work once deployed.

Contributing

I mostly made this for myself. If you want to help make this a masterpiece, be a sport and contribute.
Thanks!

zappadock's People

Contributors

dickermoshe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

zappadock's Issues

Suggestion using zappadock with credentials file

Hello, I had a problem with starting zappadock for a fresh project.
Before I started using zappa to deploy the simple application and I had configured .aws/credentials and .aws/config for development before.
In config have set default region for usage with aws.
I lost half-hour to check what is wrong and why.
Zappadock searching for aws region only in .aws/credentials ignoring .aws/config. Error message misleading that configuration for aws is wrong and pointing documentation where no information about setting region needed.

I suggest one of:

  • adding information in readme.MD that region variable region in .aws/credentials profile is mandatory,
  • adding some kind of message information that one of the needed variables in credentials profile is needed,
  • adding handling .aws/config inheritance default profile for profiles in .aws/credentials.

No such file or directory ../bin/python

Hello! First of all, thanks for this repo, it's a really helpful tool!

I had just set up my docker image through ZappaDock and was able to install all packages & have my flask app run as well.
Now, when I tried running the zappa deploy command I received the following error:


`/var/task/zappa-venv/lib/python3.9/site-packages/_distutils_hack/__init__.py:36: UserWarning: Setuptools is replacing distutils.
  warnings.warn("Setuptools is replacing distutils.")
Oh no! An error occurred! :(

==============

Traceback (most recent call last):
  File "/var/task/zappa-venv/lib/python3.9/site-packages/zappa/cli.py", line 3422, in handle
    sys.exit(cli.handle())
  File "/var/task/zappa-venv/lib/python3.9/site-packages/zappa/cli.py", line 588, in handle
    self.dispatch_command(self.command, stage)
  File "/var/task/zappa-venv/lib/python3.9/site-packages/zappa/cli.py", line 630, in dispatch_command
    self.deploy(self.vargs["zip"], self.vargs["docker_image_uri"])
  File "/var/task/zappa-venv/lib/python3.9/site-packages/zappa/cli.py", line 852, in deploy
    self.create_package()
  File "/var/task/zappa-venv/lib/python3.9/site-packages/zappa/cli.py", line 2775, in create_package
    self.zip_path = self.zappa.create_lambda_zip(
  File "/var/task/zappa-venv/lib/python3.9/site-packages/zappa/core.py", line 635, in create_lambda_zip
    copytree(
  File "/var/task/zappa-venv/lib/python3.9/site-packages/zappa/utilities.py", line 69, in copytree
    copy_file(src, dst, item)
  File "/var/task/zappa-venv/lib/python3.9/site-packages/zappa/utilities.py", line 50, in copy_file
    copytree(s, d, metadata, symlinks, ignore)
  File "/var/task/zappa-venv/lib/python3.9/site-packages/zappa/utilities.py", line 69, in copytree
    copy_file(src, dst, item)
  File "/var/task/zappa-venv/lib/python3.9/site-packages/zappa/utilities.py", line 50, in copy_file
    copytree(s, d, metadata, symlinks, ignore)
  File "/var/task/zappa-venv/lib/python3.9/site-packages/zappa/utilities.py", line 69, in copytree
    copy_file(src, dst, item)
  File "/var/task/zappa-venv/lib/python3.9/site-packages/zappa/utilities.py", line 52, in copy_file
    shutil.copy2(s, d) if metadata else shutil.copy(s, d)
  File "/var/lang/lib/python3.9/shutil.py", line 427, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/var/lang/lib/python3.9/shutil.py", line 264, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: '/var/task/venv/bin/python'

Do you have any idea what this could have caused?

Thank you so much!

Exposing port on runserver?

Hi, I am trying to run locally but when I visit localhost:8000 is not displaying anything. Is there an easy workaround?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.