Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# PORCH_GHCR_PREFIX_URL=<custom registry>/kptdev/krm-functions-catalog
# DOCKERHUB_MIRROR=<mirror registry url>
Comment thread
liamfallon marked this conversation as resolved.
# DB_MAVEN_MIRROR=<mirror repository url>
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ ifneq ("$(wildcard .env)", "")
export
endif

export PORCH_GHCR_PREFIX_URL ?= ghcr.io/kptdev/krm-functions-catalog
# remove '/' suffix
export PORCH_GHCR_PREFIX_URL := $(patsubst %/,%,$(PORCH_GHCR_PREFIX_URL))
export DOCKERHUB_MIRROR ?=
# remove '/' suffix
export DOCKERHUB_MIRROR := $(patsubst %/,%,$(DOCKERHUB_MIRROR))
Comment thread
mozesl-nokia marked this conversation as resolved.

# Include module makefiles
include make/build.mk # generate, tidy, porch, porchctl, build-images, push-images
include make/deploy.mk # deploy, run-in-kind*, destroy, deployment-config*, load-images-to-kind, reload-*
Expand Down
6 changes: 3 additions & 3 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.


ARG ALPINE_VERSION=latest
ARG GOLANG_BOOKWORM_VERSION=latest
ARG DOCKERHUB_MIRROR=docker.io

FROM golang:${GOLANG_BOOKWORM_VERSION} AS builder
FROM ${DOCKERHUB_MIRROR}/golang:${GOLANG_BOOKWORM_VERSION} AS builder

WORKDIR /go/src

Expand All @@ -43,7 +43,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \
go build -trimpath -ldflags="-s -w" -v -o /porch ./cmd/porch


FROM alpine:${ALPINE_VERSION}
FROM ${DOCKERHUB_MIRROR}/alpine:${ALPINE_VERSION}
RUN addgroup -g 10001 nonroot && \
adduser -D -G nonroot -u 10001 nonroot

Expand Down
5 changes: 3 additions & 2 deletions build/Dockerfile.apiserver
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@

ARG ALPINE_VERSION=latest
ARG GOLANG_BOOKWORM_VERSION=latest
ARG DOCKERHUB_MIRROR=docker.io

FROM golang:${GOLANG_BOOKWORM_VERSION} AS builder
FROM ${DOCKERHUB_MIRROR}/golang:${GOLANG_BOOKWORM_VERSION} AS builder

WORKDIR /workspace/src
RUN git clone https://github.com/kubernetes/kubernetes --branch v1.30.3 --depth=1
WORKDIR /workspace/src/kubernetes
RUN apt-get update && apt-get install --yes rsync
RUN make kube-apiserver

FROM alpine:${ALPINE_VERSION}
FROM ${DOCKERHUB_MIRROR}/alpine:${ALPINE_VERSION}
RUN addgroup -g 10001 nonroot && \
adduser -D -G nonroot -u 10001 nonroot

Expand Down
6 changes: 4 additions & 2 deletions build/Dockerfile.etcd
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
# limitations under the License.

ARG ALPINE_VERSION=latest
ARG GOLANG_BOOKWORM_VERSION=1.25.7-bookworm
ARG DOCKERHUB_MIRROR=docker.io

FROM golang:1.25.7-bookworm AS builder
FROM ${DOCKERHUB_MIRROR}/golang:${GOLANG_BOOKWORM_VERSION} AS builder

Comment thread
mozesl-nokia marked this conversation as resolved.
Comment thread
mozesl-nokia marked this conversation as resolved.
WORKDIR /workspace
ARG ETCD_VER=v3.5.21
RUN curl -L https://github.com/etcd-io/etcd/releases/download/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz \
| tar --strip-components 1 -xvz "etcd-${ETCD_VER}-linux-amd64/etcd"

FROM alpine:${ALPINE_VERSION}
FROM ${DOCKERHUB_MIRROR}/alpine:${ALPINE_VERSION}
RUN addgroup -g 10001 nonroot && \
adduser -D -G nonroot -u 10001 nonroot

Expand Down
12 changes: 10 additions & 2 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ ALPINE_VERSION ?= 3.23.3

.PHONY: build-image docker-build
build-image docker-build:
docker buildx build --load --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) --build-arg ALPINE_VERSION=$(ALPINE_VERSION) --build-arg GOLANG_BOOKWORM_VERSION=$(GOLANG_BOOKWORM_VERSION) -f ./Dockerfile "$(PORCHDIR)"
docker buildx build --load --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) \
--build-arg ALPINE_VERSION=$(ALPINE_VERSION) \
--build-arg GOLANG_BOOKWORM_VERSION=$(GOLANG_BOOKWORM_VERSION) \
$$(if [ -n "${DOCKERHUB_MIRROR}" ]; then echo "--build-arg DOCKERHUB_MIRROR=${DOCKERHUB_MIRROR}"; fi) \
-f ./Dockerfile "$(PORCHDIR)"
Comment thread
mozesl-nokia marked this conversation as resolved.

.PHONY: push-image docker-push
push-image docker-push:
docker buildx build --push --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) --build-arg ALPINE_VERSION=$(ALPINE_VERSION) --build-arg GOLANG_BOOKWORM_VERSION=$(GOLANG_BOOKWORM_VERSION) -f ./Dockerfile "$(PORCHDIR)"
docker buildx build --push --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) \
--build-arg ALPINE_VERSION=$(ALPINE_VERSION) \
--build-arg GOLANG_BOOKWORM_VERSION=$(GOLANG_BOOKWORM_VERSION) \
$$(if [ -n "${DOCKERHUB_MIRROR}" ]; then echo "--build-arg DOCKERHUB_MIRROR=${DOCKERHUB_MIRROR}"; fi) \
-f ./Dockerfile "$(PORCHDIR)"
5 changes: 3 additions & 2 deletions controllers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

ARG ALPINE_VERSION=latest
ARG GOLANG_BOOKWORM_VERSION=latest
ARG DOCKERHUB_MIRROR=docker.io

FROM golang:${GOLANG_BOOKWORM_VERSION} AS builder
FROM ${DOCKERHUB_MIRROR}/golang:${GOLANG_BOOKWORM_VERSION} AS builder
Comment thread
mozesl-nokia marked this conversation as resolved.

WORKDIR /go/src

Expand All @@ -42,7 +43,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /porch-controllers -v .

FROM alpine:${ALPINE_VERSION}
FROM ${DOCKERHUB_MIRROR}/alpine:${ALPINE_VERSION}
RUN addgroup -g 10001 nonroot && \
adduser -D -G nonroot -u 10001 nonroot

Expand Down
12 changes: 10 additions & 2 deletions controllers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ IMAGE_NAME ?= porch-controllers

.PHONY: build-image docker-build
build-image docker-build:
docker buildx build --load --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) --build-arg ALPINE_VERSION=$(ALPINE_VERSION) --build-arg GOLANG_BOOKWORM_VERSION=$(GOLANG_BOOKWORM_VERSION) -f Dockerfile ..
docker buildx build --load --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) \
--build-arg ALPINE_VERSION=$(ALPINE_VERSION) \
--build-arg GOLANG_BOOKWORM_VERSION=$(GOLANG_BOOKWORM_VERSION) \
$$(if [ -n "${DOCKERHUB_MIRROR}" ]; then echo "--build-arg DOCKERHUB_MIRROR=${DOCKERHUB_MIRROR}"; fi) \
-f Dockerfile ..
Comment thread
mozesl-nokia marked this conversation as resolved.

.PHONY: push-image docker-push
push-image docker-push:
docker buildx build --push --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) --build-arg ALPINE_VERSION=$(ALPINE_VERSION) --build-arg GOLANG_BOOKWORM_VERSION=$(GOLANG_BOOKWORM_VERSION) -f Dockerfile ..
docker buildx build --push --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) \
--build-arg ALPINE_VERSION=$(ALPINE_VERSION) \
--build-arg GOLANG_BOOKWORM_VERSION=$(GOLANG_BOOKWORM_VERSION) \
$$(if [ -n "${DOCKERHUB_MIRROR}" ]; then echo "--build-arg DOCKERHUB_MIRROR=${DOCKERHUB_MIRROR}"; fi) \
-f Dockerfile ..
26 changes: 14 additions & 12 deletions func/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@

ARG ALPINE_VERSION=latest
ARG GOLANG_ALPINE_VERSION=latest
ARG PORCH_GHCR_PREFIX_URL=ghcr.io/kptdev/krm-functions-catalog
ARG DOCKERHUB_MIRROR=docker.io

FROM ghcr.io/kptdev/krm-functions-catalog/apply-setters:v0.2.4 AS apply-setters
FROM ghcr.io/kptdev/krm-functions-catalog/ensure-name-substring:v0.2.1 AS ensure-name-substring
FROM ghcr.io/kptdev/krm-functions-catalog/search-replace:v0.2.3 AS search-replace
FROM ghcr.io/kptdev/krm-functions-catalog/set-annotations:v0.1.7 AS set-annotations
FROM ghcr.io/kptdev/krm-functions-catalog/set-image:v0.2.2 AS set-image
FROM ghcr.io/kptdev/krm-functions-catalog/set-labels:v0.2.4 AS set-labels
FROM ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.4.5 AS set-namespace
FROM ghcr.io/kptdev/krm-functions-catalog/set-project-id:v0.2.1 AS set-project-id
FROM ghcr.io/kptdev/krm-functions-catalog/starlark:v0.5.5 AS starlark
FROM ghcr.io/kptdev/krm-functions-catalog/upsert-resource:v0.2.3 AS upsert-resource
FROM ${PORCH_GHCR_PREFIX_URL}/apply-setters:v0.2.4 AS apply-setters
FROM ${PORCH_GHCR_PREFIX_URL}/ensure-name-substring:v0.2.1 AS ensure-name-substring
FROM ${PORCH_GHCR_PREFIX_URL}/search-replace:v0.2.3 AS search-replace
FROM ${PORCH_GHCR_PREFIX_URL}/set-annotations:v0.1.7 AS set-annotations
FROM ${PORCH_GHCR_PREFIX_URL}/set-image:v0.2.2 AS set-image
FROM ${PORCH_GHCR_PREFIX_URL}/set-labels:v0.2.4 AS set-labels
FROM ${PORCH_GHCR_PREFIX_URL}/set-namespace:v0.4.5 AS set-namespace
FROM ${PORCH_GHCR_PREFIX_URL}/set-project-id:v0.2.1 AS set-project-id
FROM ${PORCH_GHCR_PREFIX_URL}/starlark:v0.5.5 AS starlark
FROM ${PORCH_GHCR_PREFIX_URL}/upsert-resource:v0.2.3 AS upsert-resource


FROM golang:${GOLANG_ALPINE_VERSION} AS builder
FROM ${DOCKERHUB_MIRROR}/golang:${GOLANG_ALPINE_VERSION} AS builder
WORKDIR /go/src

RUN go install github.com/grpc-ecosystem/grpc-health-probe@v0.4.11
Expand All @@ -49,7 +51,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
cd func ; go build -trimpath -ldflags="-s -w" -v -o /server ./server

FROM alpine:${ALPINE_VERSION}
FROM ${DOCKERHUB_MIRROR}/alpine:${ALPINE_VERSION}
RUN addgroup -g 10001 nonroot && \
adduser -D -G nonroot -u 10001 nonroot

Expand Down
5 changes: 3 additions & 2 deletions func/Dockerfile-wrapperserver
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

ARG ALPINE_VERSION=latest
ARG GOLANG_ALPINE_VERSION=latest
ARG DOCKERHUB_MIRROR=docker.io

FROM golang:${GOLANG_ALPINE_VERSION} AS builder
FROM ${DOCKERHUB_MIRROR}/golang:${GOLANG_ALPINE_VERSION} AS builder

WORKDIR /go/src

Expand All @@ -39,7 +40,7 @@ RUN --mount=type=cache,target=/go/pkg/mod \
cd func ; go build -trimpath -ldflags="-s -w" -v -o /wrapper-server/wrapper-server ./wrapper-server
RUN cp $GOPATH/bin/grpc-health-probe /wrapper-server/

FROM alpine:${ALPINE_VERSION}
FROM ${DOCKERHUB_MIRROR}/alpine:${ALPINE_VERSION}
RUN addgroup -g 10001 nonroot && \
adduser -D -G nonroot -u 10001 nonroot

Expand Down
28 changes: 24 additions & 4 deletions func/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,30 @@ $(COMPILED_PROTO): evaluator/evaluator.proto

.PHONY: build-image docker-build
build-image docker-build:
docker buildx build --load --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) --build-arg ALPINE_VERSION=$(ALPINE_VERSION) --build-arg GOLANG_ALPINE_VERSION=$(GOLANG_ALPINE_VERSION) -f ./Dockerfile "$(PORCHDIR)"
docker buildx build --load --tag $(IMAGE_REPO)/$(WRAPPER_SERVER_IMAGE_NAME):$(IMAGE_TAG) --build-arg ALPINE_VERSION=$(ALPINE_VERSION) --build-arg GOLANG_ALPINE_VERSION=$(GOLANG_ALPINE_VERSION) -f ./Dockerfile-wrapperserver "$(PORCHDIR)"
docker buildx build --load --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) \
--build-arg ALPINE_VERSION=$(ALPINE_VERSION) \
--build-arg GOLANG_ALPINE_VERSION=$(GOLANG_ALPINE_VERSION) \
$$(if [ -n "${DOCKERHUB_MIRROR}" ]; then echo "--build-arg DOCKERHUB_MIRROR=${DOCKERHUB_MIRROR}"; fi) \
$$(if [ -n "${PORCH_GHCR_PREFIX_URL}" ]; then echo "--build-arg PORCH_GHCR_PREFIX_URL=${PORCH_GHCR_PREFIX_URL}"; fi) \
-f ./Dockerfile "$(PORCHDIR)"
Comment thread
mozesl-nokia marked this conversation as resolved.
docker buildx build --load --tag $(IMAGE_REPO)/$(WRAPPER_SERVER_IMAGE_NAME):$(IMAGE_TAG) \
--build-arg ALPINE_VERSION=$(ALPINE_VERSION) \
--build-arg GOLANG_ALPINE_VERSION=$(GOLANG_ALPINE_VERSION) \
$$(if [ -n "${DOCKERHUB_MIRROR}" ]; then echo "--build-arg DOCKERHUB_MIRROR=${DOCKERHUB_MIRROR}"; fi) \
$$(if [ -n "${PORCH_GHCR_PREFIX_URL}" ]; then echo "--build-arg PORCH_GHCR_PREFIX_URL=${PORCH_GHCR_PREFIX_URL}"; fi) \
-f ./Dockerfile-wrapperserver "$(PORCHDIR)"

.PHONY: push-image docker-push
push-image docker-push:
docker buildx build --push --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) --build-arg ALPINE_VERSION=$(ALPINE_VERSION) --build-arg GOLANG_ALPINE_VERSION=$(GOLANG_ALPINE_VERSION) -f ./Dockerfile "$(PORCHDIR)"
docker buildx build --push --tag $(IMAGE_REPO)/$(WRAPPER_SERVER_IMAGE_NAME):$(IMAGE_TAG) --build-arg ALPINE_VERSION=$(ALPINE_VERSION) --build-arg GOLANG_ALPINE_VERSION=$(GOLANG_ALPINE_VERSION) -f ./Dockerfile-wrapperserver "$(PORCHDIR)"
docker buildx build --push --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) \
--build-arg ALPINE_VERSION=$(ALPINE_VERSION) \
--build-arg GOLANG_ALPINE_VERSION=$(GOLANG_ALPINE_VERSION) \
$$(if [ -n "${DOCKERHUB_MIRROR}" ]; then echo "--build-arg DOCKERHUB_MIRROR=${DOCKERHUB_MIRROR}"; fi) \
$$(if [ -n "${PORCH_GHCR_PREFIX_URL}" ]; then echo "--build-arg PORCH_GHCR_PREFIX_URL=${PORCH_GHCR_PREFIX_URL}"; fi) \
-f ./Dockerfile "$(PORCHDIR)"
docker buildx build --push --tag $(IMAGE_REPO)/$(WRAPPER_SERVER_IMAGE_NAME):$(IMAGE_TAG) \
--build-arg ALPINE_VERSION=$(ALPINE_VERSION) \
--build-arg GOLANG_ALPINE_VERSION=$(GOLANG_ALPINE_VERSION) \
$$(if [ -n "${DOCKERHUB_MIRROR}" ]; then echo "--build-arg DOCKERHUB_MIRROR=${DOCKERHUB_MIRROR}"; fi) \
$$(if [ -n "${PORCH_GHCR_PREFIX_URL}" ]; then echo "--build-arg PORCH_GHCR_PREFIX_URL=${PORCH_GHCR_PREFIX_URL}"; fi) \
-f ./Dockerfile-wrapperserver "$(PORCHDIR)"
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
github.com/google/go-containerregistry v0.20.6
github.com/google/uuid v1.6.0
github.com/jackc/pgx/v5 v5.9.2
github.com/joho/godotenv v1.5.1
github.com/kptdev/kpt v1.0.0-beta.62.1
github.com/kptdev/krm-functions-catalog/functions/go/apply-replacements v0.1.5
github.com/kptdev/krm-functions-catalog/functions/go/apply-setters v0.2.4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/jonboulle/clockwork v0.5.0 h1:Hyh9A8u51kptdkR+cqRpT1EebBwTn1oK9YfGYbdFz6I=
github.com/jonboulle/clockwork v0.5.0/go.mod h1:3mZlmanh0g2NDKO5TWZVJAfofYk64M7XN3SzBPjZF60=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
Expand Down
18 changes: 9 additions & 9 deletions make/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,21 @@ porchctl:

.PHONY: build-images
build-images:
ALPINE_VERSION="$(ALPINE_VERSION)" GOLANG_BOOKWORM_VERSION="$(GOLANG_BOOKWORM_VERSION)" IMAGE_NAME="$(PORCH_SERVER_IMAGE)" make -C build/ build-image
ALPINE_VERSION="$(ALPINE_VERSION)" GOLANG_BOOKWORM_VERSION="$(GOLANG_BOOKWORM_VERSION)" IMAGE_NAME="$(PORCH_CONTROLLERS_IMAGE)" make -C controllers/ build-image
ALPINE_VERSION="$(ALPINE_VERSION)" GOLANG_ALPINE_VERSION="$(GOLANG_ALPINE_VERSION)" IMAGE_NAME="$(PORCH_FUNCTION_RUNNER_IMAGE)" WRAPPER_SERVER_IMAGE_NAME="$(PORCH_WRAPPER_SERVER_IMAGE)" make -C func/ build-image
GOLANG_BOOKWORM_VERSION="$(GOLANG_BOOKWORM_VERSION)" IMAGE_NAME="$(TEST_GIT_SERVER_IMAGE)" make -C test/ build-image
ALPINE_VERSION="$(ALPINE_VERSION)" GOLANG_BOOKWORM_VERSION="$(GOLANG_BOOKWORM_VERSION)" DOCKERHUB_MIRROR="$(DOCKERHUB_MIRROR)" IMAGE_NAME="$(PORCH_SERVER_IMAGE)" make -C build/ build-image
ALPINE_VERSION="$(ALPINE_VERSION)" GOLANG_BOOKWORM_VERSION="$(GOLANG_BOOKWORM_VERSION)" DOCKERHUB_MIRROR="$(DOCKERHUB_MIRROR)" IMAGE_NAME="$(PORCH_CONTROLLERS_IMAGE)" make -C controllers/ build-image
ALPINE_VERSION="$(ALPINE_VERSION)" GOLANG_ALPINE_VERSION="$(GOLANG_ALPINE_VERSION)" DOCKERHUB_MIRROR="$(DOCKERHUB_MIRROR)" IMAGE_NAME="$(PORCH_FUNCTION_RUNNER_IMAGE)" WRAPPER_SERVER_IMAGE_NAME="$(PORCH_WRAPPER_SERVER_IMAGE)" make -C func/ build-image
GOLANG_BOOKWORM_VERSION="$(GOLANG_BOOKWORM_VERSION)" DOCKERHUB_MIRROR="$(DOCKERHUB_MIRROR)" IMAGE_NAME="$(TEST_GIT_SERVER_IMAGE)" make -C test/ build-image

