FROM ubuntu:noble AS builder

# Staging area
RUN apt-get update -y
RUN apt-get install -y git build-essential wget golang-go

RUN mkdir -p /opt/dev

RUN \
	cd /opt/dev && \
	git clone https://github.com/GoogleContainerTools/kaniko.git && \
	cd kaniko && \
	sed -i 's/GOFLAGS = -mod=vendor/GOFLAGS = -mod=vendor -buildvcs=false/g' Makefile && \
	make out/executor

RUN mkdir -p /opt/dev/crane
ADD https://github.com/google/go-containerregistry/releases/download/v0.20.6/go-containerregistry_Linux_arm64.tar.gz /tmp

RUN cd /opt/dev/crane && \
	tar xf /tmp/go-containerregistry_Linux_arm64.tar.gz

FROM ubuntu:noble

RUN apt-get update && \
	apt-get install -y ca-certificates

RUN mkdir -p /kaniko/.docker
RUN mkdir -p /workspace

COPY --from=builder \
	/opt/dev/kaniko/out/executor /kaniko/executor

COPY --from=builder \
	/opt/dev/crane/* /usr/sbin/

CMD ["/bin/bash"]
