Cross-platform build for server (#682)

This commit is contained in:
Sung 2025-10-05 17:56:13 -07:00 committed by GitHub
commit b141b677bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 23 deletions

View file

@ -78,14 +78,3 @@ jobs:
--title="$TAG" \
--notes="Please see the [CHANGELOG](https://github.com/dnote/dnote/blob/master/CHANGELOG.md)" \
--draft
- name: Push to Docker Hub
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
echo "$DOCKER_TOKEN" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker push dnote/dnote:${VERSION}
docker push dnote/dnote:latest

View file

@ -1,13 +1,8 @@
FROM alpine:latest
FROM busybox:glibc
ARG tarballName
RUN test -n "$tarballName"
# add dependency to execute a golang binary with dynamical linking.
RUN apk add --no-cache \
libc6-compat \
gcompat
WORKDIR dnote
COPY "$tarballName" .

View file

@ -29,23 +29,30 @@ build() {
platform=$1
arch=$2
pushd "$basedir"
destDir="$outputDir/$platform-$arch"
mkdir -p "$destDir"
# build binary
moduleName="github.com/dnote/dnote"
ldflags="-X '$moduleName/pkg/server/buildinfo.CSSFiles=main.css' -X '$moduleName/pkg/server/buildinfo.JSFiles=main.js' -X '$moduleName/pkg/server/buildinfo.Version=$version' -X '$moduleName/pkg/server/buildinfo.Standalone=true'"
tags="fts5"
GOOS="$platform" \
GOARCH="$arch" go build \
-o "$destDir/dnote-server" \
pushd "$projectDir"
xgo \
-go go-1.25.x \
-targets="$platform/$arch" \
-ldflags "$ldflags" \
"$basedir"/*.go
-dest="$destDir" \
-out="server" \
-tags "$tags" \
-pkg pkg/server \
.
popd
mv "$destDir/server-${platform}-"* "$destDir/dnote-server"
# build tarball
tarballName="dnote_server_${version}_${platform}_${arch}.tar.gz"
tarballPath="$outputDir/$tarballName"
@ -62,5 +69,8 @@ build() {
}
# install the tool
go install src.techknowlogick.com/xgo@latest
build linux amd64
build linux arm64