-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from postfinance/trident-image
add custom Trident image with alpine base image
- Loading branch information
Showing
6 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
name: Trident Build | ||
|
||
on: | ||
push: | ||
# paths: | ||
# - "trident-distrowith/**" | ||
pull_request: | ||
# paths: | ||
# - "trident-distrowith/**" | ||
|
||
jobs: | ||
build: | ||
if: | | ||
!github.event.pull_request.head.repo.fork | ||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
working-directory: trident-distrowith | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Checkout trident repo | ||
run: ./checkout.sh | ||
|
||
- name: Patch Dockerfile with alpine and nfs-utils | ||
working-directory: trident-distrowith/trident | ||
run: patch Dockerfile ../dockerfile.patch | ||
|
||
- name: Patch chwrap.go to stop searching binaries in /host | ||
working-directory: trident-distrowith/trident | ||
run: patch chwrap/chwrap.go ../chwrap.patch | ||
|
||
- name: Patch Makefile to change default registry for images | ||
working-directory: trident-distrowith/trident | ||
run: patch Makefile ../makefile.patch | ||
|
||
- name: Run make command | ||
working-directory: trident-distrowith/trident | ||
env: | ||
BUILD_TYPE: stable | ||
run: | | ||
export CUSTOM_IMAGE_TAG=$(echo $GITHUB_REF_NAME | tr "/" "-") && \ | ||
make images | ||
- name: List docker images | ||
run: docker image ls | ||
|
||
- name: Export docker images as artifacts | ||
run: | | ||
mkdir -p /tmp/docker-images/ | ||
docker image ls --format=json | \ | ||
jq -s '[.[] | select(.Repository | test("ghcr.io/postfinance/trident.*"))] | unique_by(.ID) |.[] | .Repository + ":" + .Tag' | \ | ||
xargs -I_ sh -c 'docker save _ -o /tmp/docker-images/$(echo _ | sed "s|[/:\.]|-|g").tar' | ||
- name: Upload docker images artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: custom-trident-images | ||
path: /tmp/docker-images/*.tar | ||
|
||
publish: | ||
if: | | ||
startsWith(github.ref, 'refs/heads/') || | ||
startsWith(github.ref, 'refs/tags/') && | ||
!github.event.pull_request.head.repo.fork | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: custom-trident-images | ||
path: docker-images/ | ||
|
||
- name: Display structure of downloaded files | ||
run: find . | ||
|
||
- name: Load image(s) | ||
run: | | ||
find docker-images/ -name "*.tar" -exec docker load --input {} \; | ||
docker image ls | ||
- name: Log in to ghcr.io registry | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | ||
|
||
- name: Push docker images | ||
run: | | ||
docker image ls --format=json | \ | ||
jq 'select(.Repository | test("ghcr.io/postfinance/trident.*")) | .Repository + ":" + .Tag' | \ | ||
xargs -I_ docker push _ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# | ||
|
||
command used to create the `.patch` file: | ||
|
||
```shell | ||
diff -u Dockerfile{.original,} > ../dockerfile.patch | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
|
||
REPO_URL="https://github.com/NetApp/trident.git" | ||
TRIDENT_VERSION="v24.06.1" | ||
DEST_DIR="trident" | ||
|
||
# Remove destination directory if it exists | ||
if [ -d "$DEST_DIR" ]; then | ||
rm -rf "$DEST_DIR" | ||
fi | ||
|
||
# Clone with depth=1 and specific tag | ||
git clone --depth 1 --branch "$TRIDENT_VERSION" "$REPO_URL" "$DEST_DIR" | ||
|
||
# Verify the clone was successful | ||
if [ $? -eq 0 ]; then | ||
echo "Successfully cloned Trident $TRIDENT_VERSION" | ||
else | ||
echo "Failed to clone repository" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- trident/chwrap/chwrap.go.original 2024-10-25 07:59:25 | ||
+++ trident/chwrap/chwrap.go 2024-10-25 08:01:27 | ||
@@ -53,7 +53,7 @@ | ||
} | ||
|
||
func main() { | ||
- rootPath := "/host" | ||
+ rootPath := "/" // Oct. 24, Clément Nussbaumer: for talos we only consider binaries in the base image, not the host | ||
// First modify argv0 to strip off any absolute or relative paths | ||
argv := os.Args | ||
binary := argv[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- Dockerfile.original 2024-10-24 19:51:25 | ||
+++ Dockerfile 2024-10-24 19:51:05 | ||
@@ -1,24 +1,13 @@ | ||
ARG ARCH=amd64 | ||
|
||
-FROM --platform=linux/${ARCH} alpine:latest as baseimage | ||
+FROM --platform=linux/${ARCH} alpine:3.20 | ||
|
||
RUN apk add nfs-utils | ||
|
||
-#Get the mount.nfs4 dependency | ||
-RUN ldd /sbin/mount.nfs4 | tr -s '[:space:]' '\n' | grep '^/' | xargs -I % sh -c 'mkdir -p /nfs-deps/$(dirname %) && cp -L % /nfs-deps/%' | ||
-RUN ldd /sbin/mount.nfs | tr -s '[:space:]' '\n' | grep '^/' | xargs -I % sh -c 'mkdir -p /nfs-deps/$(dirname %) && cp -r -u -L % /nfs-deps/%' | ||
- | ||
-FROM --platform=linux/${ARCH} gcr.io/distroless/static@sha256:41972110a1c1a5c0b6adb283e8aa092c43c31f7c5d79b8656fbffff2c3e61f05 | ||
- | ||
LABEL maintainers="The NetApp Trident Team" \ | ||
app="trident.netapp.io" \ | ||
description="Trident Storage Orchestrator" | ||
|
||
-COPY --from=baseimage /bin/mount /bin/umount /bin/ | ||
-COPY --from=baseimage /sbin/mount.nfs /sbin/mount.nfs4 /sbin/ | ||
-COPY --from=baseimage /etc/netconfig /etc/ | ||
-COPY --from=baseimage /nfs-deps/ / | ||
- | ||
ARG BIN=trident_orchestrator | ||
ARG CLI_BIN=tridentctl | ||
ARG CHWRAP_BIN=chwrap.tar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- trident/Makefile.original 2024-10-25 09:11:22 | ||
+++ trident/Makefile 2024-10-25 09:21:23 | ||
@@ -93,7 +93,7 @@ | ||
|
||
# Constants | ||
ALL_PLATFORMS = linux/amd64 linux/arm64 windows/amd64/ltsc2022 windows/amd64/ltsc2019 darwin/amd64 | ||
-DEFAULT_REGISTRY = docker.io/netapp | ||
+DEFAULT_REGISTRY = ghcr.io/postfinance | ||
TRIDENT_CONFIG_PKG = github.com/netapp/trident/config | ||
OPERATOR_CONFIG_PKG = github.com/netapp/trident/operator/config | ||
TRIDENT_KUBERNETES_PKG = github.com/netapp/trident/persistent_store/crd | ||
@@ -120,8 +120,9 @@ | ||
TRIDENT_VERSION := $(VERSION)-$(BUILD_TYPE).$(BUILD_TYPE_REV) | ||
endif | ||
|
||
+CUSTOM_IMAGE_TAG ?= | ||
# tag variables | ||
-TRIDENT_TAG := $(REGISTRY)/$(TRIDENT_IMAGE):$(TRIDENT_VERSION) | ||
+TRIDENT_TAG := $(REGISTRY)/$(TRIDENT_IMAGE):$(TRIDENT_VERSION)-$(CUSTOM_IMAGE_TAG) | ||
OPERATOR_TAG := $(REGISTRY)/$(OPERATOR_IMAGE):$(TRIDENT_VERSION) | ||
TRIDENT_IMAGE_REPO := $(REGISTRY)/$(TRIDENT_IMAGE): | ||
DEFAULT_OPERATOR_TAG := $(DEFAULT_REGISTRY)/$(OPERATOR_IMAGE):$(VERSION) |