From 929e3341932d9f081ed28414ac4f6bbf22c2863f Mon Sep 17 00:00:00 2001 From: syntaf Date: Mon, 11 Nov 2024 08:17:37 -0800 Subject: [PATCH] Updates to build pipeline --- Dockerfile.production | 2 +- Makefile | 53 +++++++++++++++++++++++-------------------- version.txt | 2 +- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/Dockerfile.production b/Dockerfile.production index 67f0833..cfa2b3f 100644 --- a/Dockerfile.production +++ b/Dockerfile.production @@ -6,7 +6,7 @@ ENV INSTALL_PATH /opt/wetrockpolice RUN mkdir -p $INSTALL_PATH # nodejs, yarn & bun -RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - +RUN curl -sL https://deb.nodesource.com/setup_20.x | bash - RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg -o /root/yarn-pubkey.gpg && apt-key add /root/yarn-pubkey.gpg RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list RUN apt-get update && apt-get install -y --no-install-recommends nodejs yarn python3 python-is-python3 diff --git a/Makefile b/Makefile index cdc55e3..37f7a6d 100644 --- a/Makefile +++ b/Makefile @@ -6,30 +6,6 @@ SHELL=/opt/homebrew/bin/bash http: bundle exec rails server -p 3002 -b 0.0.0.0 -.PHONY: build -build: - docker build -t syntaf/wetrockpolice:$(LATEST_HASH) \ - --build-arg RAILS_ENV=production \ - -f ./Dockerfile.production \ - . - -.PHONY: push -push: - docker push syntaf/wetrockpolice:$(LATEST_HASH) - -.PHONY: sync -sync: - yq -i ".image.tag = \"$$(kubectl get pods -n wetrockpolice -l app.kubernetes.io/name=wetrockpolice -o=jsonpath='{$$.items[*].spec.containers[*].image}' | head -n 1 | awk '{print $$1}' | awk -F':' '{print $$2}')\"" k8s/wetrockpolice/values.yaml - yq -i ".appVersion = \"$$(kubectl get pods -n wetrockpolice -l app.kubernetes.io/name=wetrockpolice -o=jsonpath='{$$.items[*].metadata.annotations.wetrockpolice-app-version}' | awk -F' ' '{print $$2}')\"" k8s/wetrockpolice/Chart.yaml - -.PHONY: deploy -deploy: - helm upgrade -n wetrockpolice -f secrets.yaml wetrockpolice k8s/wetrockpolice - -.PHONY: commit -commit: - echo $(LATEST_HASH) > version.txt - .PHONY: worker worker: bundle exec sidekiq -q default -q mailers @@ -71,3 +47,32 @@ init: db-create db-migrate db-seed .PHONY: reset_db reset-db: restart-pg db-drop init + +# Deployment +# -------------------------------------------------- +LATEST_HASH := $(shell cat .git/refs/heads/master) +LATEST_GIT_TAG := $(shell git describe --abbrev=0 --tags) +LATEST_CHART_VERSION := $(shell yq e '.version' k8s/wetrockpolice/Chart.yaml) + +.PHONY: build +build: + docker build -t syntaf/wetrockpolice:$(LATEST_HASH) \ + -f ./Dockerfile.production \ + . + +.PHONY: push +push: + docker push syntaf/wetrockpolice:$(LATEST_HASH) + +.PHONY: sync +sync: + yq -i ".image.tag = \"$$(kubectl get pods -n wetrockpolice -l app.kubernetes.io/name=wetrockpolice -o=jsonpath='{$$.items[*].spec.containers[*].image}' | head -n 1 | awk '{print $$1}' | awk -F':' '{print $$2}')\"" k8s/wetrockpolice/values.yaml + yq -i ".appVersion = \"$$(kubectl get pods -n wetrockpolice -l app.kubernetes.io/name=wetrockpolice -o=jsonpath='{$$.items[*].metadata.annotations.wetrockpolice-app-version}' | awk -F' ' '{print $$2}')\"" k8s/wetrockpolice/Chart.yaml + +.PHONY: deploy +deploy: + helm upgrade -n wetrockpolice -f secrets.yaml wetrockpolice k8s/wetrockpolice + +.PHONY: commit +commit: + echo $(LATEST_HASH) > version.txt \ No newline at end of file diff --git a/version.txt b/version.txt index 44e2a23..f2fd5b8 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -5246ba5bad001425d3748213dc72c3ab9d9d878b +94950b003f09b371d01e7856b44298c9e0e5b489