.PHONY: push-images
push-images:
ALPINE_VERSION="$(ALPINE_VERSION)" GOLANG_BOOKWORM_VERSION="$(GOLANG_BOOKWORM_VERSION)" IMAGE_NAME="$(PORCH_SERVER_IMAGE)" make -C build/ push-image
ALPINE_VERSION="$(ALPINE_VERSION)" GOLANG_BOOKWORM_VERSION="$(GOLANG_BOOKWORM_VERSION)" IMAGE_NAME="$(PORCH_CONTROLLERS_IMAGE)" make -C controllers/ push-image
ALPINE_VERSION="$(ALPINE_VERSION)" GOLANG_ALPINE_VERSION="$(GOLANG_ALPINE_VERSION)" IMAGE_NAME="$(PORCH_FUNCTION_RUNNER_IMAGE)" WRAPPER_SERVER_IMAGE_NAME="$(PORCH_WRAPPER_SERVER_IMAGE)" make -C func/ push-image
GOLANG_BOOKWORM_VERSION="$(GOLANG_BOOKWORM_VERSION)" IMAGE_NAME="$(TEST_GIT_SERVER_IMAGE)" make -C test/ push-image
ALPINE_VERSION="$(ALPINE_VERSION)" GOLANG_BOOKWORM_VERSION="$(GOLANG_BOOKWORM_VERSION)" DOCKERHUB_MIRROR="$(DOCKERHUB_MIRROR)" IMAGE_NAME="$(PORCH_SERVER_IMAGE)" make -C build/ push-image
ALPINE_VERSION="$(ALPINE_VERSION)" GOLANG_BOOKWORM_VERSION="$(GOLANG_BOOKWORM_VERSION)" DOCKERHUB_MIRROR="$(DOCKERHUB_MIRROR)" IMAGE_NAME="$(PORCH_CONTROLLERS_IMAGE)" make -C controllers/ push-image
ALPINE_VERSION="$(ALPINE_VERSION)" GOLANG_ALPINE_VERSION="$(GOLANG_ALPINE_VERSION)" DOCKERHUB_MIRROR="$(DOCKERHUB_MIRROR)" IMAGE_NAME="$(PORCH_FUNCTION_RUNNER_IMAGE)" WRAPPER_SERVER_IMAGE_NAME="$(PORCH_WRAPPER_SERVER_IMAGE)" make -C func/ push-image
GOLANG_BOOKWORM_VERSION="$(GOLANG_BOOKWORM_VERSION)" DOCKERHUB_MIRROR="$(DOCKERHUB_MIRROR)" IMAGE_NAME="$(TEST_GIT_SERVER_IMAGE)" make -C test/ push-image

.PHONY: dev-server
dev-server:
ALPINE_VERSION="$(ALPINE_VERSION)" IMAGE_NAME="$(PORCH_SERVER_IMAGE)" make -C build/ push-image
ALPINE_VERSION="$(ALPINE_VERSION)" DOCKERHUB_MIRROR="$(DOCKERHUB_MIRROR)" IMAGE_NAME="$(PORCH_SERVER_IMAGE)" make -C build/ push-image
kubectl set image -n porch-system deployment/porch-server porch-server=$(IMAGE_REPO)/$(PORCH_SERVER_IMAGE):${IMAGE_TAG}

.PHONY: update-kube-apiserver-vendoring
Expand Down
4 changes: 2 additions & 2 deletions make/deploy.mk
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ deploy-gitea-dev-pkg:## Deploy gitea development package
--kubeconfig $(KUBECONFIG)

.PHONY: setup-dev-env
setup-dev-env: PORCH_TEST_CLUSTER=porch-test ## Setup gitea, Metallb and test repository in kind cluster
setup-dev-env: PORCH_TEST_CLUSTER=porch-test
setup-dev-env: GIT_REPO_NAME=porch-test
setup-dev-env:
setup-dev-env: ## Setup gitea, Metallb and test repository in kind cluster
./scripts/setup-dev-env.sh
15 changes: 13 additions & 2 deletions pkg/cache/dbcache/dbcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"time"

embeddedpostgres "github.com/fergusstrange/embedded-postgres"
"github.com/joho/godotenv"
configapi "github.com/kptdev/porch/api/porchconfig/v1alpha1"
"github.com/kptdev/porch/pkg/cache/testutil"
cachetypes "github.com/kptdev/porch/pkg/cache/types"
Expand All @@ -38,6 +39,7 @@ import (
)

const defaultPorchSQLSchema = "api/sql/porch-db.sql"
const dbMavenMirrorEnv = "DB_MAVEN_MIRROR"

