Skip to content

Commit

Permalink
Merge pull request #1 from rarimo/feature/init
Browse files Browse the repository at this point in the history
  • Loading branch information
napalmpapalam authored Dec 16, 2023
2 parents dd005c7 + dab5930 commit 002fc97
Show file tree
Hide file tree
Showing 88 changed files with 16,436 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*.md]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 100
31 changes: 31 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
workflow_dispatch:

jobs:
converge:
name: Converge
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install werf
uses: werf/actions/install@v1.2

- name: Log in to registry
# This is where you will update the personal access token to GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Run echo
run: |
werf version
docker version
echo $GITHUB_REPOSITORY
echo $GITHUB_SHA
- name: Run Build
run: |
. $(werf ci-env github --as-file)
werf export service --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA
33 changes: 33 additions & 0 deletions .github/workflows/actions_onlymain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
on:
push:
branches:
- 'main'

jobs:
converge:
name: Converge
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install werf
uses: werf/actions/install@v1.2

- name: Log in to registry
# This is where you will update the personal access token to GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Run echo
run: |
werf version
docker version
echo $GITHUB_REPOSITORY
echo $GITHUB_SHA
- name: Run Build
run: |
. $(werf ci-env github --as-file)
werf export service --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA
34 changes: 34 additions & 0 deletions .github/workflows/deploy-gh-pages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Builds the docs and deploys to GitHub pages
#
# https://github.com/actions/setup-node
# Using https://github.com/marketplace/actions/deploy-to-github-pages
name: Deploy to Github pages

on:
push:
#tags:
# - v*
branches:
- main

jobs:
deploy_pages:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'

- run: cd docs
- run: npm install
- run: npm run build

- run: touch doc/.nojekyll
- name: Deploy docs 🚀
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: docs/web_deploy # The folder the action should deploy.
33 changes: 33 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
converge:
name: Converge
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install werf
uses: werf/actions/install@v1.2

- name: Log in to registry
# This is where you will update the personal access token to GITHUB_TOKEN
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Run echo
run: |
werf version
docker version
echo $GITHUB_REPOSITORY
echo $GITHUB_REF_NAME
- name: Run Build
run: |
. $(werf ci-env github --as-file)
werf export service --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_REF_NAME
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.vscode/
.idea/
config.*.yaml
docs/node_modules
docs/web_deploy
vendor/
public/
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.1.0] - 2023-02-16
### Changed
- Initiated project

[Unreleased]: https://github.com/rarimo/dashboard-rarime-link-svc/compare/0.1.0...HEAD
[1.0.0]: https://github.com/rarimo/dashboard-rarime-link-svc/releases/tag/0.1.0
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM golang:1.20-alpine as buildbase

RUN apk add build-base git

ARG CI_JOB_TOKEN

WORKDIR /go/src/github.com/rarimo/dashboard-rarime-link-svc

COPY . .

ENV GO111MODULE="on"
ENV CGO_ENABLED=1
ENV GOOS="linux"

RUN go mod tidy
RUN go mod vendor
RUN go build -o /usr/local/bin/dashboard-rarime-link-svc github.com/rarimo/dashboard-rarime-link-svc

###

FROM alpine:3.9

COPY --from=buildbase /usr/local/bin/dashboard-rarime-link-svc /usr/local/bin/dashboard-rarime-link-svc
RUN apk add --no-cache ca-certificates

ENTRYPOINT ["dashboard-rarime-link-svc"]
22 changes: 22 additions & 0 deletions Dockerfile.vendor
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM golang:1.20-alpine as buildbase

WORKDIR /go/src/github.com/rarimo/dashboard-rarime-link-svc
COPY vendor .
COPY . .

ENV GO111MODULE="on"
ENV CGO_ENABLED=0
ENV GOOS="linux"

RUN go build -o /usr/local/bin/dashboard-rarime-link-svc github.com/rarimo/dashboard-rarime-link-svc

###

FROM alpine:3.9 as calpine

