Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
54 changes: 15 additions & 39 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
name: "Build GARM images"
name: "Build and push GARM images"
on:
workflow_dispatch:
workflow_call:
inputs:
push_to_project:
description: "Project to build images for"
required: true
type: string
default: "ghcr.io/cloudbase"
ref:
description: "Ref to build"
required: true
type: string
default: "main"
schedule:
- cron: "0 2 * * *"
Expand All @@ -24,8 +26,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
path: src/github.com/cloudbase/garm
fetch-depth: 0

Expand All @@ -39,35 +42,16 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
- name: Build and push image
env:
IMAGE_REGISTRY: ${{ inputs.push_to_project }}
GH_REF: ${{ inputs.ref }}
working-directory: src/github.com/cloudbase/garm
run: |
set -x
REGISTRY_INPUT="${{ github.event.inputs.push_to_project }}"
REF_INPUT="${{ github.event.inputs.ref }}"

PUSH_TO_PROJECT="${REGISTRY_INPUT:-ghcr.io/cloudbase}"
GH_REF="${REF_INPUT:-main}"
cd src/github.com/cloudbase/garm && git checkout "${GH_REF}"

VERSION=$(git describe --tags --match='v[0-9]*' --always)
AZURE_REF=v0.1.0
OPENSTACK_REF=v0.1.0
LXD_REF=v0.1.0
INCUS_REF=v0.1.0
AWS_REF=v0.1.0
GCP_REF=v0.1.0
EQUINIX_REF=v0.1.0
K8S_REF=v0.3.2
if [ "$GH_REF" == "main" ]; then
AZURE_REF="main"
OPENSTACK_REF="main"
LXD_REF="main"
INCUS_REF="main"
AWS_REF="main"
GCP_REF="main"
EQUINIX_REF="main"
K8S_REF="main"
VERSION="nightly"
IMAGE_TAG="nightly"
else
IMAGE_TAG=$(git describe --tags --match='v[0-9]*' --always)
fi
docker buildx build \
--provenance=false \
Expand All @@ -76,13 +60,5 @@ jobs:
--label "org.opencontainers.image.description=GARM ${GH_REF}" \
--label "org.opencontainers.image.licenses=Apache 2.0" \
--build-arg="GARM_REF=${GH_REF}" \
--build-arg="AZURE_REF=${AZURE_REF}" \
--build-arg="OPENSTACK_REF=${OPENSTACK_REF}" \
--build-arg="LXD_REF=${LXD_REF}" \
--build-arg="INCUS_REF=${INCUS_REF}" \
--build-arg="AWS_REF=${AWS_REF}" \
--build-arg="GCP_REF=${GCP_REF}" \
--build-arg="EQUINIX_REF=${EQUINIX_REF}" \
--build-arg="K8S_REF=${K8S_REF}" \
-t ${PUSH_TO_PROJECT}/garm:"${VERSION}" \
-t ${IMAGE_REGISTRY}/garm:"${IMAGE_TAG}" \
--push .
19 changes: 19 additions & 0 deletions .github/workflows/trigger-manual.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Manual build of GARM images
on:
workflow_dispatch:
inputs:
push_to_project:
description: "Project to build images for"
required: true
default: "ghcr.io/cloudbase"
ref:
description: "Ref to build"
required: true
default: "main"

jobs:
call-build-and-push:
uses: ./.github/workflows/build-and-push.yml
with:
push_to_project: ${{ inputs.push_to_project }}
ref: ${{ inputs.ref }}
10 changes: 10 additions & 0 deletions .github/workflows/trigger-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Nightly build of GARM images
on:
schedule:
- cron: "0 2 * * *"

jobs:
call-build-and-push:
uses: ./.github/workflows/build-and-push.yml
with:
ref: "main"
91 changes: 52 additions & 39 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,49 +1,62 @@
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 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 git -C /build/garm checkout ${GARM_REF}
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 set -e; \
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_REF="main"; \
else \
export PROVIDER_REF="$(curl -s -L https://api.github.com/repos/$repo/releases/latest | jq -r '.tag_name')"; \
fi; \
git clone --branch "$PROVIDER_REF" "https://github.com/$repo" "/build/$PROVIDER_NAME"; \
case $PROVIDER_NAME in \
"garm-provider-k8s") \
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_VERSION=$(git -C /build/$PROVIDER_NAME describe --tags --match='v[0-9]*' --dirty --always); \
export PROVIDER_LDFLAGS="-linkmode external -extldflags \"-static\" -s -w -X main.Version=$PROVIDER_VERSION"; \
;; \
esac; \
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

Expand Down
Loading