diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 71f8a387e..679f85326 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -28,8 +28,9 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build regtest image - run: ./docker/build.py buildx regtest + - name: Push backend image + # Cross compiling to AMD64 is broken right now + run: ./docker/build.py buildx --platform linux/amd64 boltz - - name: Build backend image - run: ./docker/build.py buildx boltz + - name: Push regtest image + run: ./docker/build.py buildx regtest diff --git a/docker/boltz/Dockerfile b/docker/boltz/Dockerfile index 0f14cb601..6b9b5c3dc 100644 --- a/docker/boltz/Dockerfile +++ b/docker/boltz/Dockerfile @@ -19,9 +19,11 @@ RUN git clone https://github.com/BoltzExchange/boltz-backend.git WORKDIR /boltz-backend RUN git checkout ${VERSION} -RUN npm install -g npm -RUN npm ci +# Remove dependency that is not needed for the build and unavailable on ARM64 +RUN sed -i "/grpc-tools/d" package.json + +RUN npm install RUN npm run compile FROM node:${NODE_VERSION} AS final diff --git a/docker/build.py b/docker/build.py index 549c32adc..710047973 100755 --- a/docker/build.py +++ b/docker/build.py @@ -176,6 +176,7 @@ def build_images( to_build: list[str], organisation: str, no_cache: bool, + no_latest: bool, buildx: bool, platform: str = "", ) -> None: @@ -196,21 +197,20 @@ def build_images( # join the array to a string args = " ".join(["--build-arg " + entry for entry in build_args]) + name = f"{organisation}/{image}" + dockerfile = f"{image}/Dockerfile" + if buildx: + extra_tag = "" if no_latest else f"--tag {name}:latest" command = ( - "docker buildx build --push {args} --platform " - + platform - + " --file {dockerfile} --tag {name}:{tag} ." + f"docker buildx build --push {args} --platform {platform} " + f"--file {dockerfile} --tag {name}:{tag} {extra_tag} ." ) else: - command = "docker build -t {name}:{tag} -f {dockerfile} {args} ." - - command = command.format( - tag=tag, - args=args, - name=f"{organisation}/{image}", - dockerfile=f"{image}/Dockerfile", - ) + extra_tag = "" if no_latest else f"-t {name}:latest" + command = ( + f"docker build -t {name}:{tag} {extra_tag} -f {dockerfile} {args} ." + ) if no_cache: command = command + " --no-cache" @@ -253,6 +253,7 @@ def parse_images(to_parse: list[str]) -> list[str]: BUILD_PARSER.add_argument("images", type=str, nargs="*") BUILD_PARSER.add_argument("--no-cache", dest="no_cache", action="store_true") + BUILD_PARSER.add_argument("--no-latest", dest="no_latest", action="store_true") BUILD_PARSER.add_argument( "--organisation", default="boltz", @@ -261,9 +262,9 @@ def parse_images(to_parse: list[str]) -> list[str]: BUILDX_PARSER.add_argument("images", type=str, nargs="*") BUILDX_PARSER.add_argument("--no-cache", dest="no_cache", action="store_true") + BUILDX_PARSER.add_argument("--no-latest", dest="no_latest", action="store_true") BUILDX_PARSER.add_argument( "--platform", - action="store_true", default="linux/amd64,linux/arm64", help="The platforms to build for", ) @@ -280,12 +281,15 @@ def parse_images(to_parse: list[str]) -> list[str]: if ARGS.command == "list": list_images(PARSED_IMAGES) elif ARGS.command == "build": - build_images(PARSED_IMAGES, ARGS.organisation, ARGS.no_cache, False) + build_images( + PARSED_IMAGES, ARGS.organisation, ARGS.no_cache, ARGS.no_latest, False + ) elif ARGS.command == "buildx": build_images( PARSED_IMAGES, ARGS.organisation, ARGS.no_cache, + ARGS.no_latest, True, ARGS.platform, )