mirror of
https://github.com/grassrootseconomics/cic-custodial.git
synced 2024-12-22 01:47:31 +01:00
build: update ci build stages
This commit is contained in:
parent
5a94a38805
commit
0fd35f9668
10
.dockerignore
Normal file
10
.dockerignore
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.github
|
||||||
|
.deepsource.toml
|
||||||
|
.goreleaser.yaml
|
||||||
|
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
|
||||||
|
**/docker-compose*
|
||||||
|
**/Dockerfile*
|
37
.github/workflows/binary_release.yaml
vendored
37
.github/workflows/binary_release.yaml
vendored
@ -1,37 +0,0 @@
|
|||||||
name: binary_release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- "v*"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
goreleaser:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: goreleaser/goreleaser-cross
|
|
||||||
environment: build
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Workaround Git Security Warning
|
|
||||||
run: |
|
|
||||||
# Workaround a bug in github actions:
|
|
||||||
# https://github.com/actions/runner-images/issues/6775.
|
|
||||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
|
||||||
|
|
||||||
- name: Set up Go
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: 1.20.1
|
|
||||||
|
|
||||||
- name: Run GoReleaser
|
|
||||||
uses: goreleaser/goreleaser-action@v2
|
|
||||||
with:
|
|
||||||
version: latest
|
|
||||||
args: release --rm-dist
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
29
.github/workflows/docker_release.yaml
vendored
29
.github/workflows/docker_release.yaml
vendored
@ -1,29 +0,0 @@
|
|||||||
name: docker_release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- "v*"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-publish:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: docker/login-action@v1.14.1
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.repository_owner }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- name: docker compose build push
|
|
||||||
env:
|
|
||||||
DOCKER_BUILDKIT: 1
|
|
||||||
COMPOSE_DOCKER_CLI_BUILD: 1
|
|
||||||
run: |
|
|
||||||
export TAG=$GITHUB_REF_NAME
|
|
||||||
docker-compose -f docker-compose.build.yaml build --progress plain
|
|
||||||
docker-compose -f docker-compose.build.yaml push
|
|
||||||
export TAG=latest
|
|
||||||
docker-compose -f docker-compose.build.yaml build --progress plain
|
|
||||||
docker-compose -f docker-compose.build.yaml push
|
|
100
.github/workflows/release.yaml
vendored
Normal file
100
.github/workflows/release.yaml
vendored
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
name: release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Check out repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Cache Docker layers
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
|
- name: Login to GHCR Docker registry
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set outputs
|
||||||
|
run: |
|
||||||
|
echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||||
|
echo "RELEASE_SHORT_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Build and push image
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: ./
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: true
|
||||||
|
build-args: |-
|
||||||
|
BUILD_COMMIT=${{ env.RELEASE_SHORT_COMMIT }}
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
tags: |
|
||||||
|
ghcr.io/grassrootseconomics/cic-custodial/cic-custodial:latest
|
||||||
|
ghcr.io/grassrootseconomics/cic-custodial/cic-custodial:v${{ env.RELEASE_TAG }}
|
||||||
|
|
||||||
|
goreleaser:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: goreleaser/goreleaser-cross
|
||||||
|
environment: build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/go/pkg/mod
|
||||||
|
~/.cache/go-build
|
||||||
|
~/Library/Caches/go-build
|
||||||
|
%LocalAppData%\go-build
|
||||||
|
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-go-
|
||||||
|
|
||||||
|
- name: Workaround Git Security Warning
|
||||||
|
run: |
|
||||||
|
# Workaround a bug in github actions:
|
||||||
|
# https://github.com/actions/runner-images/issues/6775.
|
||||||
|
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 'stable'
|
||||||
|
|
||||||
|
- name: Run GoReleaser
|
||||||
|
uses: goreleaser/goreleaser-action@v4
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
args: release --rm-dist
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@ -10,7 +10,7 @@ builds:
|
|||||||
- amd64
|
- amd64
|
||||||
main: ./cmd/service
|
main: ./cmd/service
|
||||||
ldflags:
|
ldflags:
|
||||||
- -s -w
|
- -X main.build={{.ShortCommit}} -s -w
|
||||||
|
|
||||||
archives:
|
archives:
|
||||||
- format: tar.gz
|
- format: tar.gz
|
||||||
|
31
Dockerfile
31
Dockerfile
@ -1,20 +1,31 @@
|
|||||||
# build
|
|
||||||
FROM golang:1-bullseye as build
|
FROM golang:1-bullseye as build
|
||||||
WORKDIR /build
|
|
||||||
COPY . .
|
|
||||||
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o cic-custodial -ldflags="-s -w" cmd/service/*.go
|
|
||||||
|
|
||||||
# main
|
ENV CGO_ENABLED=1
|
||||||
|
ENV GOOS=linux
|
||||||
|
ENV GOARCH=amd64
|
||||||
|
|
||||||
|
ENV BUILD_COMMIT=${BUILD_COMMIT}
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
COPY go.* .
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN go build -o cic-custodial -ldflags="-X main.build=${BUILD_COMMIT} -s -w" cmd/service/*
|
||||||
|
|
||||||
FROM debian:bullseye-slim
|
FROM debian:bullseye-slim
|
||||||
|
|
||||||
ENV DEBIAN_FRONTEND=noninteractive
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
RUN set -x && \
|
|
||||||
apt-get update && \
|
|
||||||
apt-get install -y ca-certificates && \
|
|
||||||
rm -rf /var/cache/apt/archives /var/lib/apt/lists/*
|
|
||||||
WORKDIR /service
|
WORKDIR /service
|
||||||
|
|
||||||
|
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
COPY --from=build /build/cic-custodial .
|
COPY --from=build /build/cic-custodial .
|
||||||
COPY migrations migrations/
|
COPY migrations migrations/
|
||||||
COPY config.toml .
|
COPY config.toml .
|
||||||
COPY queries.sql .
|
COPY queries.sql .
|
||||||
CMD ["./cic-custodial"]
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
|
CMD ["./cic-custodial"]
|
||||||
|
@ -23,6 +23,8 @@ type (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
build string
|
||||||
|
|
||||||
confFlag string
|
confFlag string
|
||||||
debugFlag bool
|
debugFlag bool
|
||||||
migrationsFolderFlag string
|
migrationsFolderFlag string
|
||||||
@ -34,7 +36,7 @@ var (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flag.StringVar(&confFlag, "config", "config.toml", "Config file location")
|
flag.StringVar(&confFlag, "config", "config.toml", "Config file location")
|
||||||
flag.BoolVar(&debugFlag, "log", false, "Enable debug logging")
|
flag.BoolVar(&debugFlag, "debug", false, "Enable debug logging")
|
||||||
flag.StringVar(&migrationsFolderFlag, "migrations", "migrations/", "Migrations folder location")
|
flag.StringVar(&migrationsFolderFlag, "migrations", "migrations/", "Migrations folder location")
|
||||||
flag.StringVar(&queriesFlag, "queries", "queries.sql", "Queries file location")
|
flag.StringVar(&queriesFlag, "queries", "queries.sql", "Queries file location")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@ -68,7 +68,6 @@ func (s *Sub) Process() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, nats.ErrTimeout) {
|
if errors.Is(err, nats.ErrTimeout) {
|
||||||
s.logg.Debug("sub: no msg to pull")
|
s.logg.Debug("sub: no msg to pull")
|
||||||
time.Sleep(waitDelay)
|
|
||||||
continue
|
continue
|
||||||
} else if errors.Is(err, nats.ErrConnectionClosed) {
|
} else if errors.Is(err, nats.ErrConnectionClosed) {
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user