Coder Social home page Coder Social logo

jangocheng / cli-3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from create-go-app/cli

0.0 0.0 0.0 3.98 MB

✨ A powerful CLI for Create Go App. Create a new production-ready Golang project by running one CLI command!

Home Page: https://create-go.app

License: MIT License

Go 100.00%

cli-3's Introduction


Create Go App CLI

Create a new production-ready Go project by running one CLI command!

cli version go version go cover go report license

⚡️ Quick start

Let's create a new project into ./app folder with Fiber as backend and Nginx as web server:

cgapp create -p ./app -b fiber -w nginx

Okay, it works! Now, you can deploy this project to a remote server or run on your local machine in isolated Docker containers (one for Fiber and one for Nginx):

cd ./app
cgapp deploy -u john_doe --ask-become-pass

That's all you need to start! 🎉

⚙️ Installation

First of all, download and install Go. Version 1.11 or higher is required.

Installation is done by using the go build command with $GOPATH/bin:

go build -i -o $GOPATH/bin/cgapp github.com/create-go-app/cli

Check, that the CLI is installed correctly by the --version (or -v) command:

cgapp --version

~ Alternative installations

We're using a GoReleaser project for shipping standalone Create Go App CLI version to all major desktop platforms: Apple macOS, GNU/Linux, MS Windows. By default, for amd64 (x86_64) architecture.

If you need this version, please go to the repository release page and download zipped archive.

📚 Commands & Options

cgapp [command] [command options] [arguments...]

☝️ Tip: you can see all available commands by running command with --help (or -h) option.

create

CLI command to create a new project with the selected configuration.

Usage

cgapp create [command options] [arguments...]

Options

--path value, -p value       path to create app, ex. ~/projects/my-app (default: ".")
--backend value, -b value    backend for your app, ex. Fiber, Echo (default: "net/http")
--frontend value, -f value   frontend for your app, ex. Preact, React.js, React.ts (default: "none")
--webserver value, -w value  web/proxy server for your app, ex. Nginx (default: "none")
--database value, -d value   database for your app, ex. Postgres (default: "none")
--help, -h                   show help

🔔 Please note: by default, cgapp create command without any options will create into current folder default backend (net/http) without frontend or configured Docker containers!

deploy

CLI command for deploy Docker containers with your project to a remote server or run on your local machine.

Usage

cgapp deploy [command options] [arguments...]

Options

--playbook value, -p value  name of Ansible playbook, ex. my-play.yml (default: "deploy-playbook.yml")
--username value, -u value  username of remote's server user or your local machine, ex. root (default: "none")
--host value, -s value      host name of remote's server or local machine (from Ansible inventory), ex. do_server_1 (default: "localhost")
--network value, -n value   network for Docker containers, ex. my_net (default: "cgapp_network")
--ask-become-pass           asking you to enter become user's password at start (default: false)
--help, -h                  show help

🔔 Please note: you should only run the cgapp deploy command from the root folder of your project, which created with the cgapp create command! It's a necessary condition for everything to work perfectly.

📝 Available production-ready app templates

Golang:

JavaScript:

🐳 Available production-ready Docker containers

Web/Proxy server:

Database:

👤 User templates & containers

Create Go App CLI provide creation your own template, instead of those prepared by authors. It's easy! 😉

Just specify backend (-b), frontend (-f), webserver (-w) and database (-d) with addresses to your repositories and run:

cgapp create \
             -b github.com/user/my-back-template \
             -f gitlab.com/user/my-front-template \
             -w github.com/user/my-webserver-container-template \
             -d bitbucket.org/user/my-database-container-template

🔔 Please note: the https:// protocol will add automatically!

🤔 FAQ

— How to update CLI to latest version?

You can just re-build the CLI. The latest version will be downloaded and installed automatically:

go build -i -o $GOPATH/bin/cgapp github.com/create-go-app/cli

If you're using standalone version, please go to the release page and download archive with a new version.

— What do you use to automate the server deployment process?

Each project is created with the required set of configs to start the build and deployment process on the production server or local machine. We use a helpful tool, called Ansible for automate this.

In the root folder of the project you will find deploy-playbook.yml file. Is the Ansible playbook describing the build app & deployment to server process.

👀 Hey! Don't worry, if you are not familiar with this technology, read this article from the docs. Besides, you can ask us about it in one of the issues.

— What does this playbook do?

  • Builds production-ready backend (Go) & frontend (JavaScript, TypeScript) apps, that you have chosen
  • Provides the best practices for web server and database configuration
  • Configures Docker network with containers for backend, static files from frontend, web server and database
  • Runs these Docker containers on your remote server or local machine

👌 We recommend to using our default playbook, but you are free to change them any way you want!

— What should I do for deploy my project?

  1. Check, that you have Ansible v2.9.x (or later) is installed.
  2. Add the right host to your inventory file (into /etc/ansible/hosts) on your local machine.
  3. Be sure, you're working with a SSH key correctly:
    • Generate a new SSH key by command ssh-keygen on your local machine;
    • Add a public key part (with *.pub extension) into a bottom of ~/.ssh/authorized_keys file (with "one line" format) on your remote server;
    • Save a private key part on your local machine;
  4. Run the built-in cgapp deploy command (from the root folder of your project):
cgapp deploy -p <PLAYBOOK_NAME> -u <USER> -s <HOST> -n <NETWORK_NAME> [EXTRA_VARS...]
  • <PLAYBOOK_NAME> (optional, default: deploy-playbook.yml) is the Ansible playbook name
  • <USER> (required) is an username of remote's server user (for example, root)
  • <HOST> (optional, default: localhost) is a host name from your inventory file
  • <NETWORK_NAME> (optional, default: cgapp_network) is a network name for your Docker containers

👌 If you need to deploy (or run) project with entering password for user, you can add --ask-become-pass variable in [EXTRA_VARS...] section. You will be prompted to enter <USER>'s password at the beginning. This is an alias of the standard Ansible argument to ask for a privilege escalation password (see docs).

— Are there any video examples of working with the Create Go App CLI?

cgapp youtube example
🔗 youtu.be/e9443CCqxio

⭐️ Project assistance

If you want to say thank you or/and support active development create-go-app/cli:

  1. Add a :octocat: GitHub Star to the project.
  2. Twit about project on your Twitter.
  3. Donate some money to project author via PayPal: @paypal.me/koddr.
  4. Join DigitalOcean at our referral link (your profit is $100 and we get $25).
  5. Buy awesome domain name with 5% discount at REG.COM.

Thanks for your support! 😘 Together, we make this project better every day.

~ Sponsors

Logo Description URL
True web artisans logo True web artisans — Team who making UX efficiency review, friendly UI design, smart backend microservices, high-quality web apps and many more. https://1wa.co

⚠️ License

MIT © Vic Shóstak & True web artisans.

cli-3's People

Contributors

koddr avatar

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.