From 55ee4f3f350c81ff54585d7a3c0acbed81ac7864 Mon Sep 17 00:00:00 2001 From: Shiloh Heurich Date: Wed, 28 Feb 2024 12:35:35 -0500 Subject: [PATCH] fix --- Dockerfile.release | 21 +++++++++------------ build.sh | 31 ------------------------------- 2 files changed, 9 insertions(+), 43 deletions(-) delete mode 100755 build.sh diff --git a/Dockerfile.release b/Dockerfile.release index ee2b406e..8a92e732 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -1,28 +1,25 @@ # syntax=docker/dockerfile:1 +# The build argument `APP` is used to select the appropriate binary +# for the target OS. +# The binary specified by `APP` must exist in the `dist-files` stage. ARG APP=${APP:-pebble} # Set the base image dynamically based on the target OS -FROM --platform=${TARGETPLATFORM} \ - alpine AS linux-base -FROM --platform=${TARGETPLATFORM} \ - mcr.microsoft.com/windows/nanoserver:ltsc2022 AS windows-base +FROM --platform=${TARGETPLATFORM} alpine AS linux-base +FROM --platform=${TARGETPLATFORM} mcr.microsoft.com/windows/nanoserver:ltsc2022 AS windows-base # Use build arguments to select the appropriate binary for Linux FROM linux-base AS linux ARG APP -ARG TARGETOS -ARG TARGETARCH -COPY --from=dist-files /${APP} / -CMD [ "${APP}" ] +COPY --from=dist-files /${APP} /app +CMD /app # Use build arguments to select the appropriate binary for Windows FROM windows-base AS windows ARG APP -ARG TARGETOS -ARG TARGETARCH -COPY --from=dist-files /${APP}.exe / -CMD [ "${APP}.exe" ] +COPY --from=dist-files /${APP}.exe /app.exe +CMD /app.exe # Final stage: dynamically select between Linux and Windows stages based on TARGETOS argument FROM ${TARGETOS} AS final diff --git a/build.sh b/build.sh deleted file mode 100755 index 5195d199..00000000 --- a/build.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -x -# This script builds a release version of the repository using GOOS/GOARCH -# environment variables if specified or defaults to the current platform. - -# Fail on error, undefined, and uninitialized variables -set -eu - -# Build the $APP command or all commands -app=${APP:-'...'} - -# Set GOOS and GOARCH, default to current platform -arch=${GOARCH:-$(go env GOARCH)} -os=${GOOS:-$(go env GOOS)} - -# Set our output directory -output=dist/${os}/${arch} - -# Create the output directory -mkdir -p "${output}" - -# Settings for reproducible builds -export CGO_ENABLED=0 -ldflags="-s -w" - -go build \ - -ldflags="${ldflags}" \ - -mod=vendor \ - -o "${output}/" \ - -trimpath \ - -v \ - ./cmd/"${app}"