Skip to content

Commit

Permalink
Merge pull request #3 from eoscostarica/feat/add-kubernetes-example
Browse files Browse the repository at this point in the history
add kubernetes cron example
  • Loading branch information
xavier506 authored Sep 22, 2022
2 parents d5dbefe + e68f141 commit 7ad45b4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
34 changes: 34 additions & 0 deletions kubernetes/distribute.cronjob.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: distribute-cronjob
spec:
schedule: "0 0 10 * *"
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
spec:
containers:
- name: distribute
image: ${DOCKER_REGISTRY}/${IMAGE_NAME_DISTRIBUTE}:${VERSION}
imagePullPolicy: IfNotPresent
command: [ "node" ]
args: [ "/app/src/index.js" ]
env:
- name: EOS_API_ENDPOINT
value: "${EOS_API_ENDPOINT}"
- name: EOS_API_CHAIN_ID
value: "${EOS_API_CHAIN_ID}"
- name: EOS_DISTRIBUTE_ACCOUNT
value: "${EOS_DISTRIBUTE_ACCOUNT}"
- name: EOS_DISTRIBUTE_PERMISSION
value: "${EOS_DISTRIBUTE_PERMISSION}"
- name: EOS_DISTRIBUTE_PRIVATE_KEY
value: "${EOS_DISTRIBUTE_PRIVATE_KEY}"
- name: EOS_DISTRIBUTE_MAX_STEPS
value: "${EOS_DISTRIBUTE_MAX_STEPS}"
- name: EOS_EDEN_ACCOUNT
value: "${EOS_EDEN_ACCOUNT}"
restartPolicy: Never
16 changes: 8 additions & 8 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ run: node_modules

build-docker: ##@devops Build the docker image
build-docker: ./Dockerfile
@docker pull $(DOCKER_REGISTRY)/$(IMAGE_NAME_WATCHER):$(VERSION) || true
@docker pull $(DOCKER_REGISTRY)/$(IMAGE_NAME_DISTRIBUTE):$(VERSION) || true
@docker build \
--target release \
-t $(DOCKER_REGISTRY)/$(IMAGE_NAME_WATCHER):$(VERSION) \
-t $(DOCKER_REGISTRY)/$(IMAGE_NAME_WATCHER):$(LATEST_TAG) \
-t $(DOCKER_REGISTRY)/$(IMAGE_NAME_DISTRIBUTE):$(VERSION) \
-t $(DOCKER_REGISTRY)/$(IMAGE_NAME_DISTRIBUTE):$(LATEST_TAG) \
.

pull-image: ##@devops Pull the latest image from registry for caching
pull-image:
@docker pull $(DOCKER_REGISTRY)/$(IMAGE_NAME_WATCHER):$(LATEST_TAG) || true
@docker pull $(DOCKER_REGISTRY)/$(IMAGE_NAME_DISTRIBUTE):$(LATEST_TAG) || true

build-docker-cached: ##@devops Build the docker image using cached layers
build-docker-cached: ./Dockerfile
@docker build \
--target prod-stage \
--cache-from $(DOCKER_REGISTRY)/$(IMAGE_NAME_WATCHER):$(LATEST_TAG) \
-t $(DOCKER_REGISTRY)/$(IMAGE_NAME_WATCHER):$(VERSION) \
-t $(DOCKER_REGISTRY)/$(IMAGE_NAME_WATCHER):$(LATEST_TAG) \
--cache-from $(DOCKER_REGISTRY)/$(IMAGE_NAME_DISTRIBUTE):$(LATEST_TAG) \
-t $(DOCKER_REGISTRY)/$(IMAGE_NAME_DISTRIBUTE):$(VERSION) \
-t $(DOCKER_REGISTRY)/$(IMAGE_NAME_DISTRIBUTE):$(LATEST_TAG) \
.

push-image: ##@devops Push the freshly built image and tag with release or latest tag
push-image:
@docker push $(DOCKER_REGISTRY)/$(IMAGE_NAME_WATCHER):$(VERSION)
@docker push $(DOCKER_REGISTRY)/$(IMAGE_NAME_DISTRIBUTE):$(VERSION)
4 changes: 2 additions & 2 deletions mkutils/meta.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
VERSION ?= $(shell git rev-parse --short HEAD)
CURRENT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)

IMAGE_NAME_WATCHER=eden-distribute
IMAGE_NAME_DISTRIBUTE=eden-distribute

DOCKER_REGISTRY=eoscostarica506

MAKE_ENV += DOCKER_REGISTRY VERSION IMAGE_NAME_WATCHER
MAKE_ENV += DOCKER_REGISTRY VERSION IMAGE_NAME_DISTRIBUTE

SHELL_EXPORT := $(foreach v,$(MAKE_ENV),$(v)='$($(v))')

Expand Down

0 comments on commit 7ad45b4

Please sign in to comment.