DEV Community

Cover image for πŸŽ‰ The Create Go App project has grown to v2, but is still easier, better, faster & stronger
Vic ShΓ³stak
Vic ShΓ³stak

Posted on • Updated on

πŸŽ‰ The Create Go App project has grown to v2, but is still easier, better, faster & stronger

Introduction

Hello, friends! πŸ˜‰ I'm excited to share great news with you: the Create Go App CLI project, that I've been working on for a long time, has finally been updated to major version 2.

In case anyone forgot, I remind you that with this CLI you can create in just a few seconds a new production-ready project with backend (Go), frontend (JavaScript, TypeScript) and deploy automation (Ansible, Docker).

☝️ You only need to focus on writing code and thinking of business-logic! The CLI will take care of the rest.

OK. Let's look at the changes together! Fasten your seat belts, we're starting.

πŸ“ Table of contents

New in v2 and beyond

There are actually quite a few changes, but I've highlighted a few of the most important ones that change the way you work with the Create Go App CLI. For all other changes, please read the release notes in our GitHub repository:

GitHub logo create-go-app / cli

✨ A complete and self-contained solution for developers of any qualification to create a production-ready project with backend (Go), frontend (JavaScript, TypeScript) and deploy automation (Ansible, Docker) by running only one CLI command.

↑ Table of contents

Changes in CLI commands

This release was aimed primarily at speeding up the CLI and reducing the functionality of commands that were too overloaded.

↑ Table of contents

init command

After some analysis of the CLI command feedback, we concluded that the command to create a configuration file is very rarely used. The same comment from the focus group of our users, followed about the configuration file itself.

The most popular comment we got, was something like this:

β€” [...] nobody likes setting up yet another config for yet another CLI!

So, it was decided to remove init command and file-based config .cgapp.yml completely, even without the possibility of backward compatibility, which we successfully did in v2.0.0.

↑ Table of contents

create command

The central CLI command has been redesigned, and its execution time has been reduced to 2-4 seconds. This was achieved by switching to generating the frontend part of the project using ready-made templates from the awesome next generation frontend tooling called Vite.js.

vite js

Now, you can choose between this frontend frameworks/libraries:

Name Version JavaScript template TypeScript template
Pure (vanilla) - vanilla vanilla-ts
React v17.0.0 react react-ts
Preact v10.5.13 preact preact-ts
Vue.js v3.0.5 vue vue-ts
Svelte v3.37.0 svelte svelte-ts
Lit v2.4.0 lit-element lit-element-ts

⚠️ Please note! Creating a new project is done only through the console interface (or CUI for short).

Create a new project from the custom backend and frontend templates (from your git repositories) is done by using -t option with create command:

Option Description Type Default Required?
-t Enables to define custom backend and frontend templates. bool false No

The structure of the created project will be as follows:

.
β”œβ”€β”€ .editorconfig
β”œβ”€β”€ .gitattributes
β”œβ”€β”€ .gitignore
β”œβ”€β”€ hosts.ini     # <-- file with Ansible inventory variables
β”œβ”€β”€ playbook.yml  # <-- file with Ansible playbook
β”œβ”€β”€ Makefile
β”œβ”€β”€ backend       # <-- folder with Go backend
β”‚   └── ...
β”œβ”€β”€ frontend      # <-- folder with JS/TS frontend (if you choose)
β”‚   └── ...
└── roles         # <-- folder with Ansible roles
    β”œβ”€β”€ backend
    β”‚   └── ...
    β”œβ”€β”€ docker
    β”‚   └── ...
    β”œβ”€β”€ postgres
    β”‚   └── ...
    β”œβ”€β”€ redis
    β”‚   └── ...
    └── traefik   # or nginx (if you choose)
        └── ...
Enter fullscreen mode Exit fullscreen mode

Watch a short video presentation:

cgapp create

Direct link: https://recordit.co/OQAwkZBrjN

↑ Table of contents

deploy command

Also, we have seriously reworked the principle of deploying the project on a remote server. The only option left for the deploy command is the default password call for the sudo user:

Option Description Type Default Required?
-k Prompt you to provide the remote user sudo password (a standard Ansible --ask-become-pass option). bool false No

Now, everything is built on pre-configured Ansible roles that work perfectly out of the box with our official backend templates for Fiber and net/http.

Watch a short video presentation:

cgapp deploy

Direct link: https://recordit.co/ishTf0Au1x

↑ Table of contents

Ansible roles

Starting with version v2.0.0 we will actively add new Ansible roles to make the process of deploying your project to remote servers as comfortable and fast as possible.

So, now all the configuration for deployment will be in the Ansible inventory hosts.ini (in the root of the created project). For example, this is what the inventory looks like for deploying a project with the Nginx web server:

# ./hosts.ini

# Ansible inventory for deploy the Create Go App project.
# Author: Vic ShΓ³stak <vic@shostak.dev> (https://shostak.dev)
# For more information, please visit https://create-go.app/

