Skip to content

Commit

Permalink
feat: reduce number of containers
Browse files Browse the repository at this point in the history
feat: reduce number of dockerfiles

this commit reduces number of builded containers to just 2.
One container for disk-virt tasks and second for everything else.
The disk-virt containers requires separate container, because they need
different base image (kubevirt libguestfs which is distroless and we
can't install there anything). Other tasks share the same container,
because they don't need anything special.
This change will help to decrease maintenance effort, because we will
not have to take care about 9 containers, but only about two.
This commit also reduce number of dockerfiles to just two (one for disk-virt tasks,
second for everything else). This will help to reduce time needed to
e.g. bump golang version, or bump base images versions. It will also reduce
complexity of build scripts and it will reduce build time.

New containers will have names:
kubevirt/tekton-tasks
kubevirt/tekton-tasks-disk-virt

kubevirt/tekton-tasks container contains :copy-template, create-vm,
execute-in-vm, generate-ssh-keys, modify-data-object, modify-vm-template
and wait-for-vmi-status tasks.
kubevirt/tekton-tasks-disk-virt container contains: disk-virt-customize
and disk-virt-sysprep

Signed-off-by: Karel Šimon <ksimon@redhat.com>
  • Loading branch information
ksimon1 committed May 2, 2023
1 parent 9cfaf98 commit 1b3d5a4
Show file tree
Hide file tree
Showing 78 changed files with 228 additions and 989 deletions.
35 changes: 35 additions & 0 deletions build/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM quay.io/centos/centos:stream9 AS taskBuilder

RUN dnf install -y tar gzip && dnf clean all

ENV GO_VERSION="1.20.2"
RUN curl -L https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz | tar -C /usr/local -xzf -
ENV PATH=$PATH:/usr/local/go/bin

COPY . /src
RUN mkdir /out

RUN task_names=("copy-template" "create-vm" "execute-in-vm" "generate-ssh-keys" "modify-data-object" "modify-vm-template" "wait-for-vmi-status"); \
for TASK_NAME in ${task_names[@]}; do \
cd /src/modules/$TASK_NAME/; \
CGO_ENABLED=0 GOOS=linux go build -mod=vendor -o /out/${TASK_NAME} cmd/${TASK_NAME}/main.go; \
done

FROM quay.io/centos/centos:stream9
ENV USER_UID=1001 \
USER_NAME=tekton-tasks \
HOME=/home/${USER_NAME}

RUN dnf install -y xorriso openssh-clients && dnf clean all

# install task binaries
COPY --from=taskBuilder /out/. /usr/local/bin/
COPY build/bin /usr/local/bin

USER 0
RUN /usr/local/bin/user_setup

ENTRYPOINT ["/usr/local/bin/entrypoint"]
CMD ["--help"]

USER ${USER_UID}
34 changes: 34 additions & 0 deletions build/Containerfile.DiskVirt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM quay.io/centos/centos:stream9 AS taskBuilder

RUN dnf install -y tar gzip && dnf clean all

ENV GO_VERSION="1.20.2"

RUN curl -L https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz | tar -C /usr/local -xzf -
ENV PATH=$PATH:/usr/local/go/bin

COPY . /src
RUN mkdir /out

RUN task_names=("disk-virt-customize" "disk-virt-sysprep"); \
for TASK_NAME in ${task_names[@]}; do \
cd /src/modules/$TASK_NAME/; \
CGO_ENABLED=0 GOOS=linux go build -mod=vendor -o /out/${TASK_NAME} cmd/${TASK_NAME}/main.go; \
done

FROM quay.io/kubevirt/libguestfs-tools:v0.59.0
ENV USER_UID=1001 \
USER_NAME=tekton-tasks-disk-virt \
HOME=/home/${USER_NAME}

# install task binaries
COPY --from=taskBuilder /out/. /usr/local/bin/
COPY build/bin /usr/local/bin

USER 0
RUN /usr/local/bin/user_setup

ENTRYPOINT ["/usr/local/bin/entrypoint"]
CMD ["--help"]

USER ${USER_UID}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,12 @@ if ! whoami &>/dev/null; then
fi
fi

exec ${ENTRY_CMD} $@
#this variable is needed for tasks which work with ssh keys
export USER="tekton-tasks"

if [[ -z "${COMMAND}" ]]; then
echo "command not defined"
exit 1
fi

exec ${COMMAND} $@
File renamed without changes.
2 changes: 1 addition & 1 deletion configs/cleanup-vm.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
task_name: cleanup-vm
task_category: execute-in-vm
# execute-in-vm.yaml main_image should be also updated to match this one!
main_image: quay.io/kubevirt/tekton-task-execute-in-vm
main_image: quay.io/kubevirt/tekton-tasks
2 changes: 1 addition & 1 deletion configs/copy-template.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
task_name: copy-template
task_category: copy-template
main_image: quay.io/kubevirt/tekton-task-copy-template
main_image: quay.io/kubevirt/tekton-tasks
is_okd: true
2 changes: 1 addition & 1 deletion configs/create-vm-from-manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
task_name: create-vm-from-manifest
task_category: create-vm
# create-vm-from-template.yaml main_image should be also updated to match this one!
main_image: quay.io/kubevirt/tekton-task-create-vm
main_image: quay.io/kubevirt/tekton-tasks
2 changes: 1 addition & 1 deletion configs/create-vm-from-template.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
task_name: create-vm-from-template
task_category: create-vm
# create-vm-from-manifest.yaml main_image should be also updated to match this one!
main_image: quay.io/kubevirt/tekton-task-create-vm
main_image: quay.io/kubevirt/tekton-tasks
is_okd: true
2 changes: 1 addition & 1 deletion configs/disk-virt-customize.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
task_name: disk-virt-customize
task_category: disk-virt-customize
main_image: quay.io/kubevirt/tekton-task-disk-virt-customize
main_image: quay.io/kubevirt/tekton-task-disk-virt
2 changes: 1 addition & 1 deletion configs/disk-virt-sysprep.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
task_name: disk-virt-sysprep
task_category: disk-virt-sysprep
main_image: quay.io/kubevirt/tekton-task-disk-virt-sysprep
main_image: quay.io/kubevirt/tekton-task-disk-virt
2 changes: 1 addition & 1 deletion configs/execute-in-vm.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
task_name: execute-in-vm
task_category: execute-in-vm
# cleanup-vm.yaml main_image should be also updated to match this one!
main_image: quay.io/kubevirt/tekton-task-execute-in-vm
main_image: quay.io/kubevirt/tekton-tasks
2 changes: 1 addition & 1 deletion configs/generate-ssh-keys.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
task_name: generate-ssh-keys
task_category: generate-ssh-keys
main_image: quay.io/kubevirt/tekton-task-generate-ssh-keys
main_image: quay.io/kubevirt/tekton-tasks
2 changes: 1 addition & 1 deletion configs/modify-data-object.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
task_name: modify-data-object
task_category: modify-data-object
main_image: quay.io/kubevirt/tekton-task-modify-data-object
main_image: quay.io/kubevirt/tekton-tasks
2 changes: 1 addition & 1 deletion configs/modify-object-task.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
task_name: modify-object
task_category: modify-object
main_image: quay.io/kubevirt/tekton-task-modify-object
main_image: quay.io/kubevirt/tekton-tasks
2 changes: 1 addition & 1 deletion configs/modify-vm-template.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
task_name: modify-vm-template
task_category: modify-vm-template
main_image: quay.io/kubevirt/tekton-task-modify-vm-template
main_image: quay.io/kubevirt/tekton-tasks
is_okd: true
6 changes: 3 additions & 3 deletions configs/modify-windows-iso-file.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
task_name: modify-windows-iso-file
task_category: modify-windows-iso-file
extract_iso_image: quay.io/kubevirt/tekton-task-disk-virt-customize
modify_iso_image: quay.io/kubevirt/tekton-task-modify-data-object
create_iso_image: quay.io/kubevirt/tekton-task-modify-data-object
extract_iso_image: quay.io/kubevirt/tekton-task-disk-virt
modify_iso_image: quay.io/kubevirt/tekton-tasks
create_iso_image: quay.io/kubevirt/tekton-tasks
2 changes: 1 addition & 1 deletion configs/wait-for-vmi-status.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
task_name: wait-for-vmi-status
task_category: wait-for-vmi-status
main_image: quay.io/kubevirt/tekton-task-wait-for-vmi-status
main_image: quay.io/kubevirt/tekton-tasks
35 changes: 24 additions & 11 deletions manifests/kubernetes/kubevirt-tekton-tasks-kubernetes.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1b3d5a4

Please sign in to comment.