RUN apk add --no-cache ca-certificates

FROM calpine

COPY --from=buildbase /usr/local/bin/dashboard-rarime-link-svc /usr/local/bin/dashboard-rarime-link-svc
ENTRYPOINT ["dashboard-rarime-link-svc"]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Zero Block Global Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
122 changes: 121 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,121 @@
# dashboard-rarime-link-svc
# Rarime Dashboard Link Service

Rarime Dashboard Link Service stores users proofs and provide simple access to it via REST API in [JSON:API] format.

## Getting Started
### Prerequisites

Before you begin, ensure you have met the following requirements:

- Docker installed, see [Docker installation guide]
- Go 1.20 installed, see [Go installation guide]


### Building

#### Binary
To build the service binary file, follow these steps:

1. Clone the repository.

```bash
git clone github.com/rarimo/dashboard-rarime-link-svc
cd dashboard-rarime-link-svc
```

1. Install dependencies and build the service.

```bash
go mod tidy
go build main.go
```

#### Docker

To build the service Docker image, follow these steps:


1. Clone the repository.

```bash
git clone github.com/rarimo/dashboard-rarime-link-svc
cd dashboard-rarime-link-svc
```

1. Build the service image.

```bash
sh ./build.sh
```

### Configuration

To properly configure the service, provide valid config file, see [config-example.yaml](config-example.yaml)
for example.

### Running with Docker

To run the service using Docker, follow these steps:

1. Build the service image, see [Building](#building).
1. Run the service image.

```bash
docker-compose up -d
```
1. The service will be available on the `8000` port.

## Usage

To use the service, you could use the swagger documentation, see [API Documentation](#api-documentation), or
any other http client.

## API Documentation

We use [openapi:json] standard for API. We use swagger for documenting our API.

To open online documentation, go to [swagger editor], here is how you can start it
```bash
cd docs
npm install
npm start
```
To build documentation use `npm run build` command,
that will create open-api documentation in `web_deploy` folder.

To generate resources for Go models run `./generate.sh` script in root folder.
use `./generate.sh --help` to see all available options.

## Contributing

We welcome contributions from the community! To contribute to this project, follow these steps:

1. Fork the repository.
1. Create a new branch with a descriptive name for your feature or bug fix.
1. Make your changes and commit them.
1. Push your changes to your branch on your GitHub fork.
1. Create a pull request from your branch to the `main` branch of this repository.

Please ensure your pull request adheres to the following guidelines:
- Add a clear pull request title;
- Add a comprehensive pull request description that includes the motivation behind the changes, steps needed to test them, etc;
- Update the [CHANGELOG.md](CHANGELOG) accordingly;
- Keep the codebase clean and well-documented;
- Make sure your code is properly tested;
- Reference any related issues in your pull request;

The maintainers will review your pull request and may request changes or provide feedback before merging. We appreciate your contributions!

## Changelog

For the changelog, see [CHANGELOG.md](CHANGELOG).

## License

This project is under the MIT License - see the [LICENSE](LICENSE) file for details.

[JSON:API]: https://jsonapi.org/
[Docker installation guide]: https://docs.docker.com/get-docker/
[Go installation guide]: https://golang.org/doc/install
[swagger editor]: http://localhost:8080/swagger-editor/
[openapi:json]: https://www.openapis.org/
10 changes: 10 additions & 0 deletions config-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
log:
disable_sentry: true
level: debug

listener:
addr: :8000

db:
url: postgres://link:link@localhost:15432/link-db?sslmode=disable

18 changes: 18 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3.7"

services:
link-db:
image: postgres:13
restart: unless-stopped
environment:
- POSTGRES_USER=link
- POSTGRES_PASSWORD=link
- POSTGRES_DB=link-db
- PGDATA=/pgdata
ports:
- "15432:5432"
volumes:
- link-data:/pgdata

volumes:
link-data:
Loading

0 comments on commit 002fc97

Please sign in to comment.