Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackmeng1985 committed Jun 14, 2024
0 parents commit 8efaf30
Show file tree
Hide file tree
Showing 909 changed files with 181,208 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Build
run: make ast

- name: Test
run: go test -v ./...

- name: Benchmark
run: go test -bench ./...
52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Release

# Uncomment the following to let goreleaser automatically
# create a GitHub release when a tag is pushed.
# permissions:
# contents: write

on:
push:
branches-ignore:
- '**'
tags:
- 'v*.*.*'
# to be used by fork patch-releases ^^
- 'v*.*.*-*'
workflow_dispatch:

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: dockerhub-login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB }}
password: ${{ secrets.DOCKERHUB_KEY }}

- name: Prepare
id: prepare
run: |
TAG=${GITHUB_REF#refs/tags/}
echo ::set-output name=tag_name::${TAG}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- run: echo ${{ steps.prepare.outputs.tag_name }}

- name: Run GoReleaser
run: |
make release
docker images
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
VERSION: ${{ steps.prepare.outputs.tag_name }}
DOCKER_USERNAME: ${{ secrets.DOCKERHUB }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_KEY }}
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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/

#
build/
.idea

#vscode
.vscode/

# utests
modules/rawdb/mdbx.db/

# mobile outputs
mobile/

.DS_Store
ast

genesis*.json

./deployments/
99 changes: 99 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
project_name: ast

release:
disable: false
draft: true
prerelease: auto

builds:
- id: darwin-amd64
main: ./cmd/ast
binary: astranet
goos: [ darwin ]
goarch: [ amd64 ]
env:
- CC=o64-clang
- CXX=o64-clang++
tags: [ nosqlite, noboltdb ]
ldflags: -s -w

- id: darwin-arm64
main: ./cmd/ast
binary: astranet
goos: [ darwin ]
goarch: [ arm64 ]
env:
- CC=oa64-clang
- CXX=oa64-clang++
tags: [ nosqlite, noboltdb ]
ldflags: -s -w

- id: linux-amd64
main: ./cmd/ast
binary: astranet
goos: [ linux ]
goarch: [ amd64 ]
env:
- CC=x86_64-linux-gnu-gcc
- CXX=x86_64-linux-gnu-g++
tags: [ nosqlite, noboltdb ]
ldflags: -s -w -extldflags "-static" # We need to build a static binary because we are building in a glibc based system and running in a musl container

- id: linux-arm64
main: ./cmd/ast
binary: astranet
goos: [ linux ]
goarch: [ arm64 ]
env:
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
tags: [ nosqlite, noboltdb ]
ldflags: -s -w -extldflags "-static" # We need to build a static binary because we are building in a glibc based system and running in a musl container

- id: windows-amd64
main: ./cmd/ast
binary: astranet
goos: [ windows ]
goarch: [ amd64 ]
env:
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
tags: [ nosqlite, noboltdb ]
ldflags: -s -w


dockers:
- image_templates:
- astranet/{{ .ProjectName }}:{{ .Version }}-amd64
dockerfile: Dockerfile.release
use: buildx
skip_push: true
goarch: amd64
ids:
- linux-amd64
build_flag_templates:
- --platform=linux/amd64

- image_templates:
- astranet/{{ .ProjectName }}:{{ .Version }}-arm64
dockerfile: Dockerfile.release
skip_push: true
use: buildx
goarch: arm64
ids:
- linux-arm64
build_flag_templates:
- --platform=linux/arm64/v8

docker_manifests:
- name_template: astranet/{{ .ProjectName }}:{{ .Version }}
skip_push: true
image_templates:
- astranet/{{ .ProjectName }}:{{ .Version }}-amd64
- astranet/{{ .ProjectName }}:{{ .Version }}-arm64

- name_template: astranet/{{ .ProjectName }}:latest
skip_push: true
image_templates:
- astranet/{{ .ProjectName }}:{{ .Version }}-amd64
- astranet/{{ .ProjectName }}:{{ .Version }}-arm64
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Build
FROM golang:1.19-alpine3.15 AS builder

# RUN apk add --no-cache gcc musl-dev linux-headers git make
RUN apk add --no-cache build-base linux-headers git bash ca-certificates libstdc++

WORKDIR /ast
ADD . .
ENV GO111MODULE="on"
RUN go mod tidy && go build -o ./build/bin/astranet ./cmd/ast


FROM alpine:3.15
#libstdc++
RUN apk add --no-cache ca-certificates curl tzdata
# copy compiled artifacts from builder
COPY --from=builder /ast/build/bin/* /usr/local/bin/

# Setup user and group
#
# from the perspective of the container, uid=1000, gid=1000 is a sensible choice, but if caller creates a .env
# (example in repo root), these defaults will get overridden when make calls docker-compose
ARG UID=1000
ARG GID=1000
RUN adduser -D -u $UID -g $GID ast


ENV astDATA /home/ast/data
# this 777 will be replaced by 700 at runtime (allows semi-arbitrary "--user" values)
RUN mkdir -p "$astDATA" && chown -R ast:ast "$astDATA" && chmod 777 "$astDATA"
VOLUME /home/ast/data

USER ast
WORKDIR /home/ast

RUN echo $UID

EXPOSE 20012 20013 20014 61015/udp 61016 6060
ENTRYPOINT ["astranet"]
21 changes: 21 additions & 0 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM alpine:3.15

RUN apk add --no-cache ca-certificates curl tzdata

COPY astranet /usr/local/bin/

ARG UID=1000
ARG GID=1000
RUN adduser -D -u $UID -g $GID ast


ENV astDATA /home/ast/data
# this 777 will be replaced by 700 at runtime (allows semi-arbitrary "--user" values)
RUN mkdir -p "$astDATA" && chown -R ast:ast "$astDATA" && chmod 777 "$astDATA"
VOLUME /home/ast/data

USER ast
WORKDIR /home/ast

EXPOSE 20012 20013 20014 61015/udp 61016 6060
ENTRYPOINT ["astranet"]
Loading

0 comments on commit 8efaf30

Please sign in to comment.