transfer providers branch computation inside Dockerfile
This commit is contained in:
parent
be3026e87c
commit
af1c090db5
2 changed files with 49 additions and 70 deletions
87
Dockerfile
87
Dockerfile
|
|
@ -1,49 +1,60 @@
|
|||
FROM docker.io/golang:alpine AS builder
|
||||
ARG GARM_REF
|
||||
ARG AZURE_REF=v0.1.0
|
||||
ARG OPENSTACK_REF=v0.1.0
|
||||
ARG LXD_REF=v0.1.0
|
||||
ARG INCUS_REF=v0.1.0
|
||||
ARG AWS_REF=v0.1.0
|
||||
ARG GCP_REF=v0.1.0
|
||||
ARG EQUINIX_REF=v0.1.0
|
||||
ARG K8S_REF=v0.3.2
|
||||
|
||||
LABEL stage=builder
|
||||
|
||||
RUN apk add --no-cache musl-dev gcc libtool m4 autoconf g++ make libblkid util-linux-dev git linux-headers upx
|
||||
RUN git config --global --add safe.directory /build
|
||||
RUN apk add --no-cache musl-dev gcc libtool m4 autoconf g++ make libblkid util-linux-dev git linux-headers upx curl jq
|
||||
RUN git config --global --add safe.directory /build && git config --global --add advice.detachedHead false
|
||||
|
||||
ADD . /build/garm
|
||||
RUN cd /build/garm && git checkout ${GARM_REF}
|
||||
RUN git clone --depth 1 --branch ${AZURE_REF} https://github.com/cloudbase/garm-provider-azure /build/garm-provider-azure
|
||||
RUN git clone --depth 1 --branch ${OPENSTACK_REF} https://github.com/cloudbase/garm-provider-openstack /build/garm-provider-openstack
|
||||
RUN git clone --depth 1 --branch ${LXD_REF} https://github.com/cloudbase/garm-provider-lxd /build/garm-provider-lxd
|
||||
RUN git clone --depth 1 --branch ${INCUS_REF} https://github.com/cloudbase/garm-provider-incus /build/garm-provider-incus
|
||||
RUN git clone --depth 1 --branch ${AWS_REF} https://github.com/cloudbase/garm-provider-aws /build/garm-provider-aws
|
||||
RUN git clone --depth 1 --branch ${GCP_REF} https://github.com/cloudbase/garm-provider-gcp /build/garm-provider-gcp
|
||||
RUN git clone --depth 1 --branch ${EQUINIX_REF} https://github.com/cloudbase/garm-provider-equinix /build/garm-provider-equinix
|
||||
|
||||
RUN git clone --depth 1 --branch ${K8S_REF} https://github.com/mercedes-benz/garm-provider-k8s /build/garm-provider-k8s
|
||||
|
||||
RUN cd /build/garm && go build -o /bin/garm \
|
||||
-tags osusergo,netgo,sqlite_omit_load_extension \
|
||||
-ldflags "-linkmode external -extldflags '-static' -s -w -X github.com/cloudbase/garm/util/appdefaults.Version=$(git describe --tags --match='v[0-9]*' --dirty --always)" \
|
||||
/build/garm/cmd/garm && upx /bin/garm
|
||||
RUN cd /build/garm/cmd/garm-cli && go build -o /bin/garm-cli \
|
||||
-tags osusergo,netgo,sqlite_omit_load_extension \
|
||||
-ldflags "-linkmode external -extldflags '-static' -s -w -X github.com/cloudbase/garm/util/appdefaults.Version=$(git describe --tags --match='v[0-9]*' --dirty --always)" \
|
||||
. && upx /bin/garm-cli
|
||||
RUN mkdir -p /opt/garm/providers.d
|
||||
RUN cd /build/garm-provider-azure && go build -ldflags="-linkmode external -extldflags '-static' -s -w -X main.Version=$(git describe --tags --match='v[0-9]*' --dirty --always)" -o /opt/garm/providers.d/garm-provider-azure . && upx /opt/garm/providers.d/garm-provider-azure
|
||||
RUN cd /build/garm-provider-openstack && go build -ldflags="-linkmode external -extldflags '-static' -s -w -X main.Version=$(git describe --tags --match='v[0-9]*' --dirty --always)" -o /opt/garm/providers.d/garm-provider-openstack . && upx /opt/garm/providers.d/garm-provider-openstack
|
||||
RUN cd /build/garm-provider-lxd && go build -ldflags="-linkmode external -extldflags '-static' -s -w -X main.Version=$(git describe --tags --match='v[0-9]*' --dirty --always)" -o /opt/garm/providers.d/garm-provider-lxd . && upx /opt/garm/providers.d/garm-provider-lxd
|
||||
RUN cd /build/garm-provider-incus && go build -ldflags="-linkmode external -extldflags '-static' -s -w -X main.Version=$(git describe --tags --match='v[0-9]*' --dirty --always)" -o /opt/garm/providers.d/garm-provider-incus . && upx /opt/garm/providers.d/garm-provider-incus
|
||||
RUN cd /build/garm-provider-aws && go build -ldflags="-linkmode external -extldflags '-static' -s -w -X main.Version=$(git describe --tags --match='v[0-9]*' --dirty --always)" -o /opt/garm/providers.d/garm-provider-aws . && upx /opt/garm/providers.d/garm-provider-aws
|
||||
RUN cd /build/garm-provider-gcp && go build -ldflags="-linkmode external -extldflags '-static' -s -w -X main.Version=$(git describe --tags --match='v[0-9]*' --dirty --always)" -o /opt/garm/providers.d/garm-provider-gcp . && upx /opt/garm/providers.d/garm-provider-gcp
|
||||
RUN cd /build/garm-provider-equinix && go build -ldflags="-linkmode external -extldflags '-static' -s -w -X main.Version=$(git describe --tags --match='v[0-9]*' --dirty --always)" -o /opt/garm/providers.d/garm-provider-equinix . && upx /opt/garm/providers.d/garm-provider-equinix
|
||||
|
||||
RUN cd /build/garm-provider-k8s/cmd/garm-provider-k8s && go build -ldflags="-linkmode external -extldflags '-static' -s -w" -o /opt/garm/providers.d/garm-provider-k8s . && upx /opt/garm/providers.d/garm-provider-k8s
|
||||
RUN cd /build/garm && git checkout ${GARM_REF} \
|
||||
&& go build -o /bin/garm \
|
||||
-tags osusergo,netgo,sqlite_omit_load_extension \
|
||||
-ldflags "-linkmode external -extldflags '-static' -s -w -X github.com/cloudbase/garm/util/appdefaults.Version=$(git describe --tags --match='v[0-9]*' --dirty --always)" \
|
||||
/build/garm/cmd/garm && upx /bin/garm
|
||||
RUN cd /build/garm/cmd/garm-cli \
|
||||
&& go build -o /bin/garm-cli \
|
||||
-tags osusergo,netgo,sqlite_omit_load_extension \
|
||||
-ldflags "-linkmode external -extldflags '-static' -s -w -X github.com/cloudbase/garm/util/appdefaults.Version=$(git describe --tags --match='v[0-9]*' --dirty --always)" \
|
||||
. && upx /bin/garm-cli
|
||||
RUN mkdir -p /opt/garm/providers.d; \
|
||||
for repo in \
|
||||
cloudbase/garm-provider-azure \
|
||||
cloudbase/garm-provider-openstack \
|
||||
cloudbase/garm-provider-lxd \
|
||||
cloudbase/garm-provider-incus \
|
||||
cloudbase/garm-provider-aws \
|
||||
cloudbase/garm-provider-gcp \
|
||||
cloudbase/garm-provider-equinix \
|
||||
flatcar/garm-provider-linode \
|
||||
mercedes-benz/garm-provider-k8s; \
|
||||
do \
|
||||
export PROVIDER_NAME="$(basename $repo)"; \
|
||||
export PROVIDER_SUBDIR=""; \
|
||||
if [ "$GARM_REF" == "main" ]; then \
|
||||
export PROVIDER_TAG="main"; \
|
||||
else \
|
||||
export PROVIDER_TAG="$(curl -s -L https://api.github.com/repos/$repo/releases/latest | jq -r '.tag_name')"; \
|
||||
fi; \
|
||||
case $PROVIDER_NAME in \
|
||||
"garm-provider-k8s") \
|
||||
export PROVIDER_TAG=v0.3.1; \
|
||||
export PROVIDER_SUBDIR="cmd/garm-provider-k8s"; \
|
||||
export PROVIDER_LDFLAGS="-linkmode external -extldflags \"-static\" -s -w"; \
|
||||
;; \
|
||||
"garm-provider-linode") \
|
||||
export PROVIDER_LDFLAGS="-linkmode external -extldflags \"-static\" -s -w"; \
|
||||
;; \
|
||||
*) \
|
||||
export PROVIDER_LDFLAGS="-linkmode external -extldflags \"-static\" -s -w -X main.Version=$PROVIDER_TAG"; \
|
||||
;; \
|
||||
esac; \
|
||||
git clone --depth 1 --branch "$PROVIDER_TAG" "https://github.com/$repo" "/build/$PROVIDER_NAME" \
|
||||
&& cd "/build/$PROVIDER_NAME/$PROVIDER_SUBDIR" \
|
||||
&& go build -ldflags="$PROVIDER_LDFLAGS" -o /opt/garm/providers.d/$PROVIDER_NAME . \
|
||||
&& upx /opt/garm/providers.d/$PROVIDER_NAME; \
|
||||
done
|
||||
|
||||
FROM busybox
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue