From 2e7af2e38cf4e0cc36ca1d46a03dc768beebb08b Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Tue, 30 Jan 2024 12:35:06 +0200 Subject: [PATCH] Test fmar (#242) * go 1.21.x * don't use alpine * don't copy * go-version: 1.21.x * don't run tests * wget libbreez_sdk_bindings and copy it into final * wails worflow * wails worflow * wails worflow * wails worflow * wails worflow * wails worflow * prepare:http * remove alby-deployment stuff * uncomment tests * uncomment tests * remove workflow, multiplatform only amd64 for now * try building for arm64 * GOARCH=$(echo "$TARGETPLATFORM" | cut -d'/' -f2) * update to github.com/breez/breez-sdk-go v0.2.14 * update to github.com/breez/breez-sdk-go v0.2.14 * add linux/386 * wails doctor * wails doctor --------- Co-authored-by: Fmar --- .../{multiplatform.yaml => build-docker.yaml} | 2 +- .github/workflows/wails.yaml | 58 +++++++++++++++++ .github/workflows/workflow.yaml | 64 ------------------- Dockerfile | 34 ++++++---- go.mod | 2 +- go.sum | 2 + 6 files changed, 84 insertions(+), 78 deletions(-) rename .github/workflows/{multiplatform.yaml => build-docker.yaml} (96%) create mode 100644 .github/workflows/wails.yaml delete mode 100644 .github/workflows/workflow.yaml diff --git a/.github/workflows/multiplatform.yaml b/.github/workflows/build-docker.yaml similarity index 96% rename from .github/workflows/multiplatform.yaml rename to .github/workflows/build-docker.yaml index 36727bad..d00708c2 100644 --- a/.github/workflows/multiplatform.yaml +++ b/.github/workflows/build-docker.yaml @@ -15,7 +15,7 @@ jobs: - name: Install Go uses: actions/setup-go@v1 with: - go-version: 1.20.x + go-version: 1.21.x - name: Checkout code uses: actions/checkout@v2 - name: Run tests diff --git a/.github/workflows/wails.yaml b/.github/workflows/wails.yaml new file mode 100644 index 00000000..bf05da4e --- /dev/null +++ b/.github/workflows/wails.yaml @@ -0,0 +1,58 @@ +name: Wails build +on: + push: + release: + types: [published] +jobs: + build: + strategy: + fail-fast: false + matrix: + build: [ + { name: nostr-wallet-connect, platform: linux/amd64, os: ubuntu-latest }, + ] + env: + REGISTRY: ghcr.io + IMAGENAME: ${{ github.event.repository.name }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + name: Check out code + - name: Setup GoLang + uses: actions/setup-go@v4 + with: + check-latest: true + go-version: 1.21 + # Setup and configure NodeJS + - name: Setup NodeJS + uses: actions/setup-node@v3 + with: + node-version: 18.x + - name: Install Wails + run: go install github.com/wailsapp/wails/v2/cmd/wails@latest + shell: bash + - name: Install Linux Wails deps + run: sudo apt-get update && sudo apt-get install libgtk-3-0 libwebkit2gtk-4.0-dev gcc-aarch64-linux-gnu libgtk-3-dev nsis + shell: bash + - name: Wails Doctor + working-directory: . + run: wails doctor + shell: bash + # Building step + - name: Build App + working-directory: . + run: wails build --platform ${{ matrix.build.platform }} -tags "wails" + #-o ${{ matrix.build.name }} + shell: bash + - uses: actions/upload-artifact@v3 + with: + name: Wails Build ${{runner.os}} nostr-wallet-connect + path: | + */bin/ + *\bin\* +# - uses: dAppServer/wails-build-action@v2.2 +# with: +# build-name: ${{ matrix.build.name }} +# build-platform: ${{ matrix.build.platform }} +# package: false +# go-version: '1.21' \ No newline at end of file diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml deleted file mode 100644 index 4f0e3176..00000000 --- a/.github/workflows/workflow.yaml +++ /dev/null @@ -1,64 +0,0 @@ -name: Linux Docker build & Alby CD -on: - push: - release: - types: [published] -jobs: - build: - env: - REGISTRY: ghcr.io - IMAGENAME: ${{ github.event.repository.name }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - name: Check out code - - name: Install Go - uses: actions/setup-go@v1 - with: - go-version: 1.20.x - - name: Checkout code - uses: actions/checkout@v2 - - name: Run tests - run: mkdir frontend/dist && touch frontend/dist/tmp && go test - - name: Docker build - uses: mr-smithers-excellent/docker-build-push@v6 - id: build - with: - image: ${{ env.IMAGENAME }} - registry: ${{ env.REGISTRY }} - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout deployment repo - uses: actions/checkout@v2 - with: - repository: getalby/alby-deployment - path: infrastructure - token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - # Always update dev environment - - name: Update dev environment - if: ${{ github.ref == 'refs/heads/main' }} - uses: fjogeleit/yaml-update-action@v0.7.0 - with: - valueFile: "alby-simnet-deployment/values/nwc.yaml" - propertyPath: "nwc.image.tag" - value: ${{ steps.build.outputs.tags }} - repository: getalby/alby-deployment - branch: main - createPR: false - message: "CD: Update nwc tag to ${{ steps.build.outputs.tags }}" - token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - workDir: infrastructure - # Only update prod environment if this action was triggered by a new tag - - name: Update production environment - if: startsWith(github.ref, 'refs/tags') - uses: fjogeleit/yaml-update-action@v0.7.0 - with: - valueFile: "alby-mainnet-deployment/values.yaml" - propertyPath: "nwc.image.tag" - value: ${{ steps.build.outputs.tags }} - repository: getalby/alby-deployment - branch: main - createPR: false - message: "CD: Update nwc tag to ${{ steps.build.outputs.tags }}" - token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - workDir: infrastructure diff --git a/Dockerfile b/Dockerfile index cd1e0674..f808444b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,23 @@ -FROM node:18-alpine as frontend +FROM node:19-alpine as frontend WORKDIR /build COPY frontend ./frontend -RUN cd frontend && yarn install && yarn build +RUN cd frontend && yarn install && yarn build:http -FROM golang:latest as builder +FROM golang:1.21 as builder + +ARG TARGETPLATFORM +ARG BUILDPLATFORM + +RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM" RUN apt-get update && \ - apt-get install -y gcc + apt-get install -y gcc ENV CGO_ENABLED=1 ENV GOOS=linux -ENV GOARCH=amd64 +#ENV GOARCH=$GOARCH + +#RUN echo "AAA $GOARCH" # Move to working directory /build WORKDIR /build @@ -18,7 +25,7 @@ WORKDIR /build # Copy and download dependency using go mod COPY go.mod . COPY go.sum . -RUN go mod download +RUN GOARCH=$(echo "$TARGETPLATFORM" | cut -d'/' -f2) go mod download # Copy the code into the container COPY . . @@ -26,16 +33,19 @@ COPY . . # Copy frontend dist files into the container COPY --from=frontend /build/frontend/dist ./frontend/dist -RUN go build -o main . +RUN GOARCH=$(echo "$TARGETPLATFORM" | cut -d'/' -f2) go build -o main . + +RUN wget https://github.com/breez/breez-sdk-go/raw/main/breez_sdk/lib/linux-amd64/libbreez_sdk_bindings.so # Start a new, final image to reduce size. -FROM alpine as final +FROM debian as final -# FROM gcr.io/distroless/static-debian11 -# USER small-user:small-user - -# Copy the binaries and entrypoint from the builder image. +ENV LD_LIBRARY_PATH=/usr/lib/libbreez +# +# # Copy the binaries and entrypoint from the builder image. +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=builder /build/libbreez_sdk_bindings.so /usr/lib/libbreez/ COPY --from=builder /build/main /bin/ ENTRYPOINT [ "/bin/main" ] diff --git a/go.mod b/go.mod index af83c2f8..4bd43956 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 toolchain go1.21.1 require ( - github.com/breez/breez-sdk-go v0.2.10 + github.com/breez/breez-sdk-go v0.2.14 github.com/davrux/echo-logrus/v4 v4.0.3 github.com/go-gormigrate/gormigrate/v2 v2.1.1 github.com/gorilla/sessions v1.2.1 diff --git a/go.sum b/go.sum index d7501825..e7b6565d 100644 --- a/go.sum +++ b/go.sum @@ -73,6 +73,8 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/breez/breez-sdk-go v0.2.10 h1:D9mEtVTNWhwoV7L6esxpyjoFyFkFoJ2w2l7iZdfE7NA= github.com/breez/breez-sdk-go v0.2.10/go.mod h1:EalYMEeQVwRzr6UXnF4QpLlpuWNwQQN9xwtDKNIutBo= +github.com/breez/breez-sdk-go v0.2.14 h1:d9AAbSWXQpE/nMZyVBvmg808zSe5jRl9PkyRLiMD298= +github.com/breez/breez-sdk-go v0.2.14/go.mod h1:EalYMEeQVwRzr6UXnF4QpLlpuWNwQQN9xwtDKNIutBo= github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M=