Skip to content

Understanding CLI commands and options

You can see all available commands and options by running cgapp --help.

init

CLI command for generate a default .cgapp.yml config file in current folder:

cgapp init

init

If you're using Docker image

docker run --rm -it -v ${PWD}:${PWD} -w ${PWD} koddr/cgapp:latest init

Generated config file looks like this:

# Project config.
project:
    # Backend for your project.
    # (Required)
    # String:
    #   - `net/http`
    #   - `fiber`
    #   - `echo`
    #   - `gin`
    # User template: supported, set to URL (without protocol),
    # like `github.com/user/template`
    - backend: fiber

    # Frontend for your project.
    # (Optional, to skip set to `none`)
    # String:
    #   - `react`
    #     - `react:<template>`
    #   - `preact`
    #     - `preact:<template>`
    #   - `vue`
    #     - `vue:<user/repo>` (for preset from GitHub)
    #     - `vue:<gitlab|bitbucket>:<user/repo>` (for presets from others)
    #   - `angular`
    #   - `svelte`
    #   - `sapper`
    #     - `sapper:<webpack>`
    # User template: supported, set to URL (without protocol),
    # like `github.com/user/template`
    - frontend: svelte

    # Web/Proxy server for your project.
    # (Optional, to skip set to `none`)
    # String: `nginx`
    # User template: supported, set to URL (without protocol),
    # like `github.com/user/template`
    - webserver: nginx

# Automation config.
roles:
    # Ansible roles for deploy your project.
    # (Optional, to skip set to empty or comment)
    # Objects list.
    - deploy:
        # Username of remote's server or local's user.
        # (Required)
        username: root

        # If you need to deploy (or run) a project asking for a password
        # for the user, set `become` to `true`. This is equivalent of
        # `--ask-become-pass`, a standard Ansible argument
        # to ask for a privilege escalation password.
        # (Optional)
        become: true

        # Host name from your inventory file (usually, at /etc/ansible/hosts).
        # (Required)
        host: localhost

        # Name of Docker network
        # (Required)
        network: cgapp_network

        # Filename of Ansible playbook in the root of the Create Go App project.
        # If you want to rename it, do it, but not to change destination of file!
        # (Required)
        playbook: deploy-playbook.yml

create

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

There's two ways to create a new project:

  • With an interactive console UI (or CUI).
  • From configuration file (by default, in $PWD/.cgapp.yml).

Create with the interactive console UI

Run create command without any arguments:

cgapp create

create

If you're using Docker image

docker run --rm -it -v ${PWD}:${PWD} -w ${PWD} koddr/cgapp:latest create

Create from the config file

Run create command with --use-config (or -c) argument:

cgapp create --use-config

If you're using Docker image

docker run --rm -it -v ${PWD}:${PWD} -w ${PWD} koddr/cgapp:latest create --use-config

deploy

CLI command for deploy Docker containers with your project to a remote server.

Condition for perfectly working

You should only run this command from the root folder of your project, which created with the create command! It's a necessary condition for everything to work perfectly.

There's, also, two ways to deploy your project:

  • With an interactive console UI (or CUI).
  • From configuration file (by default, in $PWD/.cgapp.yml).

Deploy with the interactive console UI

Run deploy command without any arguments:

cgapp deploy

deploy

Deploy from the config file

Run deploy command with --use-config (or -c) argument:

cgapp deploy --use-config

By the way, you can run containers on your local machine too (if you've not skipped Ansible roles at cgapp create step). All you have to do is define localhost as your host.