Skip to content

Use TARGETARCH to get supercronic binary per target platform - #1092

Merged
guidopetri merged 1 commit into
stringer-rss:mainfrom
guidopetri:add-build-args
Aug 26, 2023
Merged

guidopetri merged 1 commit into
stringer-rss:mainfrom
guidopetri:add-build-args

Conversation

@guidopetri

Copy link
Copy Markdown
Collaborator

I was looking into how to pass the target arch into a build arg in the Dockerfile, when I found out that it's already available in TARGETARCH. So instead of using ARCH I renamed everything to TARGETARCH and got a successful amd64 build and arm64 build, with the correct versions of the supercronic binary attached. Here's the GH Actions logs; if you search for supercronic you can see L738/739 shows the amd64 build + output, and L1197/1198 shows the arm64 build + output.

Comment thread Dockerfile
ARG ARCH=amd64
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.3/supercronic-linux-$ARCH \
SUPERCRONIC=supercronic-linux-$ARCH \
ARG TARGETARCH

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How does TARGETARCH get populated? Is id thanks to the platform line in our Github action?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Sort of - TARGETARCH is one of several pre-defined build arguments (full list here). The platform line is telling Docker which architecture to build for, so in a sense it informs what the value of TARGETARCH is but not its existence.

@guidopetri
guidopetri merged commit 21206e7 into stringer-rss:main Aug 26, 2023
@guidopetri
guidopetri deleted the add-build-args branch August 26, 2023 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants