Skip to content

Commit

Permalink
gcp: fixes to image generation
Browse files Browse the repository at this point in the history
This should be squashed.

Signed-off-by: Beraldo Leal <[email protected]>
  • Loading branch information
beraldoleal committed May 10, 2024
1 parent ba75aa2 commit 7c94918
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/cloud-api-adaptor/gcp/image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ RUN if [ -n "${CAA_SRC}" ]; then \
git checkout FETCH_HEAD -b ${CAA_SRC_REF} ;\
fi

RUN mkdir -p /src/cloud-api-adaptor/podvm/files

# Copy the binaries to podvm/files folder
COPY --from=podvm_binaries /podvm-binaries.tar.gz /src/cloud-api-adaptor/podvm/files
RUN tar xvf /src/cloud-api-adaptor/podvm/files/podvm-binaries.tar.gz -C /src/cloud-api-adaptor/podvm/files
Expand All @@ -39,9 +41,6 @@ RUN tar xvf /src/cloud-api-adaptor/podvm/files/podvm-binaries.tar.gz -C /src/clo
COPY --from=podvm_binaries /pause-bundle.tar.gz /src/cloud-api-adaptor/podvm/files
RUN tar xvf /src/cloud-api-adaptor/podvm/files/pause-bundle.tar.gz -C /src/cloud-api-adaptor/podvm/files

# Uncomment for development.
COPY . cloud-api-adaptor/gcp/image

ARG GCP_PROJECT_ID
ARG GCP_ZONE
ARG GCP_MACHINE_TYPE=e2-medium
Expand All @@ -54,6 +53,9 @@ ENV GCP_MACHINE_TYPE ${GCP_MACHINE_TYPE}
ENV GCP_NETWORK ${GCP_NETWORK}
ENV IMAGE_NAME ${IMAGE_NAME}

# Uncomment for development.
COPY . cloud-api-adaptor/gcp/image

RUN --mount=type=secret,id=APPLICATION_KEY \
export GOOGLE_APPLICATION_CREDENTIALS="/run/secrets/APPLICATION_KEY" && \
cd cloud-api-adaptor/gcp/image && \
Expand Down
25 changes: 24 additions & 1 deletion src/cloud-api-adaptor/gcp/image/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
#
# SPDX-License-Identifier: Apache-2.0
#
include ../../podvm/Makefile.inc
#include ../../podvm/Makefile.inc


.PHONY: image clean

GCP_MACHINE_TYPE ?= e2-medium
GCP_NETWORK ?= default

PODVM_DISTRO ?= ubuntu

PODVM_BUILDER_IMAGE ?= $(REGISTRY)/podvm-builder-$(PODVM_DISTRO):$(PODVM_TAG)
PODVM_BINARIES_IMAGE ?= $(REGISTRY)/podvm-binaries-$(PODVM_DISTRO)-$(ARCH):$(PODVM_TAG)

IMAGE_FILE ?= podvm-$(or $(CLOUD_PROVIDER),gcp)-$(PODVM_DISTRO)-$(ARCH)
PODVM_IMAGE ?= $(REGISTRY)/$(IMAGE_FILE):$(PODVM_TAG)

image: $(IMAGE_FILE)

$(IMAGE_FILE): setopts $(BINARIES) $(FILES)
Expand All @@ -28,6 +36,21 @@ ifeq ($(GCP_ZONE),)
$(error GCP_ZONE is not defined)
endif


podvm-image:
docker buildx build --progress=plain --no-cache -t $(PODVM_IMAGE) -f Dockerfile \
--build-arg BUILDER_IMG=$(PODVM_BUILDER_IMAGE) \
--build-arg BINARIES_IMG=$(PODVM_BINARIES_IMAGE) \
--build-arg PODVM_DISTRO=$(PODVM_DISTRO) \
--build-arg ARCH=$(ARCH) \
--build-arg GCP_ZONE=$(GCP_ZONE) \
--build-arg GCP_PROJECT_ID=$(GCP_PROJECT_ID) \
--build-arg CLOUD_PROVIDER=$(or $(CLOUD_PROVIDER),gcp) \
--build-arg IMAGE_URL=$(IMAGE_URL) \
--build-arg IMAGE_CHECKSUM=$(IMAGE_CHECKSUM) \
--secret id=APPLICATION_KEY,src=${GOOGLE_APPLICATION_CREDENTIALS} \
$(DOCKER_OPTS) .
rm -rf .git
clean:
rm -f "$(IMAGE_FILE)" "$(UBUNTU_IMAGE_FILE)" $(BINARIES)
rm -fr "$(SKOPEO_SRC)" "$(UMOCI_SRC)" "$(PAUSE_SRC)" "$(FILES_DIR)/$(PAUSE_BUNDLE)"
Expand Down

0 comments on commit 7c94918

Please sign in to comment.