Docker Community Forums

Share and learn in the Docker community.

My dockerfile needs to download a project from github. What's the best approach?

I want my dockerfile to, after installing Alpine Linux,
locate a package in github, depending on the architecture of the machine
download and install it.

It the second part I have trouble with.

Below is my attempt:

Dockerfile

FROM alpine:3.14
LABEL version="1.0"
LABEL maintainer="Folât Pjêrsômêj"
LABEL release-date="2021-07-20"

RUN apk add curl 
RUN apk add jq

ARG ARCH=$(uname -m)
ARG PACKAGE_NAME

# Find Package name
RUN if [ "$ARCH" = "aarch64" ] ; then \
    PACKAGE_NAME= echo "aarch64-unknown-linux-musl"; \ 
  else if [ "$ARCH" = "armv7l" ]
    PACKAGE_NAME= echo "armv7-unknown-linux-musleabihf"; \
  else 
    echo "I'm sorry, but your architecture is not available for this application."
    exit
  fi

# Install the app
RUN curl -L $(curl --silent https://api.github.com/repos/maidsafe/safe_network/releases/latest \ 
| jq -r '.assets[] | select(.name | endswith($PACKAGE.tar.gz")).browser_download_url')

CMD ["sh"]

Is this the right approach and should I figure out how to correctly assign ARCH and PACKAGE_NAME,
or is this something that should not even be in the dockerfile and be completely somewhere else?