-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
244 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Build | ||
description: Build vmauth image | ||
inputs: | ||
version: | ||
description: version | ||
required: true | ||
tags: | ||
description: image tags | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Build image | ||
env: | ||
OPENSEARCH_VER: ${{ inputs.version }} | ||
TAGS: ${{ inputs.tags }} | ||
run: | | ||
set -e | ||
make | ||
make test | ||
. $GITHUB_ACTION_PATH/release.sh | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
if [[ "${GITHUB_REF}" == refs/heads/main || "${GITHUB_REF}" == refs/tags/* ]]; then | ||
docker login ${DOCKER_REGISTRY} -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}" | ||
|
||
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | ||
export STABILITY_TAG="${GITHUB_REF##*/}" | ||
fi | ||
|
||
IFS=',' read -ra tags <<< "${TAGS}" | ||
|
||
for tag in "${tags[@]}"; do | ||
make release TAG="${tag}"; | ||
done | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Build docker image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
tags: | ||
- '*' | ||
|
||
env: | ||
DOCKER_REGISTRY: ghcr.io | ||
DOCKER_USERNAME: ${{ github.actor }} | ||
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
vmauth-1: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: ./.github/actions | ||
with: | ||
version: '1.93.11' | ||
tags: 1.93.11,1.93,1,latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea | ||
*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
ARG VMAUTH_VER | ||
|
||
FROM victoriametrics/vmauth:v${VMAUTH_VER} | ||
|
||
ARG TARGETPLATFORM | ||
|
||
RUN set -xe; \ | ||
apk add --update --no-cache \ | ||
bash \ | ||
make \ | ||
curl \ | ||
su-exec \ | ||
util-linux; \ | ||
\ | ||
dockerplatform=${TARGETPLATFORM:-linux/amd64};\ | ||
gotpl_url="https://github.com/wodby/gotpl/releases/download/0.3.3/gotpl-${TARGETPLATFORM/\//-}.tar.gz"; \ | ||
wget -O- "${gotpl_url}" | tar xz --no-same-owner -C /usr/local/bin; \ | ||
\ | ||
rm -rf /tmp/*; \ | ||
rm -rf /var/cache/apk/* | ||
|
||
COPY templates /etc/gotpl/ | ||
COPY bin /usr/local/bin/ | ||
|
||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
-include env_make | ||
|
||
VMAUTH_VER ?= 1.93.11 | ||
VMAUTH_MINOR_VER=$(shell echo "${VMAUTH_VER}" | grep -oE '^[0-9]+\.[0-9]+') | ||
|
||
# Remove minor version from tag | ||
TAG ?= $(VMAUTH_MINOR_VER) | ||
|
||
ifneq ($(STABILITY_TAG),) | ||
ifneq ($(TAG),latest) | ||
override TAG := $(TAG)-$(STABILITY_TAG) | ||
endif | ||
endif | ||
|
||
REPO = ghcr.io/ramsalt/vmauth | ||
NAME = vmauth-$(VMAUTH_MINOR_VER) | ||
|
||
ENV = -e VICTORIA_METRICS_TOKEN=test-token | ||
|
||
.PHONY: build test push shell run start stop logs clean release | ||
|
||
default: build | ||
|
||
build: | ||
docker build -t $(REPO):$(TAG) \ | ||
--build-arg VMAUTH_VER=$(VMAUTH_VER) \ | ||
./ | ||
|
||
test: | ||
cd ./tests && IMAGE=$(REPO):$(TAG) NAME=$(NAME) VMAUTH_VER=$(VMAUTH_VER) ./run.sh | ||
|
||
push: | ||
docker push $(REPO):$(TAG) | ||
|
||
shell: | ||
docker run --rm --name $(NAME) -i -t $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) /bin/bash | ||
|
||
run: | ||
docker run --rm -it --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) $(CMD) | ||
|
||
start: | ||
docker run -d --name $(NAME) $(PORTS) $(VOLUMES) $(ENV) $(REPO):$(TAG) | ||
|
||
stop: | ||
docker stop $(NAME) | ||
|
||
logs: | ||
docker logs $(NAME) | ||
|
||
clean: | ||
-docker rm -f $(NAME) | ||
|
||
release: build push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# vmauth | ||
|
||
Victoriametric vmauth container with custom config file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.PHONY: check-ready check-live | ||
|
||
host ?= localhost | ||
max_try ?= 1 | ||
wait_seconds ?= 1 | ||
delay_seconds ?= 0 | ||
command = curl -s -o /dev/null -H 'Authorization: Bearer ${VICTORIA_METRICS_TOKEN}' -I -w '%{http_code}' http://${host}:8427/debug/pprof/ | grep -q 200 | ||
service = vmauth | ||
|
||
default: check-ready | ||
|
||
check-ready: | ||
wait_for "$(command)" $(service) $(host) $(max_try) $(wait_seconds) $(delay_seconds) | ||
|
||
check-live: | ||
@echo "OK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env sh | ||
set -e | ||
|
||
if [[ -n "${DEBUG}" ]]; then | ||
set -x | ||
fi | ||
|
||
mkdir -p /etc/vmauth | ||
gotpl "/etc/gotpl/config.yml.tmpl" > /etc/vmauth/config.yml | ||
|
||
if [[ "${1}" == 'make' ]]; then | ||
exec "${@}" -f /usr/local/bin/actions.mk | ||
else | ||
exec /vmauth-prod -auth.config=/etc/vmauth/config.yml "${@}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
if [[ -n "${DEBUG}" ]]; then | ||
set -x | ||
fi | ||
|
||
if [ "$#" -lt 6 ]; then | ||
echo "Illegal number of parameters" | ||
fi | ||
|
||
started=0 | ||
command=$1 | ||
service=$2 | ||
host=$3 | ||
max_try=$4 | ||
wait_seconds=$5 | ||
delay_seconds=$6 | ||
|
||
sleep "${delay_seconds}" | ||
|
||
for i in $(seq 1 "${max_try}"); do | ||
if eval "${command}"; then | ||
started=1 | ||
break | ||
fi | ||
echo "${service} is starting..." | ||
sleep "${wait_seconds}" | ||
done | ||
|
||
if [[ "${started}" -eq '0' ]]; then | ||
echo >&2 "Error. ${service} is unreachable." | ||
exit 1 | ||
fi | ||
|
||
echo "${service} has started!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
users: | ||
- bearer_token: {{ getenv "VICTORIA_METRICS_TOKEN" }} | ||
url_prefix: | ||
- {{ getenv "VICTORIA_METRICS_URL" "http://victoria-metrics:8428/" }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: "2" | ||
|
||
services: | ||
vmetrics: | ||
environment: | ||
VICTORIA_METRICS_TOKEN: test-token | ||
image: victoriametrics/victoria-metrics:v$VMAUTH_VER | ||
|
||
vmauth: | ||
environment: | ||
VICTORIA_METRICS_TOKEN: test-token | ||
VICTORIA_METRICS_URL: http://tests-vmetrics-1:8428/ | ||
image: $IMAGE | ||
depends_on: | ||
- vmetrics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
if [[ -n "${DEBUG}" ]]; then | ||
set -x | ||
fi | ||
|
||
docker compose up -d | ||
docker compose exec -T vmauth make check-ready wait_seconds=5 max_try=30 -f /usr/local/bin/actions.mk | ||
docker compose down |