Skip to content

Instantly share code, notes, and snippets.

@dotysan
Last active November 14, 2023 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dotysan/99c7815f7dfea784695f1b592faa017e to your computer and use it in GitHub Desktop.
Save dotysan/99c7815f7dfea784695f1b592faa017e to your computer and use it in GitHub Desktop.
Install rclone on a Go-less system using Go in Docker
#! /usr/bin/env bash
#
# Install rclone on a Go-less system using Go in Docker.
#
set -ex
# latest stable release
RC_TAG=v1.64.2
GO_VER=1-bookworm
main() {
src
cd rclone.git
git switch --detach $RC_TAG
img
bld
#tst
ins
cd ..
cln
}
src() {
! test -d rclone.git ||return 0
git clone git@github.com:rclone/rclone.git rclone.git
}
img() {
docker pull golang:$GO_VER
docker build -t build-rclone - <<-EOF
FROM golang:$GO_VER
# give make build proper perms in .:/rclone
RUN useradd --uid $UID --user-group \
--create-home --shell /bin/bash $USER
# build static binary
ENV CGO_ENABLED=0
WORKDIR /rclone
EOF
}
bld() {
docker run --rm \
--volume "$PWD:/rclone" \
--user "$UID:$UID" \
build-rclone \
go build
#make
}
tst() {
docker run --rm \
--volume "$PWD:/rclone" \
--user "$UID:$UID" \
build-rclone \
make test
}
ins() {
mkdir --parents ~/.local/bin
cp --force --preserve rclone ~/.local/bin/
}
cln() {
rm --force --recursive rclone.git
docker image rm build-rclone
}
main
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment