Skip to content

Commit

Permalink
Merge pull request #79 from create-go-app/dev
Browse files Browse the repository at this point in the history
Fix Ansible roles
  • Loading branch information
koddr authored May 5, 2021
2 parents 24f9023 + 548ee0b commit d551a33
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</h1>
<p align="center">Create a new production-ready project with <b>backend</b> (Golang), <b>frontend</b> (JavaScript, TypeScript)<br/>and <b>deploy automation</b> (Ansible, Docker) by running one CLI command.<br/><br/>Focus on <b>writing</b> code and <b>thinking</b> of business-logic! The CLI will take care of the rest.</p>

<p align="center"><a href="https://github.com/create-go-app/cli/releases" target="_blank"><img src="https://img.shields.io/badge/version-v2.1.0-blue?style=for-the-badge&logo=none" alt="cli version" /></a>&nbsp;<a href="https://pkg.go.dev/github.com/create-go-app/cli?tab=doc" target="_blank"><img src="https://img.shields.io/badge/Go-1.16+-00ADD8?style=for-the-badge&logo=go" alt="go version" /></a>&nbsp;<a href="https://gocover.io/github.com/create-go-app/cli/pkg/cgapp" target="_blank"><img src="https://img.shields.io/badge/Go_Cover-89%25-success?style=for-the-badge&logo=none" alt="go cover" /></a>&nbsp;<a href="https://goreportcard.com/report/github.com/create-go-app/cli" target="_blank"><img src="https://img.shields.io/badge/Go_report-A+-success?style=for-the-badge&logo=none" alt="go report" /></a>&nbsp;<img src="https://img.shields.io/badge/license-apache_2.0-red?style=for-the-badge&logo=none" alt="license" /></p>
<p align="center"><a href="https://github.com/create-go-app/cli/releases" target="_blank"><img src="https://img.shields.io/badge/version-v2.1.1-blue?style=for-the-badge&logo=none" alt="cli version" /></a>&nbsp;<a href="https://pkg.go.dev/github.com/create-go-app/cli?tab=doc" target="_blank"><img src="https://img.shields.io/badge/Go-1.16+-00ADD8?style=for-the-badge&logo=go" alt="go version" /></a>&nbsp;<a href="https://gocover.io/github.com/create-go-app/cli/pkg/cgapp" target="_blank"><img src="https://img.shields.io/badge/Go_Cover-89%25-success?style=for-the-badge&logo=none" alt="go cover" /></a>&nbsp;<a href="https://goreportcard.com/report/github.com/create-go-app/cli" target="_blank"><img src="https://img.shields.io/badge/Go_report-A+-success?style=for-the-badge&logo=none" alt="go report" /></a>&nbsp;<img src="https://img.shields.io/badge/license-apache_2.0-red?style=for-the-badge&logo=none" alt="license" /></p>

## ⚡️ Quick start

Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

// CLIVersion version of Create Go App CLI.
const CLIVersion string = "2.1.0"
const CLIVersion string = "2.1.1"

// Variables struct for Ansible variables (inventory, hosts).
type Variables struct {
Expand Down
10 changes: 10 additions & 0 deletions pkg/registry/roles/docker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,13 @@
- name: Create a new Docker network
community.docker.docker_network:
name: "{{ docker_network }}"

#
# Create folder for project files.
#
- name: Create folder for project files
file:
state: directory
path: "{{ server_dir }}"
owner: "{{ server_user }}"
group: "{{ server_group }}"
4 changes: 2 additions & 2 deletions pkg/registry/roles/nginx/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
- "80:80"
volumes:
- "{{ server_dir }}/webserver/nginx.conf:/etc/nginx/nginx.conf:ro"
- "{{ server_dir }}/webserver/default.conf:/etc/nginx/conf.d/default.conf:ro"
- "{{ server_dir }}/webserver/default.conf:/etc/nginx/conf.d/default.conf"
when: nginx_use_only_https == 'no'

#
Expand All @@ -73,5 +73,5 @@
- "443:443"
volumes:
- "{{ server_dir }}/webserver/nginx.conf:/etc/nginx/nginx.conf:ro"
- "{{ server_dir }}/webserver/default.conf:/etc/nginx/conf.d/default.conf:ro"
- "{{ server_dir }}/webserver/default.conf:/etc/nginx/conf.d/default.conf"
when: nginx_use_only_https == 'yes'
4 changes: 2 additions & 2 deletions pkg/registry/roles/nginx/templates/default-http.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ server {

# Main server
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 80;
listen [::]:80;
{% if nginx_redirect_to_non_www %}
server_name {{ project_domain }};
{% else %}
Expand Down
8 changes: 6 additions & 2 deletions pkg/registry/roles/postgres/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@
#
- name: Run PostgreSQL container
community.docker.docker_container:
name: cgapp-postgres
name: "{{ postgres_container_name }}"
image: "postgres:{{ postgres_version }}"
restart_policy: unless-stopped
recreate: true
networks:
- name: "{{ docker_network }}"
ports:
- "{{ postgres_port }}:{{ postgres_port }}"
env:
POSTGRES_USER: "{{ postgres_user }}"
POSTGRES_PASSWORD: "{{ postgres_password }}"
POSTGRES_DB: "{{ postgres_db }}"
volumes:
- "{{ server_dir }}/database/data/:/var/lib/postgresql/data"

Expand All @@ -44,7 +48,7 @@
"-path",
"/migrations",
"-database",
"postgres://{{ postgres_user }}:{{ postgres_password }}@localhost:{{ postgres_port }}/{{ postgres_db }}?sslmode={{ postgres_ssl_mode }}",
"postgres://{{ postgres_user }}:{{ postgres_password }}@{{ postgres_container_name }}:{{ postgres_port }}/{{ postgres_db }}?sslmode={{ postgres_ssl_mode }}",
"up",
"{{ migrate_number }}",
]
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/roles/redis/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
- name: Run Redis container
community.docker.docker_container:
name: cgapp-redis
name: "{{ redis_container_name }}"
image: "redis:{{ redis_version }}"
restart_policy: unless-stopped
recreate: true
Expand Down
8 changes: 7 additions & 1 deletion pkg/registry/templates/hosts.ini.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ backend_port=5000
# PostgreSQL configuration (backend DB):
#

# Set PostgreSQL container name
# MUST BE MATCH to the port that is listed in your `./backend/.env` file!
postgres_container_name=cgapp-postgres
# Set PostgreSQL version (for example, 13.2)
postgres_version=latest
# Set PostgreSQL port number,
Expand All @@ -75,7 +78,7 @@ postgres_db=postgres
postgres_ssl_mode=disable

#
# Go-Migrate configuration:
# Go-Migrate configuration (DB migrations):
#

# Set migration number,
Expand All @@ -87,6 +90,9 @@ migrate_number=1
# Redis configuration (backend cache):
#

# Set Redis container name
# MUST BE MATCH to the port that is listed in your `./backend/.env` file!
redis_container_name=cgapp-redis
# Set Redis version (for example, 6.2)
redis_version=latest
# Set Redis port number,
Expand Down

0 comments on commit d551a33

Please sign in to comment.