-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
8,846 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.DS_Store | ||
.dockerignore | ||
.git | ||
.github | ||
.gitignore | ||
.hadolint.yaml | ||
.vscode | ||
CHANGELOG.md | ||
Dockerfile | ||
LICENSE | ||
Makefile | ||
README.md | ||
bench | ||
/google-account.json | ||
/ovai |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.go] | ||
indent_style = tab | ||
|
||
[*.json] | ||
insert_final_newline = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
name: Build, Test and Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
tags-ignore: | ||
- '**' | ||
paths-ignore: | ||
- '**/*.md' | ||
- LICENSE | ||
pull_request: | ||
|
||
jobs: | ||
linux: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
changed: ${{ steps.bump.outputs.bumped }} | ||
changed-files: ${{ steps.bump.outputs.changed-files }} | ||
new-version: ${{ steps.bump.outputs.new-version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
- uses: prantlf/bump-version-action@v2 | ||
if: github.ref_name == 'master' | ||
id: bump | ||
with: | ||
bump-files: cmd/ovai/main.go | ||
- uses: prantlf/shelve-changes-action@v2 | ||
- run: make RELEASE=1 | ||
- uses: prantlf/shelve-output-action@v3 | ||
if: ${{ steps.bump.outputs.bumped == 'true' }} | ||
with: | ||
name: ovai | ||
|
||
linux-arm: | ||
if: ${{ github.ref_name == 'master' && needs.linux.outputs.changed == 'true' }} | ||
needs: | ||
- linux | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
- uses: prantlf/unshelve-changes-action@v2 | ||
with: | ||
files: ${{ needs.linux.outputs.changed-files }} | ||
discard-shelf: false | ||
- run: GOOS=linux GOARCH=arm64 make build RELEASE=1 | ||
- uses: prantlf/shelve-output-action@v3 | ||
with: | ||
name: ovai | ||
arch: arm64 | ||
|
||
macos: | ||
if: ${{ github.ref_name == 'master' && needs.linux.outputs.changed == 'true' }} | ||
needs: | ||
- linux | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
- uses: prantlf/unshelve-changes-action@v2 | ||
with: | ||
files: ${{ needs.linux.outputs.changed-files }} | ||
discard-shelf: false | ||
- run: GOOS=darwin GOARCH=amd64 make build RELEASE=1 | ||
- uses: prantlf/shelve-output-action@v3 | ||
with: | ||
name: ovai | ||
os: macos | ||
|
||
macos-arm: | ||
if: ${{ github.ref_name == 'master' && needs.linux.outputs.changed == 'true' }} | ||
needs: | ||
- linux | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
- uses: prantlf/unshelve-changes-action@v2 | ||
with: | ||
files: ${{ needs.linux.outputs.changed-files }} | ||
discard-shelf: false | ||
- run: GOOS=darwin GOARCH=arm64 make build RELEASE=1 | ||
- uses: prantlf/shelve-output-action@v3 | ||
with: | ||
name: ovai | ||
os: macos | ||
arch: arm64 | ||
|
||
windows: | ||
if: ${{ github.ref_name == 'master' && needs.linux.outputs.changed == 'true' }} | ||
needs: | ||
- linux | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
- uses: prantlf/unshelve-changes-action@v2 | ||
with: | ||
files: ${{ needs.linux.outputs.changed-files }} | ||
discard-shelf: false | ||
- run: | | ||
GOOS=windows GOARCH=amd64 make build RELEASE=1 | ||
mv ovai ovai.exe | ||
- uses: prantlf/shelve-output-action@v3 | ||
with: | ||
name: ovai | ||
os: windows | ||
|
||
windows-arm: | ||
if: ${{ github.ref_name == 'master' && needs.linux.outputs.changed == 'true' }} | ||
needs: | ||
- linux | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-go@v5 | ||
- uses: prantlf/unshelve-changes-action@v2 | ||
with: | ||
files: ${{ needs.linux.outputs.changed-files }} | ||
discard-shelf: false | ||
- run: | | ||
GOOS=windows GOARCH=arm64 make build RELEASE=1 | ||
mv ovai ovai.exe | ||
- uses: prantlf/shelve-output-action@v3 | ||
with: | ||
name: ovai | ||
os: windows | ||
arch: arm64 | ||
|
||
docker: | ||
needs: | ||
- linux | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: prantlf/unshelve-changes-action@v2 | ||
if: ${{ needs.linux.outputs.changed == 'true' }} | ||
with: | ||
files: ${{ needs.linux.outputs.changed-files }} | ||
discard-shelf: false | ||
- uses: hadolint/hadolint-action@v3.1.0 | ||
- uses: docker/build-push-action@v5 | ||
with: | ||
push: false | ||
|
||
release: | ||
if: ${{ github.ref_name == 'master' && needs.linux.outputs.changed == 'true' }} | ||
needs: | ||
- linux | ||
- linux-arm | ||
- macos | ||
- macos-arm | ||
- windows | ||
- windows-arm | ||
- docker | ||
runs-on: macos-13 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: prantlf/unshelve-changes-action@v2 | ||
with: | ||
files: ${{ needs.linux.outputs.changed-files }} | ||
discard-shelf: false | ||
- uses: prantlf/unshelve-output-action@v6 | ||
with: | ||
name: ovai | ||
- uses: prantlf/finish-release-action@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
docker-publish: | ||
if: ${{ github.ref_name == 'master' && needs.linux.outputs.changed == 'true' }} | ||
needs: | ||
- linux | ||
- release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: prantlf/unshelve-changes-action@v2 | ||
with: | ||
files: ${{ needs.linux.outputs.changed-files }} | ||
- uses: docker/metadata-action@v5 | ||
id: meta | ||
with: | ||
images: | | ||
ghcr.io/prantlf/ovai | ||
prantlf/ovai | ||
tags: | | ||
type=semver,pattern={{version}},value=v${{ needs.linux.outputs.new-version }} | ||
type=semver,pattern={{major}}.{{minor}},value=v${{ needs.linux.outputs.new-version }} | ||
type=semver,pattern={{major}},value=v${{ needs.linux.outputs.new-version }} | ||
- uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: docker/login-action@v3 | ||
if: ${{ steps.inspect.outputs.publish == 'true' }} | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USER }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- uses: docker/build-push-action@v5 | ||
with: | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
/ovai | ||
/google-account.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ignored: | ||
- DL3006 | ||
- DL3018 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"files.exclude": { | ||
"**/.git": true, | ||
"**/.DS_Store": true, | ||
"ovai": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
FROM golang:alpine as builder | ||
|
||
# RUN apk update && apk upgrade --no-cache && apk add --no-cache ca-certificates | ||
RUN apk update && apk upgrade --no-cache | ||
|
||
WORKDIR /src | ||
COPY . . | ||
RUN go build -trimpath -gcflags=all="-B" -ldflags="-s -w -buildid=" -o ovai ./cmd/ovai/main.go | ||
|
||
FROM prantlf/healthchk as healthchk | ||
|
||
# FROM gcr.io/distroless/static-debian12 | ||
FROM scratch | ||
LABEL maintainer="Ferdinand Prantl <prantlf@gmail.com>" | ||
|
||
# RUN apt-get update -y && apt-get upgrade -y && \ | ||
# apt-get install -y --no-install-recommends ca-certificates && \ | ||
# apt-get clean && apt-get autoremove && \ | ||
# rm -rf /var/cache/apt/archives/* && rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
COPY --from=builder /src/ovai / | ||
COPY --from=healthchk /healthchk / | ||
|
||
WORKDIR / | ||
EXPOSE 22434 | ||
ENTRYPOINT ["/ovai"] | ||
|
||
ARG DEBUG=ovai,ovai:srv | ||
ENV DEBUG=${DEBUG} | ||
ENV PORT=22434 | ||
|
||
# HEALTHCHECK --interval=5m \ | ||
# CMD /healthchk http://localhost:22434/api/ping || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
RELFLAGS= | ||
ifeq (1,${RELEASE}) | ||
RELFLAGS:=-trimpath -gcflags=all="-B" -ldflags="-s -w -buildid=" | ||
endif | ||
|
||
all: lint build test | ||
|
||
lint: | ||
go vet ./... | ||
|
||
format: | ||
go fmt ./... | ||
|
||
build: | ||
go build $(RELFLAGS) -o ovai ./cmd/ovai/main.go | ||
|
||
test: | ||
go test ./internal/... | ||
|
||
bench:: | ||
cd bench && go test -benchmem -bench=. | ||
|
||
clean: | ||
go clean | ||
rm -f ovai | ||
|
||
docker: docker-lint docker-build | ||
|
||
docker-clean: | ||
docker image rm ovai | ||
|
||
docker-lint: | ||
docker run --rm -i \ | ||
-v ${PWD}/.hadolint.yaml:/bin/hadolint.yaml \ | ||
-e XDG_CONFIG_HOME=/bin hadolint/hadolint \ | ||
< Dockerfile | ||
|
||
docker-build: | ||
docker build -t ovai . | ||
|
||
docker-enter: | ||
docker run --rm -it -p 22434:22434 --entrypoint sh \ | ||
-v ${PWD}/google-account.json:/google-account.json \ | ||
-v ${PWD}/model-defaults.json:/model-defaults.json \ | ||
ovai | ||
|
||
docker-start: | ||
docker run --rm -dt -p 22434:22434 --name ovai \ | ||
-v ${PWD}/google-account.json:/google-account.json \ | ||
-v ${PWD}/model-defaults.json:/model-defaults.json \ | ||
ovai | ||
|
||
docker-kill: | ||
docker container kill ovai | ||
|
||
docker-log: | ||
docker logs ovai | ||
|
||
docker-up: | ||
IMAGE_HUB= docker compose -f docker-compose.yml up -d --wait | ||
|
||
docker-down: | ||
IMAGE_HUB= docker compose -f docker-compose.yml down |
Oops, something went wrong.