-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release 2.2
- Loading branch information
Showing
36 changed files
with
905 additions
and
149 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 |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
venv | ||
.docker_data | ||
__pycache__ | ||
.pytest_cache |
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,26 @@ | ||
language: python | ||
|
||
services: | ||
- docker | ||
|
||
|
||
jobs: | ||
include: | ||
- stage: test | ||
if: (type IN (pull_request)) | ||
install: | ||
- pip install -r requirements.txt | ||
script: | ||
- pytest -s tests/ | ||
|
||
- stage: build docker | ||
if: (branch = master) AND (NOT (type IN (pull_request))) | ||
install: | ||
- docker pull byjg/k8s-ci | ||
script: | ||
- docker run --privileged -v /tmp/z:/var/lib/containers -it --rm -v $PWD:/work -w /work -e DOCKER_USERNAME=$DOCKER_USERNAME -e DOCKER_PASSWORD=$DOCKER_PASSWORD -e DOCKER_REGISTRY=$DOCKER_REGISTRY byjg/k8s-ci /work/build-multiarch.sh | ||
|
||
- stage: documentation | ||
if: (branch = master) AND (NOT (type IN (pull_request))) | ||
install: skip | ||
script: "curl https://opensource.byjg.com/add-doc.sh | bash /dev/stdin devops docker-easy-haproxy" |
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 |
---|---|---|
@@ -1,18 +1,21 @@ | ||
FROM haproxy:2.1-alpine | ||
FROM alpine:3.14 | ||
|
||
WORKDIR /scripts | ||
|
||
RUN apk add --no-cache bash python3 py-yaml supervisor docker | ||
RUN apk add --no-cache haproxy bash python3 py3-pip py-yaml supervisor docker \ | ||
&& ln -s /usr/bin/python3 /usr/bin/python | ||
|
||
COPY requirements.txt /scripts | ||
|
||
RUN pip3 install --upgrade pip \ | ||
&& pip install -r requirements.txt | ||
|
||
COPY swarm.* /scripts/ | ||
COPY static.* /scripts/ | ||
COPY templates /scripts/templates/ | ||
COPY easymapping /scripts/easymapping/ | ||
COPY tests/ /scripts/tests/ | ||
|
||
COPY assets / | ||
|
||
RUN pytest -s tests/ | ||
|
||
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf" ] |
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,7 @@ | ||
.PHONY: build | ||
build: | ||
docker build -t byjg/easy-haproxy -t byjg/easy-haproxy:local . | ||
|
||
.PHONY: test | ||
test: | ||
pytest tests/ |
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
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
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
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
File renamed without changes.
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 @@ | ||
import os | ||
from easymapping import HaproxyConfigGenerator | ||
|
||
# path = os.path.dirname(os.path.realpath(__file__)) | ||
with open("/tmp/.docker_data", 'r') as content_file: | ||
lineList = content_file.readlines() | ||
|
||
result = { | ||
"customerrors": True if os.getenv("HAPROXY_CUSTOMERRORS") == "true" else False | ||
} | ||
|
||
if os.getenv("HAPROXY_PASSWORD"): | ||
result["stats"] = { | ||
"username": os.getenv("HAPROXY_USERNAME") if os.getenv("HAPROXY_USERNAME") else "admin", | ||
"password": os.getenv("HAPROXY_PASSWORD"), | ||
"port": os.getenv("HAPROXY_STATS_PORT") if os.getenv("HAPROXY_STATS_PORT") else "1936", | ||
} | ||
|
||
cfg = HaproxyConfigGenerator(result) | ||
print(cfg.generate(lineList)) | ||
|
||
# print(jsonStr) | ||
|
||
|
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,33 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Start k8s-ci before run this command | ||
# docker run --privileged -v /tmp/z:/var/lib/containers -it --rm -v $PWD:/work -w /work byjg/k8s-ci | ||
|
||
if [ -z "$DOCKER_USERNAME" ] || [ -z "$DOCKER_PASSWORD" ] || [ -z "$DOCKER_REGISTRY" ] | ||
then | ||
echo You need to setup \$DOCKER_USERNAME, \$DOCKER_PASSWORD and \$DOCKER_REGISTRY before run this command. | ||
exit 1 | ||
fi | ||
|
||
buildah login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD $DOCKER_REGISTRY | ||
|
||
podman run --rm --events-backend=file --cgroup-manager=cgroupfs --privileged docker://multiarch/qemu-user-static --reset -p yes | ||
|
||
VERSIONS="latest $TRAVIS_TAG" | ||
for VERSION in $VERSIONS | ||
do | ||
DOCKERFILE=Dockerfile | ||
|
||
buildah manifest create byjg/easy-haproxy:$VERSION | ||
|
||
buildah bud --arch arm64 --os linux --iidfile /tmp/iid-arm64 -f $DOCKERFILE -t byjg/easy-haproxy:$VERSION-arm64 . | ||
buildah bud --arch amd64 --os linux --iidfile /tmp/iid-amd64 -f $DOCKERFILE -t byjg/easy-haproxy:$VERSION-amd64 . | ||
|
||
buildah manifest add byjg/easy-haproxy:$VERSION --arch arm64 --os linux --variant v8 $(cat /tmp/iid-arm64) | ||
buildah manifest add byjg/easy-haproxy:$VERSION --arch amd64 --os linux --os=linux $(cat /tmp/iid-amd64) | ||
|
||
buildah manifest push --all --format v2s2 byjg/easy-haproxy:$VERSION docker://byjg/easy-haproxy:$VERSION | ||
done | ||
|
Oops, something went wrong.