Skip to content

Commit

Permalink
Merge pull request #2 from wisdom-oss/dev
Browse files Browse the repository at this point in the history
Update README from dev
  • Loading branch information
dr4hcu5-jan committed Feb 5, 2024
2 parents 1ee2541 + 709b547 commit b31f7a1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 81 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/build-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
name: Create/Release Docker Image
on:
push:
branches: [ "main", "stable", "dev" ]
# Publish semver tags as releases.
branches: [ "main", "dev" ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: wisdom-oss/service-swat-collector


jobs:
Expand All @@ -27,7 +24,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -44,7 +41,14 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=ref,event=pr
type=semver,pattern={{raw}}
type=raw,value={{sha}}
type=ref,event=branch
- name: Build and push Docker image
id: build-and-push
Expand Down
92 changes: 17 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,23 @@
<div align="center">
<img height="150px" src="https://raw.githubusercontent.com/wisdom-oss/brand/main/svg/standalone_color.svg">
<h1>Microservice Template/Example</h1>
<h3>service-example</h3>
<p>πŸ“ A minimal working example for microservices in the WISdoM Architecture</p>
<img src="https://img.shields.io/github/go-mod/go-version/wisdom-oss/microservice-template?style=for-the-badge"
alt="Go Lang Version"/>
<h1>Smartmeter Data Management</h1>
<h3>service-smartmeter-rest</h3>
<p>πŸ’§ data management for smart meters</p>
<img src="https://img.shields.io/github/go-mod/go-version/wisdom-oss/service-smartmeter-rest?style=for-the-badge" alt="Go Lang Version"/>
<a href="openapi.yaml">
<img src="https://img.shields.io/badge/Schema%20Version-3.0.0-6BA539?style=for-the-badge&logo=OpenAPI%20Initiative" alt="Open
API Schema Version"/></a>
<img src="https://img.shields.io/badge/Schema%20Version-3.0.0-6BA539?style=for-the-badge&logo=OpenAPI%20Initiative" alt="OpenAPI Schema Version"/>
</a>
<a href="https://github.com/wisdom-oss/service-smartmeter-rest/pkgs/container/service-smartmeter-rest">
<img alt="Static Badge" src="https://img.shields.io/badge/ghcr.io-wisdom--oss%2Fservice--smartmeter--rest-2496ED?style=for-the-badge&logo=docker&logoColor=white&labelColor=555555">
</a>
</div>

## Using the template
1. Download this archive as `.zip` or `.tar.gz` (whatever you prefer)
> [!NOTE]
> This service does not interact with smart meters and their configuration as
> this should only be done by authorized personnel.
2. Extract the downloaded archive to a directory of your choice and remove the
parent folders which may have been created during the download

3. Make sure that your folder now contains at least the following file structure:
```
β”œβ”€β”€ globals
β”‚ β”œβ”€β”€ connections.go (contains globally available connections)
β”‚ β”œβ”€β”€ variables.go (contains globally available variables)
β”œβ”€β”€ resources
β”‚ β”œβ”€β”€ authConfig.json (contains auth config)
β”‚ β”œβ”€β”€ environment.json (contains the environment setup)
β”‚ β”œβ”€β”€ errors.json (contains http errors)
β”‚ β”œβ”€β”€ queries.sql (contains sql queries for the service)
β”œβ”€β”€ routes
β”‚ β”œβ”€β”€ templates.go (contains three template routes)
β”œβ”€β”€ .gitignore
β”œβ”€β”€ init.go (contains code used during startup)
β”œβ”€β”€ template-service.go (contains the bootstrapping code for the service)
β”œβ”€β”€ go.mod (contains the dependencies of the service)
β”œβ”€β”€ go.sum (is the lockfile for the dependencies)
```

4. **Important** Change the service name

To change the service name, you need to edit the file `globals/variables.go`
which should contain the following line

```go
const ServiceName = "template-service"
```

This line needs to be changed to your service name. This constant is
used in logs and error handling to identify the service.

5. Initialize a Git Repository with `main` as default branch

```shell
git init -b main
```
6. Add all files to the repository

```shell
git add -A
```

7. Commit the template to the repository

```shell
git commit -m "loading wisdom-oss/microservice-template"
```

8. Set up a remote origin for the repository

```shell
git remote add origin <your-remote-url>
```

9. Push the repository to the remote origin

```shell
git push origin main
```

10. :tada: You are now able to develop your new microservice

11. Change the README to the contents you desire in here
This microservice allows the management of smart meter data that has been
written into the database.
Furthermore, the service provides an endpoint allowing external services to
write collected smart meter data into the database, either as a batch operation
or writing single entries.

0 comments on commit b31f7a1

Please sign in to comment.