Skip to content

Commit 78bdd10

Browse files
authored
Merge pull request #289 from authorizerdev/fix/build
Fix/build
2 parents 4afd544 + 512fd4f commit 78bdd10

File tree

6 files changed

+165
-33
lines changed

6 files changed

+165
-33
lines changed

.github/workflows/release.yaml

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,44 @@ on:
22
workflow_dispatch:
33
inputs:
44
logLevel:
5-
description: 'Log level'
5+
description: "Log level"
66
required: true
7-
default: 'warning'
7+
default: "warning"
88
type: choice
99
options:
10-
- info
11-
- warning
12-
- debug
10+
- info
11+
- warning
12+
- debug
1313
tags:
14-
description: 'Tags'
15-
required: false
14+
description: "Tags"
15+
required: false
1616
type: boolean
1717
release:
1818
types: [created]
1919

2020
jobs:
2121
releases:
22-
name: Release Authorizer Binary
22+
name: Release Authorizer
2323
runs-on: ubuntu-latest
2424
steps:
25-
- uses: actions/checkout@v2
25+
- uses: actions/checkout@v3
2626
- uses: actions/setup-node@v2
2727
with:
28-
node-version: '16'
28+
node-version: "16"
29+
- # Add support for more platforms with QEMU (optional)
30+
# https://github.com/docker/setup-qemu-action
31+
name: Set up QEMU
32+
uses: docker/setup-qemu-action@v2
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v2
35+
with:
36+
platforms: linux/amd64,linux/arm64
2937
- uses: actions/setup-go@v2
3038
with:
31-
go-version: '^1.17.3'
39+
go-version: "^1.17.3"
3240
- name: Install dependencies
3341
run: |
34-
sudo apt-get install build-essential wget zip gcc-mingw-w64 && \
42+
sudo apt-get install build-essential wget zip libc6-dev-arm64-cross && \
3543
echo "/usr/bin/x86_64-w64-mingw32-gcc" >> GITHUB_PATH && \
3644
wget --no-check-certificate --progress=dot:mega https://github.com/wangyoucao577/assets-uploader/releases/download/v0.3.0/github-assets-uploader-v0.3.0-linux-amd64.tar.gz -O github-assets-uploader.tar.gz && \
3745
tar -zxf github-assets-uploader.tar.gz && \
@@ -44,25 +52,26 @@ jobs:
4452
run: whereis go
4553
- name: Print Go Version
4654
run: go version
55+
- name: Install gox
56+
run: go install github.com/mitchellh/gox@latest
4757
- name: Set VERSION env
4858
run: echo VERSION=$(basename ${GITHUB_REF}) >> ${GITHUB_ENV}
4959
- name: Copy .env file
5060
run: mv .env.sample .env
51-
- name: Package files for windows
52-
run: |
53-
make clean && \
54-
CGO_ENABLED=1 GOOS=windows CC=/usr/bin/x86_64-w64-mingw32-gcc make && \
55-
mv build/server build/server.exe && \
56-
zip -vr authorizer-${VERSION}-windows-amd64.zip .env app/build build templates dashboard/build
57-
- name: Package files for linux
61+
- name: Build package
5862
run: |
5963
make clean && \
60-
CGO_ENABLED=1 make && \
61-
tar cvfz authorizer-${VERSION}-linux-amd64.tar.gz .env app/build build templates dashboard/build
64+
make build && \
65+
mkdir -p authorizer-${VERSION}-darwin-amd64/build authorizer-${VERSION}-darwin-amd64/app authorizer-${VERSION}-darwin-amd64/dashboard && cp build/darwin/amd64/server authorizer-${VERSION}-darwin-amd64/build/ && cp .env authorizer-${VERSION}-darwin-amd64/.env && cp -rf app/build authorizer-${VERSION}-darwin-amd64/app/build && cp -rf templates authorizer-${VERSION}-darwin-amd64/ && cp -rf dashboard/build authorizer-${VERSION}-darwin-amd64/dashboard/build && tar cvfz authorizer-${VERSION}-darwin-amd64.tar.gz authorizer-${VERSION}-darwin-amd64 && \
66+
mkdir -p authorizer-${VERSION}-linux-amd64/build authorizer-${VERSION}-linux-amd64/app authorizer-${VERSION}-linux-amd64/dashboard && cp build/linux/amd64/server authorizer-${VERSION}-linux-amd64/build/ && cp .env authorizer-${VERSION}-linux-amd64/.env && cp -rf app/build authorizer-${VERSION}-linux-amd64/app/build && cp -rf templates authorizer-${VERSION}-linux-amd64/ && cp -rf dashboard/build authorizer-${VERSION}-linux-amd64/dashboard/build && tar cvfz authorizer-${VERSION}-linux-amd64.tar.gz authorizer-${VERSION}-linux-amd64 && \
67+
mkdir -p authorizer-${VERSION}-linux-arm64/build authorizer-${VERSION}-linux-arm64/app authorizer-${VERSION}-linux-arm64/dashboard && cp build/linux/arm64/server authorizer-${VERSION}-linux-arm64/build/ && cp .env authorizer-${VERSION}-linux-arm64/.env && cp -rf app/build authorizer-${VERSION}-linux-arm64/app/build && cp -rf templates authorizer-${VERSION}-linux-arm64/ && cp -rf dashboard/build authorizer-${VERSION}-linux-arm64/dashboard/build && tar cvfz authorizer-${VERSION}-linux-arm64.tar.gz authorizer-${VERSION}-linux-arm64 && \
68+
mkdir -p authorizer-${VERSION}-windows-amd64/build authorizer-${VERSION}-windows-amd64/app authorizer-${VERSION}-windows-amd64/dashboard && cp build/windows/amd64/server.exe authorizer-${VERSION}-windows-amd64/build/ && cp .env authorizer-${VERSION}-windows-amd64/.env && cp -rf app/build authorizer-${VERSION}-windows-amd64/app/build && cp -rf templates authorizer-${VERSION}-windows-amd64/ && cp -rf dashboard/build authorizer-${VERSION}-windows-amd64/dashboard/build && zip -vr authorizer-${VERSION}-windows-amd64.zip authorizer-${VERSION}-windows-amd64
6269
- name: Upload assets
6370
run: |
64-
github-assets-uploader -f authorizer-${VERSION}-windows-amd64.zip -mediatype application/zip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION} && \
71+
github-assets-uploader -f authorizer-${VERSION}-darwin-amd64.tar.gz -mediatype application/gzip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION}
6572
github-assets-uploader -f authorizer-${VERSION}-linux-amd64.tar.gz -mediatype application/gzip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION}
73+
github-assets-uploader -f authorizer-${VERSION}-linux-arm64.tar.gz -mediatype application/gzip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION}
74+
github-assets-uploader -f authorizer-${VERSION}-windows-amd64.zip -mediatype application/zip -repo authorizerdev/authorizer -token ${{secrets.RELEASE_TOKEN}} -tag ${VERSION}
6675
- name: Log in to Docker Hub
6776
uses: docker/login-action@v1
6877
with:
@@ -74,6 +83,14 @@ jobs:
7483
uses: docker/metadata-action@v3
7584
with:
7685
images: lakhansamani/authorizer
86+
flavor: |
87+
latest=false
88+
tags: |
89+
type=schedule
90+
type=ref,event=branch
91+
type=ref,event=tag
92+
type=ref,event=pr
93+
type=raw,value=latest,enable={{is_default_branch}}
7794
7895
- name: Build and push Docker image
7996
uses: docker/build-push-action@v2
@@ -82,5 +99,6 @@ jobs:
8299
push: true
83100
tags: ${{ steps.meta.outputs.tags }}
84101
labels: ${{ steps.meta.outputs.labels }}
102+
platforms: linux/amd64,linux/arm64
85103
build-args: |
86104
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ test.db
1515
.vscode/
1616
.yalc
1717
yalc.lock
18-
certs/
18+
certs/
19+
*-shm
20+
*-wal

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@ VERSION := $(or $(VERSION),$(DEFAULT_VERSION))
33

