Skip to content

Commit

Permalink
try another if else method
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarak Ben Youssef committed Jan 10, 2024
1 parent 0a57ef5 commit 6a03566
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions cmd/emulator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@ COPY . .

ARG TARGETOS
ARG TARGETARCH
ARG C_COMPILER=""
RUN if [ "$TARGETARCH" = "arm64" ] ; then C_COMPILER="arm-linux-gnueabi-gcc" ; \
elif [ "$TARGETARCH" = "amd64" ] ; then C_COMPILER="gcc" ; fi
RUN --mount=type=ssh \
RUN if [ "$TARGETARCH" = "arm64" ] ; then \
--mount=type=ssh \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \
GOARCH=$TARGETARCH CC=$C_COMPILER \
go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator
GOARCH=$TARGETARCH CC=arm-linux-gnueabi-gcc \
go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \
elif [ "$TARGETARCH" = "amd64" ] ; then \
--mount=type=ssh \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
GO111MODULE=on CGO_ENABLED=1 GOOS=$TARGETOS \
GOARCH=$TARGETARCH CC=gcc \
go build -ldflags "-extldflags -static" -o ./app ./cmd/emulator ; \
fi

## Add the binary to a fresh distroless image
FROM gcr.io/distroless/static
Expand Down

0 comments on commit 6a03566

Please # to comment.