type DbTestSuite struct {
suite.Suite
Expand All @@ -61,12 +63,21 @@ func (t *DbTestSuite) Context() context.Context {
}

func (t *DbTestSuite) SetupSuite() {
postgres := embeddedpostgres.NewDatabase(embeddedpostgres.DefaultConfig().
if err := godotenv.Load("../../../.env"); err != nil {
t.T().Logf("Failed to load .env file: %v", err)
Comment thread
mozesl-nokia marked this conversation as resolved.
}

config := embeddedpostgres.DefaultConfig().
Username("porch").
Password("porch").
Database("porch").
Port(55432))
Port(55432)

if mavenMirror := os.Getenv(dbMavenMirrorEnv); mavenMirror != "" {
config = config.BinaryRepositoryURL(mavenMirror)
}

postgres := embeddedpostgres.NewDatabase(config)
err := postgres.Start()
t.Require().NoError(err, "could not start test instance of postgres")

Expand Down
35 changes: 33 additions & 2 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,34 @@
# Fallback defaults for direct script execution
# NOTE: Users should use root Makefile targets instead of calling scripts directly

# Only set defaults if variables are not already exported from Makefile
# Only set defaults if variables are not already exported from Makefile.
# .env entries do not override variables already set in the environment.

PORCHDIR=${PORCHDIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}

if [[ -f "${PORCHDIR}/.env" ]]; then
_env_trim() {
local s="$1"
s="${s#"${s%%[![:space:]]*}"}"
s="${s%"${s##*[![:space:]]}"}"
printf '%s' "$s"
}
while IFS= read -r line || [[ -n "$line" ]]; do
[[ "$line" =~ ^[[:space:]]*# ]] && continue
[[ -z "${line//[[:space:]]/}" ]] && continue
[[ "$line" != *=* ]] && continue
key="${line%%=*}"
value="${line#*=}"
key="$(_env_trim "$key")"
value="$(_env_trim "$value")"
[[ -z "$key" ]] && continue
[[ -n "${!key+x}" ]] && continue
export "${key}=${value}"
done < "${PORCHDIR}/.env"
Comment thread
mozesl-nokia marked this conversation as resolved.
unset -f _env_trim
unset -v key value line
Comment thread
liamfallon marked this conversation as resolved.
fi

IMAGE_REPO=${IMAGE_REPO:-ghcr.io/kptdev}

PORCH_SERVER_IMAGE=${PORCH_SERVER_IMAGE:-porch-server}
Expand All @@ -15,11 +42,15 @@ SKIP_IMG_BUILD=${SKIP_IMG_BUILD:-false}
SKIP_PORCHSERVER_BUILD=${SKIP_PORCHSERVER_BUILD:-false}
SKIP_CONTROLLER_BUILD=${SKIP_CONTROLLER_BUILD:-false}

PORCHDIR=${PORCHDIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}
KIND_CONTEXT_NAME=${KIND_CONTEXT_NAME:-porch-test}
ENABLED_RECONCILERS=${ENABLED_RECONCILERS:-"packagevariants,packagevariantsets,repositories"}
PORCH_CACHE_TYPE=${PORCH_CACHE_TYPE:-CR}
FN_RUNNER_WARM_UP_POD_CACHE=${FN_RUNNER_WARM_UP_POD_CACHE:-true}
DB_PUSH_DRAFTS_TO_GIT=${DB_PUSH_DRAFTS_TO_GIT:-false}
CREATE_V1ALPHA2_RPKG=${CREATE_V1ALPHA2_RPKG:-false}
DEPLOYPORCHCONFIGDIR=${DEPLOYPORCHCONFIGDIR:-${PORCHDIR}/.build/deploy}

DOCKERHUB_MIRROR=${DOCKERHUB_MIRROR:-""}
DOCKERHUB_MIRROR=${DOCKERHUB_MIRROR%/} # remove '/' suffix
PORCH_GHCR_PREFIX_URL=${PORCH_GHCR_PREFIX_URL:-ghcr.io/kptdev/krm-functions-catalog}
PORCH_GHCR_PREFIX_URL=${PORCH_GHCR_PREFIX_URL%/} # remove '/' suffix
Loading
Loading