1919version : ' 3'
2020
2121vars :
22- BASETAG : 0.1.0
23-
24- env :
25- OPS_API_TAG :
26- sh : git describe --tags --abbrev=0 2>/dev/null || git rev-parse --short HEAD
27- OPS_API_IMAGE : registry.hub.docker.com/apache/openserverless-admin-api
22+ BASETAG : 0.1.0-incubating
23+ COMMIT_ID :
24+ sh : git rev-parse --short HEAD
25+ TAG :
26+ sh : git describe --tags --abbrev=0 2>/dev/null || echo latest
2827
2928dotenv :
3029 - .env
@@ -49,34 +48,105 @@ tasks:
4948 then cp .env.example .env
5049 echo "Please edit .env file with your local CouchDB and Kubernetes credentials"
5150 fi
51+ - |
52+ if [ ! -d .venv ];
53+ then uv venv
54+ fi
5255 - uv pip install -r pyproject.toml 2>/dev/null
53-
54-
55- image-tag :
56- - git tag -d $(git tag)
57- - git tag -f {{.P}}{{.BASETAG}}.$(date +%y%m%d%H%M)
58- - env PAGER= git tag
5956
60- docker-login : >
61- echo $DOCKER_HUB_TOKEN | docker login registry.hub.docker.com -u $DOCKER_HUB_USER --password-stdin
57+ docker-login-ghcr : >
58+ silent: true
59+ cmds:
60+ - |
61+ echo "Logging in to ghcr.io as $GITHUB_USER"
62+ echo $GITHUB_TOKEN | docker login ghcr.io -u $GITHUB_USER --password-stdin
63+
64+ docker-login-dockerhub :
65+ silent : true
66+ cmds :
67+ - |
68+ echo "Logging in to dockerhub as $DOCKERHUB_USER"
69+ echo $DOCKERHUB_TOKEN | docker login -u $DOCKERHUB_USER --password-stdin
6270
63- docker-setup :
64- - docker buildx create --use
65- - docker run -it --rm --privileged tonistiigi/binfmt --install all
71+ docker-login :
72+ desc : |
73+ Login to the docker registry. Set REGISTRY=ghcr or REGISTRY=dockerhub in .env
74+ to use the respective registry.
75+ silent : true
76+ cmds :
77+ - |
78+ if [ -z "$REGISTRY" ]; then
79+ echo "Error: REGISTRY variable is not set in .env"
80+ exit 1
81+ fi
82+ task docker-login-$REGISTRY
83+
84+ image-tag :
85+ silent : true
86+ desc : |
87+ Create a new tag for the current git commit.
88+ cmds :
89+ - git tag -d $(git tag)
90+ - git tag -f {{.BASETAG}}.$(date +%y%m%d%H%M)
91+ - env PAGER= git tag
92+
93+ base-image-name :
94+ silent : true
95+ cmds :
96+ - |
97+ if [ -n "$REGISTRY" ] && [ -z "$NAMESPACE" ]; then
98+ echo "Error: NAMESPACE variable is not set in .env"
99+ exit 1
100+ fi
101+ if [ "$REGISTRY" = "ghcr" ]; then
102+ echo "ghcr.io/$NAMESPACE/openserverless-admin-api"
103+ elif [ "$REGISTRY" = "dockerhub" ]; then
104+ echo "docker.io/$NAMESPACE/openserverless-admin-api"
105+ elif [ "$REGISTRY" = "apache" ]; then
106+ echo "registry.hub.docker.com/apache/openserverless-admin-api"
107+ else
108+ echo "openserverless-admin-api"
109+ fi
66110
67- build :
68- - >
69- docker build . -t {{.OPS_API_IMAGE}}:{{.OPS_API_TAG}} --load
111+ buildx :
112+ desc : |
113+ Build the docker image using buildx. Set PUSH=1 to push the image to the registry.
114+ silent : true
115+ cmds :
116+ - |
117+ BASEIMG=$(task base-image-name)
118+ IMG="$BASEIMG:{{.TAG}}"
119+ if [ -n "{{.PUSH}}" ]; then
120+ if [ -z "$REGISTRY" ]; then
121+ echo "Error: REGISTRY variable must be set in .env to push the image"
122+ exit 1
123+ fi
124+ {{.DRY}} docker buildx build -t $IMG --platform linux/amd64,linux/arm64 . --push
125+ else
126+ {{.DRY}} docker buildx build -t $IMG . --load
127+ fi
128+
129+ build :
130+ silent : true
131+ desc : Build the image locally
132+ cmds :
133+ - |
134+ BASEIMG=$(task base-image-name)
135+ IMG="$BASEIMG:{{.TAG}}"
136+ docker build . -t $IMG --load
70137
71138 build-and-load :
72- - task : build
73- - >
74- kind load docker-image {{.OPS_API_IMAGE}}:{{.OPS_API_TAG}} --name=nuvolaris
139+ silent : true
140+ desc : Build the image and loads it to local Kind cluster
141+ cmds :
142+ - task : build
143+ - |
144+ BASEIMG=$(task base-image-name)
145+ IMG="$BASEIMG:{{.TAG}}"
146+ kind load docker-image $IMG --name=nuvolaris
75147
76- # Docker image
77- build-and-push :
148+ run :
149+ desc : |
150+ Run the admin api locally, using configuration from .env file
78151 cmds :
79- - task : docker-setup
80- - task : docker-login
81- - " docker buildx build --platform linux/amd64,linux/arm64 . -t {{.OPS_API_IMAGE}}:{{.OPS_API_TAG}} --push"
82-
152+ - uv run -m openserverless
0 commit comments