Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add application logs #4

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
492 changes: 492 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

100 changes: 73 additions & 27 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
name: Build Docker images

on:
workflow_dispatch:
push:
branches:
- 'main'
tags:
- '*' # Push events to matching tags
- 'v*'
pull_request:
branches:
- 'main'

jobs:
docker-api-cart:
Expand All @@ -17,29 +23,39 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: alphayax/microservice-demo-cart-service
images: |
name=ghcr.io/${{ github.repository }}/cart-service
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

type=sha
type=raw,value=latest,enable={{is_default_branch}}
labels: |
maintainer=WeScale
org.opencontainers.image.title=cart-service
org.opencontainers.image.description=Example of cart-service microservice
org.opencontainers.image.vendor=WeScale
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./cart-service/
push: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

Expand All @@ -54,29 +70,39 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: alphayax/microservice-demo-article-service
images: |
name=ghcr.io/${{ github.repository }}/article-service
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

type=sha
type=raw,value=latest,enable={{is_default_branch}}
labels: |
maintainer=WeScale
org.opencontainers.image.title=article-service
org.opencontainers.image.description=Example of article-service microservice
org.opencontainers.image.vendor=WeScale
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./article-service/
push: true
context: ./cart-service/
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

Expand All @@ -91,29 +117,39 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: alphayax/microservice-demo-frontend-user
images: |
name=ghcr.io/${{ github.repository }}/frontend-user
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

type=sha
type=raw,value=latest,enable={{is_default_branch}}
labels: |
maintainer=WeScale
org.opencontainers.image.title=frontend-user
org.opencontainers.image.description=Example of frontend user portal
org.opencontainers.image.vendor=WeScale
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./front-user/
push: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

Expand All @@ -128,28 +164,38 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: alphayax/microservice-demo-frontend-admin
images: |
name=ghcr.io/${{ github.repository }}/frontend-admin
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

type=semver,pattern={{major}}
type=sha
type=raw,value=latest,enable={{is_default_branch}}
labels: |
maintainer=WeScale
org.opencontainers.image.title=frontend-admin
org.opencontainers.image.description=Example of frontend admin portal
org.opencontainers.image.vendor=WeScale
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./front-admin/
push: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
123 changes: 123 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
### VisualStudioCode template
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Go template
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work

### Vuejs template
# Recommended template: Node.gitignore

node_modules/
dist/
npm-debug.log
yarn-error.log
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## See https://pre-commit.com for more information
## See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
- id: go-fmt
- id: go-lint
- id: validate-toml
- id: go-mod-tidy
- repo: https://github.com/pre-commit/mirrors-prettier
rev: 'v3.1.0'
hooks:
- id: prettier
types_or: [css, javascript, vue, ts, scss]
- repo: https://github.com/pre-commit/mirrors-eslint
rev: 'v8.56.0'
hooks:
- id: eslint
files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
types: [ file ]
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
golang 1.20
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Content-Type: application/json
"description": "The best article of all times"
}

###
GET http://localhost:8080/article/
Accept: application/json

###
DELETE http://localhost:8080/article/655cabd93dea2ba2e45e3159/
Accept: application/json
4 changes: 3 additions & 1 deletion article-service/config.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
listen: ":8080"
mongodbUri: "mongodb://localhost:27017/alpha-articles"
mongodbURI: "mongodb://localhost:27017/alpha-articles"
logLevel: "debug"
environment: "dev"
3 changes: 3 additions & 0 deletions article-service/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ go 1.20

require (
github.com/gin-contrib/cors v1.4.0
github.com/gin-contrib/requestid v0.0.6
github.com/gin-gonic/gin v1.9.1
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/viper v1.17.0
github.com/toorop/gin-logrus v0.0.0-20210225092905-2c785434f26f
go.mongodb.org/mongo-driver v1.13.0
)

Expand All @@ -22,6 +24,7 @@ require (
github.com/go-playground/validator/v10 v10.14.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.0 // indirect
Expand Down
Loading