Skip to content

Commit

Permalink
PostgreSQL Cluster Console (UI/API) (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks authored Aug 18, 2024
1 parent 1cf159e commit 23d0219
Show file tree
Hide file tree
Showing 714 changed files with 23,531 additions and 334 deletions.
91 changes: 79 additions & 12 deletions .config/make/docker.mak
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,89 @@
TAG ?= local
DOCKER_REGISTRY ?= vitabaks

.PHONY: docker-build
docker-build: ## Run docker build image (example: make docker-build TAG=my_tag)
@echo "Building container image with tag $(TAG)";
docker build --no-cache --tag postgresql_cluster:$(TAG) --file Dockerfile .

.PHONY: docker-push
docker-push: ## Push image to Dockerhub (example: make docker-push TAG=my_tag DOCKER_REGISTRY=my_repo DOCKER_REGISTRY_USER="my_username" DOCKER_REGISTRY_PASSWORD="my_password")
@echo "Pushing container image with tag $(TAG)";
.PHONY: docker-lint docker-lint-console-ui docker-lint-console-api docker-lint-console-db docker-lint-console
docker-lint: docker-lint-automation docker-lint-console-ui docker-lint-console-api docker-lint-console-db docker-lint-console ## Lint all Dockerfiles

docker-lint-automation: ## Lint automation Dockerfile
@echo "Lint automation container Dockerfile"
docker run --rm -i -v $(PWD)/automation/Dockerfile:/Dockerfile \
hadolint/hadolint hadolint --ignore DL3002 --ignore DL3008 --ignore DL3059 /Dockerfile

docker-lint-console-ui: ## Lint console ui Dockerfile
@echo "Lint console ui container Dockerfile"
docker run --rm -i -v $(PWD)/console/ui/Dockerfile:/Dockerfile \
hadolint/hadolint hadolint --ignore DL3002 --ignore DL3008 --ignore DL3059 /Dockerfile

docker-lint-console-api: ## Lint console api Dockerfile
@echo "Lint console api container Dockerfile"
docker run --rm -i -v $(PWD)/console/service/Dockerfile:/Dockerfile \
hadolint/hadolint hadolint --ignore DL3002 --ignore DL3008 --ignore DL3059 /Dockerfile

docker-lint-console-db: ## Lint console db Dockerfile
@echo "Lint console db container Dockerfile"
docker run --rm -i -v $(PWD)/console/db/Dockerfile:/Dockerfile \
hadolint/hadolint hadolint --ignore DL3002 --ignore DL3008 --ignore DL3059 --ignore DL4001 /Dockerfile

docker-lint-console: ## Lint console Dockerfile (all services)
@echo "Lint console container Dockerfile"
docker run --rm -i -v $(PWD)/console/Dockerfile:/Dockerfile \
hadolint/hadolint hadolint --ignore DL3002 --ignore DL3008 --ignore DL3059 --ignore DL4001 /Dockerfile

.PHONY: docker-build docker-build-console-ui docker-build-console-api docker-build-console-db docker-build-console
docker-build: docker-build-automation docker-build-console-ui docker-build-console-api docker-build-console-db docker-build-console ## Build for all Docker images

docker-build-automation: ## Build automation image
@echo "Build automation docker image with tag $(TAG)";
docker build --no-cache --platform linux/amd64 --tag postgresql_cluster:$(TAG) --file automation/Dockerfile .

docker-build-console-ui: ## Build console ui image
@echo "Build console ui docker image with tag $(TAG)"
docker build --no-cache --platform linux/amd64 --tag postgresql_cluster_console_ui:$(TAG) --file console/ui/Dockerfile .

docker-build-console-api: ## Build console api image
@echo "Build console api docker image with tag $(TAG)"
docker build --no-cache --platform linux/amd64 --tag postgresql_cluster_console_api:$(TAG) --file console/service/Dockerfile .

docker-build-console-db: ## Build console db image
@echo "Build console db docker image with tag $(TAG)"
docker build --no-cache --platform linux/amd64 --tag postgresql_cluster_console_db:$(TAG) --file console/db/Dockerfile .

docker-build-console: ## Build console image (all services)
@echo "Build console docker image with tag $(TAG)"
docker build --no-cache --platform linux/amd64 --tag postgresql_cluster_console:$(TAG) --file console/Dockerfile .

.PHONY: docker-push docker-push-console-ui docker-push-console-api docker-push-console-db docker-push-console
docker-push: docker-push-automation docker-push-console-ui docker-push-console-api docker-push-console-db docker-push-console ## Push all images to Dockerhub (example: make docker-push TAG=my_tag DOCKER_REGISTRY=my_repo DOCKER_REGISTRY_USER="my_username" DOCKER_REGISTRY_PASSWORD="my_password")

docker-push-automation: ## Push automation to Dockerhub
@echo "Push automation docker image with tag $(TAG)";
echo "$(DOCKER_REGISTRY_PASSWORD)" | docker login --username "$(DOCKER_REGISTRY_USER)" --password-stdin
docker tag postgresql_cluster:$(TAG) $(DOCKER_REGISTRY)/postgresql_cluster:$(TAG)
docker push $(DOCKER_REGISTRY)/postgresql_cluster:$(TAG)

.PHONY: docker-lint
docker-lint: ## Run hadolint command to lint Dokerfile
docker run --rm -i -v ./Dockerfile:/Dockerfile \
hadolint/hadolint hadolint --ignore DL3002 --ignore DL3008 --ignore DL3059 /Dockerfile
docker-push-console-ui: ## Push console ui image to Dockerhub
@echo "Push console ui docker image with tag $(TAG)"
echo "$(DOCKER_REGISTRY_PASSWORD)" | docker login --username "$(DOCKER_REGISTRY_USER)" --password-stdin
docker tag postgresql_cluster_console_ui:$(TAG) $(DOCKER_REGISTRY)/postgresql_cluster_console_ui:$(TAG)
docker push $(DOCKER_REGISTRY)/postgresql_cluster_console_ui:$(TAG)

docker-push-console-api: ## Push console api image to Dockerhub
@echo "Push console api docker image with tag $(TAG)"
echo "$(DOCKER_REGISTRY_PASSWORD)" | docker login --username "$(DOCKER_REGISTRY_USER)" --password-stdin
docker tag postgresql_cluster_console_api:$(TAG) $(DOCKER_REGISTRY)/postgresql_cluster_console_api:$(TAG)
docker push $(DOCKER_REGISTRY)/postgresql_cluster_console_api:$(TAG)

docker-push-console-db: ## Push console db image to Dockerhub
@echo "Push console db docker image with tag $(TAG)"
echo "$(DOCKER_REGISTRY_PASSWORD)" | docker login --username "$(DOCKER_REGISTRY_USER)" --password-stdin
docker tag postgresql_cluster_console_db:$(TAG) $(DOCKER_REGISTRY)/postgresql_cluster_console_db:$(TAG)
docker push $(DOCKER_REGISTRY)/postgresql_cluster_console_db:$(TAG)

docker-push-console: ## Push console image to Dockerhub (all services)
@echo "Push console docker image with tag $(TAG)"
echo "$(DOCKER_REGISTRY_PASSWORD)" | docker login --username "$(DOCKER_REGISTRY_USER)" --password-stdin
docker tag postgresql_cluster_console:$(TAG) $(DOCKER_REGISTRY)/postgresql_cluster_console:$(TAG)
docker push $(DOCKER_REGISTRY)/postgresql_cluster_console:$(TAG)

.PHONY: docker-tests
docker-tests: ## Run tests for docker
Expand Down
2 changes: 1 addition & 1 deletion .config/make/linters.mak
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ linter-yamllint: ## Lint YAML files using yamllint
linter-ansible-lint: ## Lint Ansible files using ansible-lint
echo "ansible-lint #########################################################"
$(ACTIVATE_VENV) && \
ansible-lint --force-color --parseable
ansible-lint --force-color --parseable ./automation

.PHONY: linter-flake8
linter-flake8: ## Lint Python files using flake8
Expand Down
26 changes: 13 additions & 13 deletions .config/make/molecule.mak
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,52 @@ ACTIVATE_VENV = . .venv/bin/activate

.PHONY: molecule-test
molecule-test: ## Run test sequence for default scenario
$(ACTIVATE_VENV) && molecule test
$(ACTIVATE_VENV) && cd automation && molecule test

.PHONY: molecule-destroy
molecule-destroy: ## Run destroy sequence for default scenario
$(ACTIVATE_VENV) && molecule destroy
$(ACTIVATE_VENV) && cd automation && molecule destroy

.PHONY: molecule-converge
molecule-converge: ## Run converge sequence for default scenario
$(ACTIVATE_VENV) && molecule converge
$(ACTIVATE_VENV) && cd automation && molecule converge

.PHONY: molecule-reconverge
molecule-reconverge: ## Run destroy and converge sequence for default scenario
$(ACTIVATE_VENV) && molecule destroy && molecule converge
$(ACTIVATE_VENV) && cd automation && molecule destroy && && molecule converge

.PHONY: molecule-test-all
molecule-test-all: ## Run test sequence for all scenarios
$(ACTIVATE_VENV) && molecule test --all
$(ACTIVATE_VENV) && cd automation && molecule test --all

.PHONY: molecule-destroy-all
molecule-destroy-all: ## Run destroy sequence for all scenarios
$(ACTIVATE_VENV) && molecule destroy --all
$(ACTIVATE_VENV) && cd automation && molecule destroy --all

.PHONY: molecule-test-scenario
molecule-test-scenario: ## Run molecule test with specific scenario (example: make molecule-test-scenario MOLECULE_SCENARIO="scenario_name")
$(ACTIVATE_VENV) && molecule test --scenario-name $(MOLECULE_SCENARIO)
$(ACTIVATE_VENV) && cd automation && molecule test --scenario-name $(MOLECULE_SCENARIO)

.PHONY: molecule-destroy-scenario
molecule-destroy-scenario: ## Run molecule destroy with specific scenario (example: make molecule-destroy-scenario MOLECULE_SCENARIO="scenario_name")
$(ACTIVATE_VENV) && molecule destroy --scenario-name $(MOLECULE_SCENARIO)
$(ACTIVATE_VENV) && cd automation && molecule destroy --scenario-name $(MOLECULE_SCENARIO)

.PHONY: molecule-converge-scenario
molecule-converge-scenario: ## Run molecule converge with specific scenario (example: make molecule-converge-scenario MOLECULE_SCENARIO="scenario_name")
$(ACTIVATE_VENV) && molecule converge --scenario-name $(MOLECULE_SCENARIO)
$(ACTIVATE_VENV) && cd automation && molecule converge --scenario-name $(MOLECULE_SCENARIO)

.PHONY: molecule-dependency
molecule-dependency: ## Run dependency sequence
$(ACTIVATE_VENV) && molecule dependency
$(ACTIVATE_VENV) && cd automation && molecule dependency

.PHONY: molecule-verify
molecule-verify: ## Run verify sequence
$(ACTIVATE_VENV) && molecule verify
$(ACTIVATE_VENV) && cd automation && molecule verify

.PHONY: molecule-login
molecule-login: ## Log in to one instance using custom host IP (example: make molecule-login MOLECULE_HOST="10.172.0.20")
$(ACTIVATE_VENV) && molecule login --host $(MOLECULE_HOST)
$(ACTIVATE_VENV) && cd automation && molecule login --host $(MOLECULE_HOST)

.PHONY: molecule-login-scenario
molecule-login-scenario: ## Log in to one instance using custom host IP and scenario name (example: make molecule-login-scenario MOLECULE_HOST="10.172.1.20" MOLECULE_SCENARIO="scenario_name")
$(ACTIVATE_VENV) && molecule login --host $(MOLECULE_HOST) --scenario-name $(MOLECULE_SCENARIO)
$(ACTIVATE_VENV) && cd automation && molecule login --host $(MOLECULE_HOST) --scenario-name $(MOLECULE_SCENARIO)
2 changes: 1 addition & 1 deletion .config/make/python.mak
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Python default launcher
python_launcher ?= python3.10
python_requirements_file ?= requirements.txt
python_requirements_file ?= automation/requirements.txt
python_requirements_dev_file ?= .config/python/dev/requirements.txt

# Activate virtual environment
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,21 @@ jobs:
run: echo "TERM=xterm" >> $GITHUB_ENV

- name: Extract branch or tag name
shell: bash
run: |
REF_NAME=""
if [[ -n "${GITHUB_HEAD_REF}" ]]; then
# This is a PR, use the source branch name
REF_NAME="${GITHUB_HEAD_REF}"
echo "REF_NAME=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
else
# This is a push, use the branch or tag name from GITHUB_REF
REF_NAME="${GITHUB_REF##*/}"
echo "REF_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV
fi
# If this is the master branch, use 'latest' as the tag, otherwise use the REF_NAME
if [[ "$REF_NAME" == "master" ]]; then
- name: Set TAG
run: |
if [[ "${{ env.REF_NAME }}" == "master" ]]; then
echo "TAG=latest" >> $GITHUB_ENV
else
echo "TAG=$REF_NAME" >> $GITHUB_ENV
echo "TAG=${{ env.REF_NAME }}" >> $GITHUB_ENV
fi
- name: Checkout
Expand Down
Loading

0 comments on commit 23d0219

Please sign in to comment.