docker-sand


Namedocker-sand JSON
Version 0.0.9 PyPI version JSON
download
home_pagehttps://github.com/gkpln3/Sand
SummarySand is a Dockerfile generator based on python that allows you to write your Dockerfile in a more convenient way.
upload_time2023-12-05 21:46:48
maintainer
docs_urlNone
authorGuy Kaplan
requires_python
licenseMIT
keywords sand docker dockerfile build
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Sand 🏝
[![.github/workflows/ci.yml](https://github.com/gkpln3/Sand/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/gkpln3/Sand/actions/workflows/ci.yml)

Sand is a Dockerfile generator.

It allows you to write cleaner, shorter and more configurable Dockerfiles.

## Developers ❤️ Sand
Sand is built by developers, for developers. It's built to be as simple as possible, while still being super useful.

## Installation
You can install Sand using pip.
```bash
pip3 install docker-sand
```

## Features
✅ Simple, easy to learn syntax based on Python.

✅ Configurable Dockerfiles. 

✅ Share code between Dockerfiles.

✅ Perfect for monorepos composed of multiple microservices.

✅ Supports multi-stage builds.


#### Planned Features:
    
🔘 Optimize builds by finding common layers between Dockerfiles, and merging them into a base image.

🔘 Minimizing the number of layers by combining multiple RUN commands into one.    


# Example
Write your Dockerfile in a Python-like syntax.
```python
# Sandfile
from sand import *

From("ubuntu", Tag="20.04")
Run([
    "apt-get update",
    "apt-get install ffmpeg python3"
])

# Install python debugger on debug images.
if config.DEBUG:
    Run("pip3 install pdb")

Copy("app", "/app")
Entrypoint("python3 /app/app.py")
```
⬇️
```dockerfile
# Auto-generated by Sand, do not edit!
FROM ubuntu:20.04
RUN apt-get update
RUN apt-get install ffmpeg python3
COPY app /app
ENTRYPOINT python3 /app/app.py
```

### Share Code
Because `Sandfile`s are just Python files, and are being evaluated in an hierarchical manner by using the `Sand` directive, you can easily share code between them.

Given the following directory structure:
```
my-monorepo/
│
├── tweet-service/
|   ├── src/
|   ├── ...
│   └── Sandfile
│
├── home-timeline/
|   ├── src/
|   ├── ...
│   └── Sandfile
│
└── Sandfile
```
You can write your `Sandfile`s like this:
```python
# ./my-monorepo/Sandfile
from sand import *

def MyService(name):
    From("ubuntu", "20.04")
    Run("apt-get install python3")
    Copy(Src="src", Dst="/app")
    Entrypoint(f"python3 /app/{name}.py")

Sand("tweet-service")
Sand("home-timeline")
```
```python
# ./my-monorepo/tweet-service/Sandfile
from sand import *

MyService("tweet-service") # Defined in ../Sandfile
```

```python
# ./my-monorepo/home-timeline/Sandfile
from sand import *

MyService("home-timeline") # Defined in ../Sandfile
```

This allows you to share code between your Dockerfiles, and keep them [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself).

This is similar to the way `add_subdirectory` works in [CMake](https://cmake.org/)


## Usage
Running Sand is as simple as running `sand` in your terminal.
This will generate Dockerfiles for all Sandfiles in the current directory.
```
$ sand config
Saving Dockerfile to backend/service1/Dockerfile
Saving Dockerfile to backend/service2/Dockerfile
Built successfully!
```
You can also watch for changes and automatically rebuild your Dockerfiles.
```
$ sand config -w
Watching for changes...
```

### Configuration
You can pass configuration values to Sand using the `-D` or `--set` flag.
```
$ sand config -DDEBUG=True
```
Or use a YAML file.
```yaml
# sand.yaml
DEBUG: True
```
```
$ sand config --values sand.yaml
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gkpln3/Sand",
    "name": "docker-sand",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "sand docker dockerfile build",
    "author": "Guy Kaplan",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/a4/cf/0da03cc317f820562a3ee2a19512ecda614d6689c4ea8b721bbd03beb945/docker-sand-0.0.9.tar.gz",
    "platform": null,
    "description": "# Sand \ud83c\udfdd\n[![.github/workflows/ci.yml](https://github.com/gkpln3/Sand/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/gkpln3/Sand/actions/workflows/ci.yml)\n\nSand is a Dockerfile generator.\n\nIt allows you to write cleaner, shorter and more configurable Dockerfiles.\n\n## Developers \u2764\ufe0f Sand\nSand is built by developers, for developers. It's built to be as simple as possible, while still being super useful.\n\n## Installation\nYou can install Sand using pip.\n```bash\npip3 install docker-sand\n```\n\n## Features\n\u2705 Simple, easy to learn syntax based on Python.\n\n\u2705 Configurable Dockerfiles. \n\n\u2705 Share code between Dockerfiles.\n\n\u2705 Perfect for monorepos composed of multiple microservices.\n\n\u2705 Supports multi-stage builds.\n\n\n#### Planned Features:\n    \n\ud83d\udd18 Optimize builds by finding common layers between Dockerfiles, and merging them into a base image.\n\n\ud83d\udd18 Minimizing the number of layers by combining multiple RUN commands into one.    \n\n\n# Example\nWrite your Dockerfile in a Python-like syntax.\n```python\n# Sandfile\nfrom sand import *\n\nFrom(\"ubuntu\", Tag=\"20.04\")\nRun([\n    \"apt-get update\",\n    \"apt-get install ffmpeg python3\"\n])\n\n# Install python debugger on debug images.\nif config.DEBUG:\n    Run(\"pip3 install pdb\")\n\nCopy(\"app\", \"/app\")\nEntrypoint(\"python3 /app/app.py\")\n```\n\u2b07\ufe0f\n```dockerfile\n# Auto-generated by Sand, do not edit!\nFROM ubuntu:20.04\nRUN apt-get update\nRUN apt-get install ffmpeg python3\nCOPY app /app\nENTRYPOINT python3 /app/app.py\n```\n\n### Share Code\nBecause `Sandfile`s are just Python files, and are being evaluated in an hierarchical manner by using the `Sand` directive, you can easily share code between them.\n\nGiven the following directory structure:\n```\nmy-monorepo/\n\u2502\n\u251c\u2500\u2500 tweet-service/\n|   \u251c\u2500\u2500 src/\n|   \u251c\u2500\u2500 ...\n\u2502   \u2514\u2500\u2500 Sandfile\n\u2502\n\u251c\u2500\u2500 home-timeline/\n|   \u251c\u2500\u2500 src/\n|   \u251c\u2500\u2500 ...\n\u2502   \u2514\u2500\u2500 Sandfile\n\u2502\n\u2514\u2500\u2500 Sandfile\n```\nYou can write your `Sandfile`s like this:\n```python\n# ./my-monorepo/Sandfile\nfrom sand import *\n\ndef MyService(name):\n    From(\"ubuntu\", \"20.04\")\n    Run(\"apt-get install python3\")\n    Copy(Src=\"src\", Dst=\"/app\")\n    Entrypoint(f\"python3 /app/{name}.py\")\n\nSand(\"tweet-service\")\nSand(\"home-timeline\")\n```\n```python\n# ./my-monorepo/tweet-service/Sandfile\nfrom sand import *\n\nMyService(\"tweet-service\") # Defined in ../Sandfile\n```\n\n```python\n# ./my-monorepo/home-timeline/Sandfile\nfrom sand import *\n\nMyService(\"home-timeline\") # Defined in ../Sandfile\n```\n\nThis allows you to share code between your Dockerfiles, and keep them [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself).\n\nThis is similar to the way `add_subdirectory` works in [CMake](https://cmake.org/)\n\n\n## Usage\nRunning Sand is as simple as running `sand` in your terminal.\nThis will generate Dockerfiles for all Sandfiles in the current directory.\n```\n$ sand config\nSaving Dockerfile to backend/service1/Dockerfile\nSaving Dockerfile to backend/service2/Dockerfile\nBuilt successfully!\n```\nYou can also watch for changes and automatically rebuild your Dockerfiles.\n```\n$ sand config -w\nWatching for changes...\n```\n\n### Configuration\nYou can pass configuration values to Sand using the `-D` or `--set` flag.\n```\n$ sand config -DDEBUG=True\n```\nOr use a YAML file.\n```yaml\n# sand.yaml\nDEBUG: True\n```\n```\n$ sand config --values sand.yaml\n```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Sand is a Dockerfile generator based on python that allows you to write your Dockerfile in a more convenient way.",
    "version": "0.0.9",
    "project_urls": {
        "Homepage": "https://github.com/gkpln3/Sand"
    },
    "split_keywords": [
        "sand",
        "docker",
        "dockerfile",
        "build"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a4cf0da03cc317f820562a3ee2a19512ecda614d6689c4ea8b721bbd03beb945",
                "md5": "245e1ac2214a1f13ccc1feb184311675",
                "sha256": "53f1b1f2c59ae70a14225aa519badd7cb22b7d6cbb9b041957466bfac43b78a5"
            },
            "downloads": -1,
            "filename": "docker-sand-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "245e1ac2214a1f13ccc1feb184311675",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8337,
            "upload_time": "2023-12-05T21:46:48",
            "upload_time_iso_8601": "2023-12-05T21:46:48.941694Z",
            "url": "https://files.pythonhosted.org/packages/a4/cf/0da03cc317f820562a3ee2a19512ecda614d6689c4ea8b721bbd03beb945/docker-sand-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-05 21:46:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gkpln3",
    "github_project": "Sand",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "docker-sand"
}
        
Elapsed time: 0.16528s