Code Monkey home page Code Monkey logo

takeoff-env / takeoff Goto Github PK

View Code? Open in Web Editor NEW
271.0 12.0 17.0 1.01 MB

A rapid development environment using docker for convenience.

Home Page: https://takeoff.sh/

License: MIT License

JavaScript 10.46% Ruby 11.07% HTML 4.64% TypeScript 70.30% Shell 3.54%
docker node hapi react postgresql development development-environment ngnix devops devops-tools developer-tools frontend dockerfile jwt redux database router convenience hacktoberfest

takeoff's Introduction

Takeoff Rapid Development Toolkit

Takeoff is a toolkit for rapid development, allowing you to prototype web applications using it's command line tool.

Installed via npm you can find a list of commands via takeoff help for creating and managing Takeoff environments and projects. Projects are created based on Blueprints.

Install Takeoff

Installing takeoff is simple, via NPM.

npm install -g @takeoff/takeoff
takeoff init <myenv> # Creates an environment for your projects, if not passed will create a folder called "takeoff"
cd <myenv>
takeoff start # This starts the project in `projects/default`

This creates an initial "Environment" - folders containing blueprints, projects and commands, alongside a .takeoffrc file. Blueprints are the heart of Takeoff and allow a way to easily distribute projects for Proof of Concepts, Hackdays, Code Camps and many more uses. A blueprint is used to create projects, essentially a working environment that contains the project sources and docker file. Commands are custom scripts you can add you any blueprint that are shipable.

It starts with a blueprint

Blueprints are repositories with some batteries included applications and configurations for containers. Takeoff uses these to build a full working environment in minutes. A blueprint generally contains a backend component, a frontend, a database and an ingress server.

