Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.
generated from gogolcorp/go-yave

The goal of this project is to use the Elastic search tool with a Golang API in order to be able to search for books by title, author or summary, using this API.

License

Notifications You must be signed in to change notification settings

alexandre-delaloy/elastic-books

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elastic-books

I - Goal

The goal of this project is to use the Elastic search tool with a Golang API in order to be able to search for books by title, author or summary, using this API. The development environment is build with Docker and Docker Compose, using a Makefile.

This repository provides commit writting and branch naming conventions, issues and pull request templates, and a custom issues labels preset.

But also CI/CD and release using GitHub Actions, GitHub Container Registry and Docker.

II - Table of content

III - Conventions, templates and labels

A - Commit conventions

tag(scope): #issue_id - message

See commit_conventions.md for more informations.

B - Branch naming convention

type_scope-of-the-work

See branch_naming_convention.md for more informations.

C - Issue template

See user-story.md for more informations.

D - Pull request template

See pull_request_template.md for more informations.

E - Custom issues labels preset

The labels preset is located at .github/settings.yml.

You can add, edit or remove them. To automatically update these labels, you need to install the "Settings" GitHub app, which will syncs repository settings defined in the file above to your repository.

IV - CI/CD, release and container registry

A - CI

GO

The CI workflow is located at .github/workflows/go.yml. It's triggered a each push on all branches.

It consist of:

  • install Golang on the VM
  • get the dependancies using the cache of other Actions run
  • lint the files to check or syntax errors
  • build the application

B - CD

DOCKER

The CD workflow is located at .github/workflows/docker.yml. It's triggered a each push on main branch.

It consist of:

  • login into the GitHub container registry (ghcr.io)
  • build and push the Golang api using the production Dockerfile located at .docker/api/prod.Dockerfile

After that, you can check the pushed container at: https://github.com/<username>?tab=packages&repo_name=<repository-name>

IMPORTANT: you need to update the production Dockerfile with your username AND repository name. Otherwise, there will be errors at push:

LABEL org.opencontainers.image.source = "https://github.com/<username>/<repository-name>"

C - Release

RELEASE

The release workflow is located at .github/workflows/release.yml. It's triggered manually by user input at: Actions > RELEASE.

IMPORTANT: you need to set the image tag in the action input, for the action to be able to push the docker image and create a release with a specific version. The image tag is a SemVer tag, e.g. 1.0.2.

It consist of:

  • check if the environment match the branch
  • do the CD (docker) action again, but with a specific image tag
  • create a release with the same tag, filled with the generated changelog as closed issues since the last release

After that, you can check the release at https://github.com/<username>/<repository-name>/releases.

V - Elastic-books product

The project use Docker and Docker Compose to build and run local and distant images in our workspace.

For more informations, check the wiki.

A - Stack

All the images use the same network, more informations at docker-compose.yml

CONTAINER PORT IMAGE
GOLANG 3333:3333 .docker/api/dev.Dockerfile
ELASTIC 9200:9200 docker.elastic.co/elasticsearch/elasticsearch:7.13.2
KIBANA 5601:5601 docker.elastic.co/kibana/kibana:7.13.2

B - Makefile

TL;DR

make lint start logs

You will have errors at 1st build, because the Golang API is ready before the ES service. Just Ctrl + S on a Golang file will fix the problem (hot-reload)

make help

Display informations about other commands.

make start

Up the containers with full cache reset to avoid cache errors.

make stop

Down the containers.

make logs

Display and follow the logs.

make lint

Lint the Go files using gofmt.

make seed

Seed the Elasticsearch database with sample data

VI - License

Under MIT license.

About

The goal of this project is to use the Elastic search tool with a Golang API in order to be able to search for books by title, author or summary, using this API.

Resources

License

Stars

Watchers

Forks

Packages