Giter VIP home page Giter VIP logo

dotrun's Introduction

dotrun

A tool for developing Node.js and Python projects

dotrun makes use of a Docker image to provide a predictable sandbox for running Node and Python projects.

Features:

  • Make use of standard package.json script entrypoints:
    • dotrun runs yarn run start within the Docker container
    • dotrun foo runs yarn run foo within the Docker container
  • Detect changes in package.json and only run yarn install when needed
  • Detect changes in requirements.txt and only run pip3 install when needed
  • Run scripts using environment variables from .env and .env.local files
  • Keep python dependencies in .venv in the project folder for easy access

Usage

$ dotrun          # Install dependencies and run the `start` script from package.json
$ dotrun serve    # Run the python app only
$ dotrun clean    # Delete `node_modules`, `.venv`, `.dotrun.json`, and run `yarn run clean`
$ dotrun install  # Force install node and python dependencies
$ dotrun exec     # Start a shell inside the dotrun environment
$ dotrun exec {command}          # Run {command} inside the dotrun environment
$ dotrun {script-name}           # Install dependencies and run `yarn run {script-name}`
$ dotrun -s {script}             # Run {script} but skip installing dependencies
$ dotrun --env FOO=bar {script}  # Run {script} with FOO environment variable
$ dotrun -m "/path/to/mount":"localname"       # Mount additional directory and run `dotrun`
$ dotrun serve -m "/path/to/mount":"localname" # Mount additional directory and run `dotrun serve`

Installation

Docker

First, install Docker. On Linux, you can install Docker snap instead.

Linux users may also need to follow the post install instructions to be able to run Docker as a non-root user.

Linux

To install dotrun run:

sudo apt install python3-pip
sudo pip3 install dotrun

Mac

To install dotrun on a mac you will need Homebrew (follow the install instructions on that page).

Then run:

brew install python3
sudo pip3 install dotrun

Requirements

  • Linux / macOS
  • Docker (Get Docker)
  • Python > 3.6 and PIP

macOS performance

For optimal performance on Docker we recommend enabling a new experimental file sharing implementation called virtiofs. Virtiofs is only available to users of the following macOS versions:

  • macOS 12.2 and above (for Apple Silicon)
  • macOS 12.3 and above (for Intel)

How to enable virtiofs

Add dotrun on new projects

To fully support dotrun in a new project you should do the following:

  • For Python projects, ensure Talisker is at 0.16.0 or greater in requirements.txt
  • Add .dotrun.json and .venv to .gitignore
  • Create a start script in package.json to do everything needed to set up local development. E.g.: "start": "concurrently --raw 'yarn run watch' 'yarn run serve'"
    • The above command makes use of concurrently - you might want to consider this
  • Older versions of Gunicorn are incompatible with strict confinement so we need Gunicorn >= 20
    • The update landed in Talisker but at the time of writing hasn't made it into a new version
    • If there's no new version of Talisker, simply add gunicorn==20.0.4 to the bottom of requirements.txt

However, once you're ready to completely switch over to dotrun, simply go ahead and remove the run script.

Automated tests of pull requests

The "PR" action builds the Python package and runs a project with dotrun. This will run against every pull request.

Publish

All the changes made to the main branch will be automatically published as a new version on PyPI.

To publish a new version manually, run:

docker buildx create --name mybuilder
docker buildx use mybuilder
docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag canonicalwebteam/dotrun-image:latest .

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.