Currently Takeoff only ships with the default blueprint (but it's relativly easy to create new ones!) called takeoff-blueprint-basic and it provides:

Configuring the Blueprint

Configuring the setup of the blueprint application is done via a very easy takeoff.md file included in the root directory.

You can find an example file here with details on how it works.

Default Blueprint

The default blueprint for API comes batteries included:

  • A node API server powered by Hapi and written in TypeScript. Included in the application is a User system for username/password login and basic user management, 2 levels (admin and user - and easily extendible). There is also a JSON Web Token (JWT) authentication system that gives you control over access to your API endpoints.

  • An Angular Frontend with Bootstrap 4. The frontend comes with a basic Dashboard layout and homepage. A login page with some basic validation allows you to log in (the default login is admin/password). There are some additional components in development, but this is enough to get started on a basic app.

Do not expect this to be a fully secure environment. Once logged in you have a basic user CRUD application to manage users, and a navigation bar that you can customise. Disclaimer: If you build an app with this you wish to deploy, you are responsible for your own security.

  • A MongoDB database using Mongoose to make model development easy. There is a basic user table and seeded admin user provided. It's easy to add your own models, or update pre-existing ones.

  • A Nginx ingress server, by default running on port 80 (which means you get http://localhost or http:// as your address. If you cannot run on port 80, it can be configured in the docker-compose.yml by changing the first number of the pair (e.g "8080:80")

Under the hood it uses docker and docker-compose to minimise the hassle of setting up frontend, backend and database servers.

The best part though is of course kept till last.

Using Docker volumes, the development files for the applications sit on your local computer file system, however the applications run within docker and reload on changes. This means you can switch between your code and browser in seconds and see the changes and not have to worry about manually compiling before seeing your changes. Node Modules have their own volume inside the container, so your local ones won't be affected.

On the server side this is accomplished with nodemon and on the clientside with ng serve using page reloading.

Each container also has an internal volume for node_modules so there are no issues with cross-OS compatibility.

If you ever get disconnected from your docker sessions afer starting them up, you can type takeoff start again and you will reconnect to see any log output.

Why Takeoff?

Takeoff is designed to cut out those first few crucial hours where you are setting up your project environment, such as babel and webpack configurations, user authentication or even just selecting a framework. It's perfect for hackdays, rapid prototypes, or teaching new coders by having a pre-configured environment in just 4 simple commands.

It cuts out the scary/annoying bit and gets right to the fun bit!

System Dependencies

This software has some dependencies, and currently has only been fully tested on Linux using Docker Community Edition.

First install this, once installed you will have the docker and docker-compose commands. You also need git and it's recommended you have node >= 10.0.0.

Up and running

You should now have a server running at http://localhost. You can access the API via http://localhost/api.

The default blueprint (takeoff-blueprint-basic is installed as the default environment in the env and blueprints folders.

After installing, you will have this folder structure in your Takeoff environment:

    -|- .takeoffrc
     |- blueprints/default # The basic blueprint that Takeoff ships
     |- project/default # The default environment installed
        |- takeoff.md
        |- env # Folders with the source code you can change
            |- api # This is the Hapi API Server
            |- frontend-app # Angular application
            |- nginx # Nginx configuration
        |- docker # This is where all the docker configurations are kept
            |- docker-compose.yml # The glue file for your services
            |- api # This is the Hapi API Server
            |- frontend-app # Angular app docker file
            |- nginx # Nginx configuration

Blueprint Cache

When you install a new blueprint, it is cached in the blueprints folder; this way when you create a new project below it uses your local copy. If you want to update a blueprint, you can type takeoff blueprint:update [name]. The default one is installed as basic for now. You can also install new blueprints via takeoff blueprint:add [name] [git-url].

.takeoffrc

The .takeoffrc file is a JSON configuration file that is used to define the root folder of an environment. When takeoff runs, it will parse this file and provide it as properties available to commands. The file can also have the .json extension if you prefer.

Creating new projects

When you want to create a new environment you can type:

takeoff new [environment] [blueprint-name] --blueprint-url
# Both blueprints here are optional, the first uses the local cache the second specifies a remote
takeoff start [environment]

This will start up your new named environment using the default blueprint if no name is specified. It's good to make sure you have stopped any other environments running unless you have changed ingress port assignments.

Custom Commands

Takeoff supports custom commands with it's drop-in and easy-to-use API. These are JavaScript or TypeScript files that give you access to do tasks within a Takeoff project, such as custom installers or seeders.

By adding a command to the environments command folder with a group and command option, it becomes available to users of your blueprint, and can be run as part of your setup too.

You can checkout the Custom Commands Documentation for more details.

Platform Support

Currently only Linux is fully tested and supported out of the box, but support for other OS is coming (testers and contributors welcome!). There is a page for Windows Users to provide extra information in the quest to get it working.

Documentation

References

takeoff's People

Contributors

rococtz avatar tanepiper avatar toddpress avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

takeoff's Issues

Discussion: "environment" nomenclature in the documentation is confusing

For me an environment is "production", "staging", etc.

When I ran takeoff init <env> I was expecting it to be structured in a way that reflected this and allow me to add alternative environments based on the same overall source code, but it seems to be more of a "workspace", ie a collection of projects and configuration.

Further more, the Angular app itself appears to talk about environments, including the code:

if (environment.production) {
  enableProdMode();
}

Have I misunderstood the intention or would an alternative name (like "workspace") be more appropriate?

Custom names for commands

As a users, for the following commands: build, up, down I would like to be able to just pass a name of an environment and have it be build if the settings are available, otherwise display me an error.

Currently the command is hard coded as npm run build:dev.

Instead if should be npm run build (--)dev. It may need a switch depending on the library used.

Based on the name, the Dockerfile. files are used, as well as other environmental settings.

Help: frontend-app - Module not found after adding material

Expected Behavior

App should compile after adding material.

Actual Behavior

App doesn't compile and complains that it can't find the module:

Module not found: Error: Can't resolve '/home/envuser/apphome/node_modules/@angular/material/prebuilt-themes/indigo-pink.css' in '/home/envuser/apphome'

Steps to Reproduce the Problem

  1. takeoff init material
  2. cd material/projects/default/env/frontend-app
  3. ng add @angular/material --project=frontend-app
  4. takeoff start

Workaround is to copy the css file in to the theme folder and update angular.json.

Specifications

  • Version: 2.0.8
  • Platform: macOS 10.13.6 (High Sierra)
  • Subsystem:

Bug: live reloading does not work

Expected Behavior

After making changes to frontend-app it should automatically reload.

Actual Behavior

The app does not automatically reload. (Restarting the docker instance forces it.)

Steps to Reproduce the Problem

  1. Create a new project
  2. Edit a file in the project, e.g. change something visual in src/app/components/home/homepage.component.ts
  3. Running ng serve explicitly does support live reloading

Specifications

  • Version: 2.0.8
  • Platform: macOS 10.13.6 (High Sierra)
  • Subsystem:

Build CI Pipeline

Should be able to test that any release is stable between backend and frontend via end-to-end testing. Do this via pipeline (such as CircleCI)

Windows docker-compose build fails

Output:

events.js:182
      throw er; // Unhandled 'error' event
      ^

Error: spawn sleep ENOENT
    at exports._errnoException (util.js:1016:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:189:19)
    at onErrorNT (internal/child_process.js:366:16)
    at _combinedTickCallback (internal/process/next_tick.js:102:11)
    at process._tickCallback (internal/process/next_tick.js:161:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] to:build: `node utilities/takeoff/docker-compose-build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] to:build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Will require further debugging

Suggestion: Fail fast if docker-compose is unavailable

Expected Behavior

takeoff init <env> should fail fast if docker-compose is not available.

Actual Behavior

takeoff init <env> runs and does some stuff then shows an error if docker-compose fails. Would be nicer for newbies like me to get that message first before it creates a load of stuff in the environment folder as it's not clear how to continue once docker-compose is installed.

Steps to Reproduce the Problem

  1. Without docker-compose installed, run takeoff init <env> where is an environment name

Specifications

  • Version: 2.0.8
  • Platform: macOS 10.13.6 (High Sierra)
  • Subsystem:

remove CODE_OF_CONDUCT, fork into separate project 'takeoff-social'

Hello, I cannot use software dependencies which require HR and legal confirmations outside of the standard license files.

Please consider to fork the project into a separate 'takeoff-social' which can contain a version of takeoff with the added non-code materials and social policies for people working on the takeoff project.

Bug: commands folder has } character in name

Expected Behavior

The commands folder should not have a } character in the name.

Actual Behavior

After running takeoff init <env> and then cd in to the folder I see the following:

drwxr-xr-x  3 brindy  staff  96 15 Sep 16:11 blueprints
drwxr-xr-x  2 brindy  staff  64 15 Sep 16:11 commands}
drwxr-xr-x  3 brindy  staff  96 15 Sep 16:11 projects

Steps to Reproduce the Problem

  1. Run `takeoff init where is an environment name.
  2. cd in to the folder
  3. Run ls -la

Specifications

  • Version: 2.0.8
  • Platform: macOS 10.13.6 (High Sierra)
  • Subsystem:

Takeoff CLI Proposal

As a Takeoff User
I want to use a CLI tool to control my environment

This tool should do will be deployed via npm install -g takeoff-env and will provide the takeoff cli command.

Benefits of moving to a CLI tool allow for a simpler install process, no need to clone a repo and this allows for the creation of multiple environments.

This list below also represents a task list for command that are not yet implemented, but v1.2.0 will release with a 1:1 mapping of all existing commands.

It will have the following commands and arguments (please note this list is not yet exhaustive as of first creation)

Default Arguments

These are default arguments that all commands take:

  • takeoff init <envname>
    This command will create a folder that will be the users Takeoff environment, in here we create a place to cache blueprints, create environments to run, and allow users to extend commands (similar to gulp).

It will take the following arguments:

  • --no-default: Creates a plain folder with no default environment
  • --blueprintName: The name of a known blueprint from the blueprint repo, used for the default blueprint.
  • --blueprintUrl: URL to a git repository containing a blueprint, used for the default blueprint.
  • takeoff new <envname>
    This command is used within a Takeoff folder and creates a new environment. With no arguments it will make a clone of the default blueprint as a fresh new environment with a new name. If you pass arguments you can create different environment types.

It will take the following arguments:

  • --blueprintName: The name of a known blueprint from the blueprint repo, used for the default blueprint.
  • --blueprintUrl: URL to a git repository containing a blueprint, used for the default blueprint.
  • takeoff start <envname>
    This will start the environment. At the end we should hand command back to the user, so possibly look at using this command to mux the environment.

  • takeoff stop <envname>
    This will rebuild the environment.

  • takeoff build <envname>
    This will rebuild the environment.

  • takeoff pull <envname>
    This will pull the pre-built docker images in an environment.

  • takeoff rm <envname>
    This will remove and environment

  • takeoff clean <envname>
    This will clean an environment by removing caches and things like node_modules, but will leave the source files

Todo:

  • Provide plugin format for commands
  • Provide way to read commands from environment and directory as well as application defaults

Reported: Unable to run docker compose file

Reported here: https://medium.com/@GarrettHogan/tried-to-clone-the-repo-and-run-locally-and-i-got-a-docker-error-service-version-doesn-t-have-85b7d15901ac

Developer response: I believe it's due to the user running the pip version of docker-compose which doesn't support version 3 of the compose files.

The fix is to uninstall any existing version of docker and docker-compose and install docker-ce (Docker Community Edition) which includes both.

I have asked the user to confirm their docker version

  • Request User to check their docker and docker compose version
  • Advise user to try steps above
  • Confirm this issue is related to outdated docker versions

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.