Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

chore: build on arm64 and amd64 (#1040)

Guilherme Oenning0eae211df03f
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e406e8bbf..a7ff455d8 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -25,6 +25,10 @@ jobs:
test-server:
name: test-server
runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ arch: [x86_64, arm64]
services:
minio:
image: getfider/minio:0.0.2
@@ -67,6 +71,7 @@ jobs:
BLOB_STORAGE_S3_ENDPOINT_URL: http://localhost:9000
DATABASE_URL: postgres://fider_ci:fider_ci_pw@localhost:5432/fider_ci?sslmode=disable
+ # The build job uses the Dockerfile to build an image which is then used by e2e tests
build:
name: build
runs-on: ubuntu-latest
@@ -79,7 +84,7 @@ jobs:
echo sha7=${GITHUB_SHA::7}
id: vars
- - run: docker build --build-arg buildnumber=${{ steps.vars.outputs.sha7 }} -t fider-image .
+ - run: docker build -t fider-image .
- run: mkdir -p ./out
@@ -89,7 +94,6 @@ jobs:
if: ${{ github.event_name == 'pull_request' }}
- run: echo ${{ steps.vars.outputs.sha7 }} > ./out/sha7
- if: ${{ github.event_name == 'push' }}
- uses: actions/upload-artifact@v2
with:
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 5d521c4f3..8ed3bec36 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -16,28 +16,16 @@ jobs:
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
- - name: download artifact
- uses: actions/[email protected]
+ - name: Checkout
+ uses: actions/checkout@v2
with:
- script: |
- var artifacts = await github.actions.listWorkflowRunArtifacts({
- owner: context.repo.owner,
- repo: context.repo.repo,
- run_id: ${{github.event.workflow_run.id }},
- });
- var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
- return artifact.name == "fider-image"
- })[0];
- var download = await github.actions.downloadArtifact({
- owner: context.repo.owner,
- repo: context.repo.repo,
- artifact_id: matchArtifact.id,
- archive_format: 'zip',
- });
- var fs = require('fs');
- fs.writeFileSync('${{github.workspace}}/fider-image.zip', Buffer.from(download.data));
- - run: unzip fider-image.zip
- - run: docker load --input fider-image.tar
+ ref: ${{ github.event.workflow_run.head_sha }}
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v1
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
@@ -45,16 +33,20 @@ jobs:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- - name: push docker image (pull_request)
+ - name: build and push docker image (pull_request)
if: ${{ github.event.workflow_run.event == 'pull_request' }}
- run: |
- docker tag fider-image getfider/fider:PR_$(cat ./pr)
- docker push getfider/fider:PR_$(cat ./pr)
+ uses: docker/build-push-action@v2
+ with:
+ push: true
+ build-args: BUILDNUMBER=${{ github.event.workflow_run.head_sha }}
+ platforms: linux/amd64,linux/arm64/v8
+ tags: getfider/fider:PR_${{ github.event.workflow_run.pull_requests[0].number }}
- - name: push docker image (push)
+ - name: build and push docker image (push)
if: ${{ github.event.workflow_run.event == 'push' }}
- run: |
- docker tag fider-image getfider/fider:SHA_$(cat ./sha7)
- docker push getfider/fider:SHA_$(cat ./sha7)
- docker tag fider-image getfider/fider:main
- docker push getfider/fider:main
+ uses: docker/build-push-action@v2
+ with:
+ push: true
+ build-args: BUILDNUMBER=${{ github.event.workflow_run.head_sha }}
+ platforms: linux/amd64,linux/arm64/v8
+ tags: getfider/fider:SHA_${{ github.event.workflow_run.head_sha }},getfider/fider:main
diff --git a/Dockerfile b/Dockerfile
index f00c3a10b..6af851616 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,22 +1,23 @@
#####################
### Server Build Step
#####################
-FROM golang:1.17-buster AS server-builder
+FROM --platform=${TARGETPLATFORM:-linux/amd64} golang:1.17-buster AS server-builder
-ARG buildnumber=local
+ARG BUILDNUMBER=local
+ARG TARGETOS
+ARG TARGETARCH
RUN mkdir /server
WORKDIR /server
COPY . .
-RUN BUILDNUMBER=${buildnumber} GOOS=linux GOARCH=amd64 make build-server
+RUN BUILDNUMBER=${BUILDNUMBER} GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build-server
#################
### UI Build Step
#################
-FROM node:16-buster AS ui-builder
+FROM --platform=${TARGETPLATFORM:-linux/amd64} node:16-buster AS ui-builder
-RUN mkdir /ui
WORKDIR /ui
COPY . .
@@ -27,12 +28,11 @@ RUN make build-ui
################
### Runtime Step
################
-FROM debian:buster-slim
+FROM --platform=${TARGETPLATFORM:-linux/amd64} debian:buster-slim
RUN apt-get update
RUN apt-get install -y ca-certificates
-RUN mkdir /app
WORKDIR /app
COPY --from=server-builder /server/migrations /app/migrations
diff --git a/Makefile b/Makefile
index 3e4e1676c..1bc19837e 100644
--- a/Makefile
+++ b/Makefile
@@ -78,7 +78,7 @@ watch-ui: ## Build and run server in watch mode
lint: lint-server lint-ui ## Lint server and ui
lint-server: ## Lint server code
- golangci-lint run
+ golangci-lint run --timeout 2m
lint-ui: ## Lint ui code
npx eslint .
diff --git a/app/pkg/web/react.go b/app/pkg/web/react.go
index 0b09a6fa6..0be8514be 100644
--- a/app/pkg/web/react.go
+++ b/app/pkg/web/react.go
@@ -22,10 +22,7 @@ type ReactRenderer struct {
func newIsolatePool() *sync.Pool {
return &sync.Pool{
New: func() interface{} {
- isolate, err := v8go.NewIsolate()
- if err != nil {
- return errors.Wrap(err, "unable to initialize v8 isolate.")
- }
+ isolate := v8go.NewIsolate()
runtime.SetFinalizer(isolate, func(iso *v8go.Isolate) {
if iso != nil {
@@ -60,13 +57,10 @@ func (r *ReactRenderer) Render(u *url.URL, props Map) (string, error) {
}
defer r.pool.Put(isolate)
- v8ctx, err := v8go.NewContext(isolate)
- if err != nil {
- return "", errors.Wrap(err, "unable to initialize v8 context.")
- }
+ v8ctx := v8go.NewContext(isolate)
defer v8ctx.Close()
- _, err = v8ctx.RunScript(string(r.scriptContent), r.scriptPath)
+ _, err := v8ctx.RunScript(string(r.scriptContent), r.scriptPath)
if err != nil {
return "", errors.Wrap(err, "failed to execute SSR script.")
}
diff --git a/go.mod b/go.mod
index f2cfa040e..a655713b5 100644
--- a/go.mod
+++ b/go.mod
@@ -26,7 +26,7 @@ require (
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
golang.org/x/net v0.0.0-20211029224645-99673261e6eb
golang.org/x/oauth2 v0.0.0-20211028175245-ba495a64dcb5
- rogchap.com/v8go v0.6.0
+ rogchap.com/v8go v0.7.1-0.20211222173054-943fcf9e74cc
)
require (
diff --git a/go.sum b/go.sum
index 20c3b856d..66ebd6976 100644
--- a/go.sum
+++ b/go.sum
@@ -1417,8 +1417,8 @@ mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jC
mvdan.cc/unparam v0.0.0-20210104141923-aac4ce9116a7/go.mod h1:hBpJkZE8H/sb+VRFvw2+rBpHNsTBcvSpk61hr8mzXZE=
mvdan.cc/unparam v0.0.0-20211002134041-24922b6997ca h1:xzXXnoG5a3NUnKAcVMpE2cs3+RwR5/R+jtvLPFoNw7I=
mvdan.cc/unparam v0.0.0-20211002134041-24922b6997ca/go.mod h1:Mb96j26qXgU/+SOj6MSgC36X30UgAlRYaxckYuYyEmo=
-rogchap.com/v8go v0.6.0 h1:wNn5Iu06+ke7HM511zXTVBBpRNYaauyZoPMTrLsGurU=
-rogchap.com/v8go v0.6.0/go.mod h1:IitZnaOtWSJadY/7qinKHIEHpxsilMWyLQ+Efdo4n4I=
+rogchap.com/v8go v0.7.1-0.20211222173054-943fcf9e74cc h1:rcoe6etpGGPcdMibCdCI38v0Th/oyxqTFAjnMQiDGnY=
+rogchap.com/v8go v0.7.1-0.20211222173054-943fcf9e74cc/go.mod h1:MxgP3pL2MW4dpme/72QRs8sgNMmM0pRc8DPhcuLWPAs=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=