Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/macostea/cage
Develop and run your Python applications in clean Docker environments
https://github.com/macostea/cage
Last synced: 23 days ago
JSON representation
Develop and run your Python applications in clean Docker environments
- Host: GitHub
- URL: https://github.com/macostea/cage
- Owner: macostea
- License: mit
- Created: 2016-10-13T07:55:29.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-11-04T04:29:58.000Z (about 5 years ago)
- Last Synced: 2024-04-14T13:10:17.846Z (8 months ago)
- Language: Python
- Size: 27.3 KB
- Stars: 354
- Watchers: 11
- Forks: 11
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- starred-awesome - cage - Develop and run your Python applications in clean Docker environments (Python)
README
# Cage
Develop and run your Python applications in clean Docker environments
Cage aims to be as easy to use and as familiar as possible.## Requirements
* Docker
* Python 3.5+## Installation
```bash
$ pip install pycage
```## Usage
NOTE: Docker should be running before using any of the Cage commands.
All commands should be run from your project directory!### Create a new cage
```bash
$ cage app:create
```This command will create a new Dockerfile in the root your project and initialize all the necessary environment files.
### Activate the new environment
```bash
$ source /bin/activate
```This command should be very familiar to [virtualenv](https://virtualenv.pypa.io/en/stable/) users. This adjusts your environment to make sure you use the caged python binaries.
### Run your project
```bash
()$ python
```Running a script with the caged python binary will build a new Docker image with your project files, create a new container using that image and run the python command you specified.
### Passing environment variables
You can pass environment variables to the cage by creating a **ENV** file in the root of your project. The file structure should be VAR=VALUE.Example:
```
AVAR=value1
BVAR=value2
```You can also place this file anywhere in your project. If it is not in the root of your project you can specify the path to it by passing the ENV variable when running a python script.
```bash
()$ ENV=path/to/ENV python
```### Expose a TCP Port
To expose a TCP port from the cage, use the PORT environment variable defined in your ENV file.Example:
```
PORT=5000
```Specifying it in the ENV file will also make it available in the cage so you can bind your apps to it easily.
### Working with requirements
The current version of Cage only supports dependencies **written in a requirements file**:
```bash
()$ pip install -r requirements.txt
```You *cannot* use any other pip commands with this version. This includes simple pip install commands like:
```bash
()$ pip install
```### Stop a cage
```bash
()$ cage app:stop
```### Deactivating the environment
```bash
(