This content originally appeared on DEV Community and was authored by Vic Shóstak
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
- Changes in CLI commands
- Ansible roles
- Project Wiki page
- Your assistance to the project
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:
create-go-app / cli
✨ A powerful CLI for the Create Go App project. Create a new production-ready project with backend, frontend and deploy automation by running one CLI command!
Changes in CLI commands
This release was aimed primarily at speeding up the CLI and reducing the functionality of commands that were too overloaded.
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
.
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.
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). Support for creation from the custom templates is currently under complete redesign! We plan to bring this functionality back in the Create Go App CLI
v2.2.x
.
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)
└── ...
Watch a short video presentation:
Direct link: https://recordit.co/OQAwkZBrjN
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). |
boolean |
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:
Direct link: https://recordit.co/ishTf0Au1x
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
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:
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.
Database
List of roles:
-
postgres
— configured PostgreSQL container with apply migrations (by golang-migrate/migrate tool) for backend.
Cache, key-value storage
List of roles:
-
redis
— configured Redis container to store the backend cache.
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:
- CLI commands
- How the CLI works
- Frequently asked questions
- Logo
Your assistance to the project
If you want to say thank you or/and support active development of project:
- Add a GitHub Star to the project.
- Twit about project on your Twitter.
- Write interesting articles about project on Dev.to, Medium or personal blog.
- Join DigitalOcean at our referral link (your profit is $100 and we get $25).
Together, we can make this project better every day!
Photos and videos by
- Vic Shóstak https://shostak.dev
P.S.
If you want more → write a comment below & follow me. Thanks! ?
This content originally appeared on DEV Community and was authored by Vic Shóstak
Vic Shóstak | Sciencx (2021-05-06T14:55:16+00:00) ? The Create Go App project has grown to v2, but is still easier, better, faster & stronger. Retrieved from https://www.scien.cx/2021/05/06/%f0%9f%8e%89-the-create-go-app-project-has-grown-to-v2-but-is-still-easier-better-faster-stronger/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.