[cgapp_project]
127.0.0.1 # CHANGE THIS TO YOUR REMOTE SERVER IP!

[cgapp_project:vars]
#
# Ansible default variables to start playbook:
#

# Set remote sudo username
ansible_user=root
# Ask become password for remote sudo user
ansible_become=yes
# Set connection type to remote server (usually, 'ssh')
ansible_connection=ssh
# Set Python 3 default path
ansible_python_interpreter=/usr/bin/python3

#
# Remote server configuration:
#

# Set directory on your remote server 
# for store project files
server_dir=/var/www/cgapp
# Set user (owner of files/folders) name
server_user=root
# Set group name
server_group=docker

#
# Project configuration:
#

# Set your project domain
project_domain=example.com

#
# Docker configuration:
#

# Set Docker network name
docker_network=cgapp_network

#
# Backend configuration:
#

# Set backend port number,
# MUST BE MATCH to the port that is listed 
# in your `./backend/.env` file!
backend_port=5000

#
# PostgreSQL configuration (backend DB):
#

# Set PostgreSQL version (for example, 13.2)
postgres_version=latest
# Set PostgreSQL port number,
# MUST BE MATCH to the port that is listed 
# in your `./backend/.env` file!
postgres_port=5432
# Set PostgreSQL user name,
# MUST BE MATCH to the user name that is listed 
# in your `./backend/.env` file!
postgres_user=postgres
# Set PostgreSQL password,
# MUST BE MATCH to the password that is listed 
# in your `./backend/.env` file!
postgres_password=password
# Set PostgreSQL DB name,
# MUST BE MATCH to the DB name that is listed 
# in your `./backend/.env` file!
postgres_db=postgres
# Set PostgreSQL SSL mode state ('enabled' or 'disabled'),
# MUST BE MATCH to the SSL mode state that is listed 
# in your `./backend/.env` file!
postgres_ssl_mode=disable

#
# Go-Migrate configuration:
#

# Set migration number,
# if you WANT to migrate all of your migrations, 
# just leave it blank,
# for only initial migration set it to '1'
migrate_number=1

#
# Redis configuration (backend cache):
#

# Set Redis version (for example, 6.2)
redis_version=latest
# Set Redis port number,
# MUST BE MATCH to the port that is listed 
# in your `./backend/.env` file!
redis_port=6379

#
# Nginx configuration:
#

# Set Nginx version (for example, 1.20-alpine)
nginx_version=alpine
# Set redirect from HTTP to HTTPS for default server
nginx_use_only_https=yes
# Set redirect from WWW to non-WWW domain for default server
nginx_redirect_to_non_www=yes
Enter fullscreen mode Exit fullscreen mode

↑ Table of contents

Web, proxy servers

We're recommending to use Traefik Proxy as default proxy server for your projects. The main reason: this proxy provides automatic SSL certificates from Let's Encrypt with renew out of the box.

Also, Traefik was built on the Docker ecosystem and has a really useful Web UI:

traefik web ui

List of roles:

  • traefik β€” configured Traefik container with a simple ACME challenge via CA server.
  • traefik-acme-dns β€” configured Traefik container with a complex ACME challenge via DNS provider.
  • nginx β€” pure Nginx container with "the best practice" configuration.

↑ Table of contents

Database

List of roles:

↑ Table of contents

Cache, key-value storage

List of roles:

  • redis β€” configured Redis container to store the backend cache.

↑ Table of contents

Project Wiki page

Soon, we plan to move completely to the GitHub Wiki and do away with the separate documentation on our website for the project.

β€” Everything should be in one place, β€” as focus group users correctly noted.

This is a table of contents for the Create Go App Wiki:

↑ Table of contents

Your assistance to the project

If you want to say thank you or/and support active development of project:

Together, we can make this project better every day!

↑ Table of contents

Photos and videos by

P.S.

If you want more articles (like this) on this blog, then post a comment below and subscribe to me. Thanks! 😻

And of course, you can help me make developers' lives even better! Just connect to one of my projects as a contributor. It's easy!

My projects that need your help (and stars) πŸ‘‡

  • πŸ”₯ gowebly: A next-generation CLI tool for easily build amazing web applications with Go on the backend, using htmx & hyperscript and the most popular atomic/utility-first CSS frameworks on the frontend.
  • ✨ create-go-app: Create a new production-ready project with Go backend, frontend and deploy automation by running one CLI command.
  • πŸƒ yatr: Yet Another Task Runner allows you to organize and automate your routine operations that you normally do in Makefile (or else) for each project.
  • πŸ“š gosl: The Go Snippet Library provides snippets collection for working with routine operations in your Go programs with a super user-friendly API and the most efficient performance.
  • πŸ„β€β™‚οΈ csv2api: The parser reads the CSV file with the raw data, filters the records, identifies fields to be changed, and sends a request to update the data to the specified endpoint of your REST API.
  • 🚴 json2csv: The parser can read given folder with JSON files, filtering and qualifying input data with intent & stop words dictionaries and save results to CSV files by given chunk size.

Top comments (0)