Skip to content

aliefee/up.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

up.sh

up.sh to automatically create Dockerfile and compose.yml for your projects.

It is useful especially if you are working on different projects different frameworks frequently.
Or if you want to get a glimpse on how to containerize your local app development.

3 minutes of reading the README and examining the example usage, you are good to go with up.sh

Requirements

To run scripts properly all you need is:
- Bash or Bash compatible shell
- Python3

Will run in almost any modern Linux distribution with no additional installation.
Should run in WSL and probably would run in Git Bash too (not tested yet)

*And surely you need Docker or one of its alternatives installed (Podman, Nerdctl etc.).
Latest versions to not run into compose file version related problems.

Installation

Just clone the repository and start examining up.sh and types directory

There are:

  • Types
  • Apps

Types are reusable scripts that do the magical part of creating Dockerfile and compose.yml files for your Apps. You can find them under types directory, edit them or create your own types when needed.

You need to define your Apps in apps.json file. This all you need to do to start using up.sh

Example Usage

1- Make your app directory ready

Let's create an example flask app:

mkdir ~/upsh-demo-app
# For this example we will use 'python3-flask' type
cat << EOF > ~/upsh-demo-app/app.py
from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, World!'

if __name__ == '__main__':
    app.run(debug=True) 
EOF
# and a requirements.txt 
cat << EOF > ~/upsh-demo-app/requirements.txt
flask
EOF

2- Config your app in the apps.json file

you may use apps.json.example as a template

cp apps.json.example apps.json
{
    "apps": [
        {
            "dir": "~/upsh-demo-app",
            "name": "my-app",
            "type": "python3-flask",
            "port": 5000
        }
    ]
}

3- Run the script

./up.sh my-app

And it will create Dockerfile and compose.yml inside /apps/my-app

..| apps/
.........| my-app/
................ compose.yml
................ Dockerfile

up.sh will run docker compose up -d right after creating the Docker files.

flask app


Purpose of up.sh

There is already mature toolings out there to simplify 'containerization' of local development with nice UIs and wrappings. I wanted to compose a tooling that lives in shell and gives a glimpse of how to Dockerize (or containerize) your local development. You will likely have the glimpse of bash scripting and running containers after giving up.sh a few tries.

What up.sh does essentially is simply:

  • creating Dockerfile and compose.yml for your app according to its type
  • running docker compose up -d

if you only want to create Dockerfile and compose.yml files

but don't want up.sh to run docker compose up -d you can comment out up_loop command in up.sh file

#up_loop

After creating Dockerfile and compose.yml files, you can just take your app folder to somewhere else and fly away from up.sh project. This is another fair use of up.sh. 🙃

you can make the script run with your favourite container engine that supports Docker Compose.

just change the value of CONTAINER_CLI in up.sh

CONTAINER_CLI="docker compose"

or

CONTAINER_CLI="podman-compose"

or

CONTAINER_CLI="nerdctl compose"

!!! Using the scripts in this project for production deployment or testing would be extremely dangerous! Use only in your local machine.

Contribution

This project is not intended to transform into another cli wrapper or a project with many configuration and a UI or whatsoever in the future.

I will try to keep scripts and the structure as intuitive and simple as possible in this repository.

  • new "type"s
  • bug reports (especially related with working with different terminals)
  • recommendations for better naming or even for new structure
  • best practices
  • any kind of feedback

are gratefully welcomed.

indefinite roadmap:

  • get rid of python and json files. make everything pure shell script
  • make sh-compatible
  • tests

+Personally I am a fan of podman's daemonless runtime and currently interested in switching from compose to podman kube play for my local dev env. In the future, I may add that functionality to up.sh or create a seperate script for that purpose.

Telegram group

License

Mozilla Publich License 2.0