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

Update README from dev #2

Merged
merged 2 commits into from
Feb 5, 2024
Merged
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
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.
Loading