Simple Docker Ubuntu cron-tab setup with Python script.
- Click 'Use this Template'
- checkout your new project:
git clone git@github.com:<your-github-name>/<created-project-name>.git
- jump into folder and run:
make init
- creates the default .env file (only if it doesnt exists already)
- creates a fresh python virtual environment
- put your (existing) python code into
src/
.- important: your main file should be named:
main.py
- important: your main file should be named:
- you can run your code with
make
ormake python-run
- if you want to add new pypi dependencies:
- put your pypi dependencies into requirements.txt
- run
make python-install
to setup a new python virtual environment
- in file
python-cron
configure cron schedule by replacing the * symbols (for help: crontab schedule builder) - running
make container
will build the cron-tab-docker-container and starting it with docker-compose - if you want to build and run independently use:
make container-build
to build the containermake container-run
to run the containermake container-run-detached
to run the container in the background
- you can add environment variables to env/.env
- all variables will be visible:
- in docker-compose.yml
- in your apps execution environment (local and contnainer)
- inital idea from https://stackoverflow.com/a/37458519/7423160