Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.
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
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore build and test binaries.
bin/
testbin/
67 changes: 67 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# -*- mode: Python -*-

kubectl_cmd = "kubectl"

# verify kubectl command exists
if str(local("command -v " + kubectl_cmd + " || true", quiet = True)) == "":
fail("Required command '" + kubectl_cmd + "' not found in PATH")

# Use kustomize to build the install yaml files
install = kustomize('config/default')

# Update the root security group. Tilt requires root access to update the
# running process.
objects = decode_yaml_stream(install)
for o in objects:
if o.get('kind') == 'Deployment' and o.get('metadata').get('name') == 'git-sync-controller':
o['spec']['template']['spec']['securityContext']['runAsNonRoot'] = False
break

updated_install = encode_yaml_stream(objects)

# Apply the updated yaml to the cluster.
# Allow duplicates so the e2e test can include this tilt file with other tilt files
# setting up the same namespace.
k8s_yaml(updated_install, allow_duplicates = True)

load('ext://restart_process', 'docker_build_with_restart')

# enable hot reloading by doing the following:
# - locally build the whole project
# - create a docker imagine using tilt's hot-swap wrapper
# - push that container to the local tilt registry
# Once done, rebuilding now should be a lot faster since only the relevant
# binary is rebuilt and the hot swat wrapper takes care of the rest.
local_resource(
'git-sync-controller-binary',
'CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/manager ./',
deps = [
"main.go",
"go.mod",
"go.sum",
"api",
"controllers",
"pkg",
],
)

# Build the docker image for our controller. We use a specific Dockerfile
# since tilt can't run on a scratch container.
# `only` here is important, otherwise, the container will get updated
# on _any_ file change. We only want to monitor the binary.
# If debugging is enabled, we switch to a different docker file using
# the delve port.
entrypoint = ['/manager']
dockerfile = 'tilt.dockerfile'
docker_build_with_restart(
'ghcr.io/open-component-model/git-sync-controller',
'.',
dockerfile = dockerfile,
entrypoint = entrypoint,
only=[
'./bin',
],
live_update = [
sync('./bin/manager', '/manager'),
],
)
4 changes: 2 additions & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ images:
newName: controller
newTag: latest
- name: open-component-model/git-sync-controller
newName: localhost:5001/open-component-model/git-sync-controller
newTag: v0.0.1
newName: ghcr.io/open-component-model/git-sync-controller
newTag: latest
5 changes: 5 additions & 0 deletions tilt.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM alpine
WORKDIR /
COPY ./bin/manager /manager

ENTRYPOINT ["/manager"]