Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
olegfomenko committed Oct 30, 2023
0 parents commit 3346578
Show file tree
Hide file tree
Showing 51 changed files with 6,097 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build Rarimo EVM saver service docker image
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/[email protected]

- 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
37 changes: 37 additions & 0 deletions .github/workflows/actions_onlymain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build Rarimo TSS service docker image
on:
push:
branches:
- 'main'
- 'master'
- 'chains/mainnet'
- 'chains/mainnet-beta'

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/[email protected]

- 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/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build Rarimo EVM saver service docker image
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/[email protected]

- 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
config.*.yaml
vendor/
191 changes: 191 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@

default:
image:
name: "tokend/werf:0.0.9"
entrypoint: [""]
services:
- name: docker:20-dind
alias: docker
command: ["--tls=false"]
tags:
- "tokend"


variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
SERVICE: $CI_PROJECT_NAME
REGISTRY: registry.gitlab.com/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME
IMAGE_NAME: $REGISTRY:$CI_COMMIT_SHA
IMAGE_NAME_TAG: $REGISTRY:$CI_COMMIT_TAG
DH_IMAGE_NAME: $CI_PROJECT_ROOT_NAMESPACE/$CI_PROJECT_NAME
WERF_LOG_COLOR_MODE: "on"
WERF_IMAGES_REPO: $CI_REGISTRY_IMAGE
WERF_BUILDAH_MODE: auto

.before_script_template: &before_script_templ
before_script:
- werf version
- docker version
- echo $CI_REGISTRY
- echo $CI_REGISTRY_USER
- echo $CI_REGISTRY_PASSWORD
- echo $WERF_IMAGES_REPO
- echo $WERF_ADD_CUSTOM_TAG_1


stages:
- build-and-publish
# - code-review
- docs
#- deploy
#- update
- cleanup

Build and Publish:
stage: build-and-publish
<<: *before_script_templ
script:
- type werf && source $(werf ci-env gitlab --as-file)
- werf build --report-path=images-report.json
- docker pull $(cat images-report.json | jq -r .Images.service.DockerImageName)
- docker tag $(cat images-report.json | jq -r .Images.service.DockerImageName) $IMAGE_NAME
- docker push $IMAGE_NAME
except: [schedules]
interruptible: true

Build and Publish Tag:
stage: build-and-publish
only:
- tags
<<: *before_script_templ
script:
- type werf && source $(werf ci-env gitlab --as-file)
- werf build --report-path=images-report.json
- docker pull $(cat images-report.json | jq -r .Images.service.DockerImageName)
- docker tag $(cat images-report.json | jq -r .Images.service.DockerImageName) $IMAGE_NAME_TAG
- docker push $IMAGE_NAME_TAG
except: [schedules]
interruptible: true

# Code-Review:
# image: golang:1.16
# stage: code-review
# only:
# - merge_requests
# except: [schedules]
# interruptible: true
# variables:
# GIT_STRATEGY: clone
# GIT_CHECKOUT: "true"
# GIT_DEPTH: "0"
# before_script:
# - |
# raw='runner:
# \n\tgolangci-lint:
# \n\t\tcmd: golangci-lint run
# \n\t\terrorformat:
# \n\t\t\t- "%f:%l:%c: %m"'
# - echo -e $raw > reviewdog.yml
# - curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b ./bin
# - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.43.0
# script:
# - if [ -f reviewdog.yml ]; then ./bin/reviewdog -reporter=gitlab-mr-discussion -tee; fi
# needs: []

pages:
image: node:8
stage: docs
only:
- master
script:
- cd docs
- npm install
- mkdir -p ../public
- npm run release-build
artifacts:
paths:
- public
except: [schedules]
interruptible: true

##########################
# use for deployment via #
# helm chart must be in #
# the .helm directory #
##########################

# Deploy to Staging:
# services:
# - docker:18-dind
# image: dtzar/helm-kubectl:latest
# tags:
# - tokend-deploy
# stage: deploy
# script:
# - mkdir ~/.kube/
# - echo ${k8sconfig} | base64 -d > config
# - mv config ~/.kube/
# - helm upgrade -i "webclient" ".helm" --set global.IngressDomain=stage.${DOMAIN} --set "image.repository=${REGISTRY}" --set "image.tag=${CI_COMMIT_SHA}" --create-namespace --namespace $CI_PROJECT_NAME-stage
# interruptible: true

# Deploy to Production:
# services:
# - docker:18-dind
# image: dtzar/helm-kubectl:latest
# tags:
# - tokend-deploy
# stage: deploy
# script:
# - mkdir ~/.kube/
# - echo ${k8sconfig} | base64 -d > config
# - mv config ~/.kube/
# - helm upgrade -i "webclient" ".helm" --set global.IngressDomain=${DOMAIN} --set "image.repository=${REGISTRY}" --set "image.tag=${CI_COMMIT_TAG}" --create-namespace --namespace $CI_PROJECT_NAME-prod
# when: manual
# interruptible: true

##############################
# can be used if deployment #
# via helm was not initially #
# configured #
##############################

# Update to Staging:
# services:
# - docker:18-dind
# image: dtzar/helm-kubectl:latest
# tags:
# - tokend-deploy
# stage: update
# script:
# - mkdir ~/.kube/
# - echo ${k8sconfig} | base64 -d > config
# - mv config ~/.kube/
# - kubectl set image deployment/my-deployment mycontainer=myimage:1.9.1 -n mynamespace
# interruptible: true

# Update to Production:
# services:
# - docker:18-dind
# image: dtzar/helm-kubectl:latest
# tags:
# - tokend-deploy
# stage: update
# script:
# - mkdir ~/.kube/
# - echo ${k8sconfig} | base64 -d > config
# - mv config ~/.kube/
# - kubectl set image deployment/my-deployment mycontainer=myimage:1.9.1 -n mynamespace
# when: manual
# interruptible: true

Cleanup:
stage: cleanup
<<: *before_script_templ
script:
- type multiwerf && . $(multiwerf use 1.1 stable --as-file)
- type werf && source $(werf ci-env gitlab --as-file)
- docker login -u nobody -p ${WERF_IMAGES_CLEANUP_PASSWORD} ${WERF_IMAGES_REPO}
- werf cleanup --dev
only: [schedules]
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.19-alpine as buildbase

WORKDIR /go/src/github.com/rarimo/evm-saver-svc
COPY vendor .
COPY . .

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

RUN apk add build-base
RUN go build -o /usr/local/bin/evm-saver-svc github.com/rarimo/evm-saver-svc

###

FROM alpine:3.9

COPY --from=buildbase /usr/local/bin/evm-saver-svc /usr/local/bin/evm-saver-svc
RUN apk add --no-cache ca-certificates

ENTRYPOINT ["evm-saver-svc"]
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright 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.
Loading

0 comments on commit 3346578

Please sign in to comment.