Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix multiplatform builds #2725

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# stage 1 Generate celestia-appd Binary
FROM --platform=$BUILDPLATFORM docker.io/golang:1.21.3-alpine3.18 as builder

ARG TARGETOS
ARG TARGETARCH
Comment on lines +4 to +5
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[optional] it looks like ARGs can contain underscores, in which case this seems a bit easier to read but def not blocking

Ref:

https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact

Suggested change
ARG TARGETOS
ARG TARGETARCH
ARG TARGET_OS
ARG TARGET_ARCH


ENV CGO_ENABLED=0
ENV GO111MODULE=on
# hadolint ignore=DL3018
RUN apk update && apk add --no-cache \
gcc \
Expand All @@ -10,10 +16,12 @@ RUN apk update && apk add --no-cache \
musl-dev
COPY . /celestia-app
WORKDIR /celestia-app
RUN make build
RUN uname -a &&\
CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
make build

# stage 2
FROM --platform=$BUILDPLATFORM docker.io/alpine:3.18.4
FROM docker.io/alpine:3.18.4

# Read here why UID 10001: https://github.com/hexops/dockerfile/blob/main/README.md#do-not-use-a-uid-below-10000
ARG UID=10001
Expand Down
12 changes: 10 additions & 2 deletions docker/Dockerfile_txsim
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Stage 1: generate celestia-appd binary
FROM --platform=$BUILDPLATFORM docker.io/golang:1.21.3-alpine3.18 as builder

ARG TARGETOS
ARG TARGETARCH

ENV CGO_ENABLED=0
ENV GO111MODULE=on
# hadolint ignore=DL3018
RUN apk update && apk add --no-cache \
gcc \
Expand All @@ -12,10 +18,12 @@ COPY . /celestia-app
WORKDIR /celestia-app
# we need the celestia-appd build as we might want to create an account
# internally for txsimulation
RUN make build && make txsim-build
RUN uname -a &&\
CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
make build && make txsim-build

# Stage 2: create a minimal image with the binary
FROM --platform=$BUILDPLATFORM docker.io/alpine:3.18.4
FROM docker.io/alpine:3.18.4

# Use UID 10,001 because UIDs below 10,000 are a security risk.
# Ref: https://github.com/hexops/dockerfile/blob/main/README.md#do-not-use-a-uid-below-10000
Expand Down
Loading