44
cmd:
55
cd server && go build -ldflags "-w -X main.VERSION=$(VERSION)" -o '../build/server'
6+
build:
7+
cd server && gox \
8+
-osarch="linux/amd64 linux/arm64 darwin/amd64 windows/amd64" \
9+
-ldflags "-w -X main.VERSION=$(VERSION)" \
10+
-output="../build/{{.OS}}/{{.Arch}}/server" \
11+
./...
612
build-app:
713
cd app && npm i && npm run build
814
build-dashboard:
915
cd dashboard && npm i && npm run build
1016
clean:
1117
rm -rf build
1218
test:
13-
rm -rf server/test/test.db && rm -rf test.db && cd server && go clean --testcache && TEST_DBS="sqlite" go test -p 1 -v ./test
19+
rm -rf server/test/test.db server/test/test.db-shm server/test/test.db-wal && rm -rf test.db test.db-shm test.db-wal && cd server && go clean --testcache && TEST_DBS="sqlite" go test -p 1 -v ./test
1420
test-mongodb:
1521
docker run -d --name authorizer_mongodb_db -p 27017:27017 mongo:4.4.15
1622
cd server && go clean --testcache && TEST_DBS="mongodb" go test -p 1 -v ./test
@@ -28,7 +34,7 @@ test-dynamodb:
2834
cd server && go clean --testcache && TEST_DBS="dynamodb" go test -p 1 -v ./test
2935
docker rm -vf dynamodb-local-test
3036
test-all-db:
31-
rm -rf server/test/test.db && rm -rf test.db
37+
rm -rf server/test/test.db server/test/test.db-shm server/test/test.db-wal && rm -rf test.db test.db-shm test.db-wal
3238
docker run -d --name authorizer_scylla_db -p 9042:9042 scylladb/scylla
3339
docker run -d --name authorizer_mongodb_db -p 27017:27017 mongo:4.4.15
3440
docker run -d --name authorizer_arangodb -p 8529:8529 -e ARANGO_NO_AUTH=1 arangodb/arangodb:3.8.4

server/db/providers/sql/provider.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99
"github.com/authorizerdev/authorizer/server/constants"
1010
"github.com/authorizerdev/authorizer/server/db/models"
1111
"github.com/authorizerdev/authorizer/server/memorystore"
12+
"github.com/glebarez/sqlite"
1213
"gorm.io/driver/mysql"
1314
"gorm.io/driver/postgres"
14-
"gorm.io/driver/sqlite"
1515
"gorm.io/driver/sqlserver"
1616
"gorm.io/gorm"
1717
"gorm.io/gorm/logger"
@@ -61,7 +61,7 @@ func NewProvider() (*provider, error) {
6161
case constants.DbTypePostgres, constants.DbTypeYugabyte, constants.DbTypeCockroachDB:
6262
sqlDB, err = gorm.Open(postgres.Open(dbURL), ormConfig)
6363
case constants.DbTypeSqlite:
64-
sqlDB, err = gorm.Open(sqlite.Open(dbURL), ormConfig)
64+
sqlDB, err = gorm.Open(sqlite.Open(dbURL+"?_pragma=busy_timeout(5000)&_pragma=journal_mode(WAL)"), ormConfig)
6565
case constants.DbTypeMysql, constants.DbTypeMariaDB, constants.DbTypePlanetScaleDB:
6666
sqlDB, err = gorm.Open(mysql.Open(dbURL), ormConfig)
6767
case constants.DbTypeSqlserver:

server/go.mod

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ require (
77
github.com/arangodb/go-driver v1.2.1
88
github.com/aws/aws-sdk-go v1.44.109
99
github.com/coreos/go-oidc/v3 v3.1.0
10+
github.com/denisenkom/go-mssqldb v0.11.0 // indirect
1011
github.com/gin-gonic/gin v1.8.1
12+
github.com/glebarez/sqlite v1.5.0 // indirect
1113
github.com/go-playground/validator/v10 v10.11.1 // indirect
1214
github.com/go-redis/redis/v8 v8.11.0
1315
github.com/goccy/go-json v0.9.11 // indirect
@@ -17,14 +19,15 @@ require (
1719
github.com/google/uuid v1.3.0
1820
github.com/guregu/dynamo v1.16.0
1921
github.com/joho/godotenv v1.3.0
22+
github.com/mitchellh/gox v1.0.1 // indirect
2023
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
2124
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
2225
github.com/robertkrimen/otto v0.0.0-20211024170158-b87d35c0b86f
2326
github.com/sirupsen/logrus v1.8.1
2427
github.com/stretchr/testify v1.8.0
2528
github.com/vektah/gqlparser/v2 v2.5.1
2629
go.mongodb.org/mongo-driver v1.8.1
27-
golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be
30+
golang.org/x/crypto v0.0.0-20221005025214-4161e89ecf1b
2831
golang.org/x/net v0.0.0-20220930213112-107f3e3c3b0b // indirect
2932
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914
3033
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect
@@ -33,9 +36,8 @@ require (
3336
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
3437
gopkg.in/mail.v2 v2.3.1
3538
gopkg.in/square/go-jose.v2 v2.6.0
36-
gorm.io/driver/mysql v1.2.1
37-
gorm.io/driver/postgres v1.2.3
38-
gorm.io/driver/sqlite v1.2.6
39-
gorm.io/driver/sqlserver v1.2.1
40-
gorm.io/gorm v1.22.4
39+
gorm.io/driver/mysql v1.4.3
40+
gorm.io/driver/postgres v1.4.5
41+
gorm.io/driver/sqlserver v1.4.1
42+
gorm.io/gorm v1.24.1
4143
)

0 commit comments

Comments
 (0)