mirror of
https://github.com/gomods/athens
synced 2026-02-03 11:00:32 +00:00
Publish charts to azure storage (#1097)
* Add chart-push target and script * Rename chart dir to match helm standards
This commit is contained in:
committed by
Aaron Schlesinger
parent
7bf99e1e6e
commit
d379c20f44
+2
-2
@@ -15,6 +15,7 @@ env:
|
||||
- CODE_COV=1
|
||||
- ATHENS_DIR=${GOPATH}/src/github.com/gomods/athens
|
||||
- REGISTRY=gomods/
|
||||
- CHARTS_REPO=https://athens.blob.core.windows.net
|
||||
- GORELEASER_ON=1
|
||||
- GO111MODULE=on
|
||||
|
||||
@@ -37,8 +38,7 @@ before_deploy:
|
||||
|
||||
deploy:
|
||||
- provider: script
|
||||
script: make docker-push
|
||||
script: make docker-push charts-push
|
||||
on:
|
||||
repo: gomods/athens
|
||||
all_branches: true
|
||||
|
||||
|
||||
@@ -7,8 +7,14 @@ build:
|
||||
build-ver:
|
||||
GO111MODULE=on CGO_ENABLED=0 go build -mod=vendor -ldflags "-X github.com/gomods/athens/pkg/build.version=$(VERSION) -X github.com/gomods/athens/pkg/build.buildDate=$(DATE)" -o athens ./cmd/proxy
|
||||
|
||||
# The build-image step creates a docker image that has all the tools required
|
||||
# to perform some CI build steps, instead of relying on them being installed locally
|
||||
.PHONY: build-image
|
||||
build-image:
|
||||
docker build -t athens-build ./scripts/build-image
|
||||
|
||||
.PHONY: run
|
||||
run:
|
||||
run:
|
||||
cd ./cmd/proxy && go run . -config_file ../../config.dev.toml
|
||||
|
||||
.PHONY: docs
|
||||
@@ -60,6 +66,14 @@ proxy-docker:
|
||||
docker-push:
|
||||
./scripts/push-docker-images.sh
|
||||
|
||||
.PHONY: charts-push
|
||||
charts-push: build-image
|
||||
docker run --rm -it \
|
||||
-v `pwd`:/go/src/github.com/gomods/athens \
|
||||
-e AZURE_STORAGE_CONNECTION_STRING \
|
||||
-e CHARTS_REPO \
|
||||
athens-build ./scripts/push-helm-charts.sh
|
||||
|
||||
bench:
|
||||
./scripts/benchmark.sh
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
FROM golang:1.12-stretch
|
||||
|
||||
WORKDIR /tmp
|
||||
|
||||
# Install Helm
|
||||
ENV HELM_VERSION=2.13.0
|
||||
RUN curl -sLO https://kubernetes-helm.storage.googleapis.com/helm-v${HELM_VERSION}-linux-amd64.tar.gz && \
|
||||
tar -zxvf helm-v${HELM_VERSION}-linux-amd64.tar.gz && \
|
||||
mv linux-amd64/helm /usr/local/bin/
|
||||
|
||||
# Install a tiny azure client
|
||||
ENV AZCLI_VERSION=v0.3.1
|
||||
RUN curl -sLo /usr/local/bin/az https://github.com/carolynvs/az-cli/releases/download/$AZCLI_VERSION/az-linux-amd64 && \
|
||||
chmod +x /usr/local/bin/az
|
||||
|
||||
WORKDIR /go/src/github.com/gomods/athens
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -xeuo pipefail
|
||||
|
||||
helm init --client-only
|
||||
|
||||
#####
|
||||
# set up the repo dir, and package up all charts
|
||||
#####
|
||||
CHARTS_REPO=${CHARTS_REPO:-"https://athens.blob.core.windows.net"}
|
||||
CHARTS_BUCKET=charts
|
||||
REPO_DIR=bin/charts # This is where we do the charge merge and dirty things up, not the source chart directory
|
||||
mkdir -p $REPO_DIR
|
||||
echo "entering $REPO_DIR"
|
||||
cd $REPO_DIR
|
||||
if curl --output /dev/null --silent --head --fail ${CHARTS_REPO}/${CHARTS_BUCKET}/index.yaml; then
|
||||
echo "downloading existing index.yaml"
|
||||
curl -sLO ${CHARTS_REPO}/${CHARTS_BUCKET}/index.yaml
|
||||
fi
|
||||
|
||||
#####
|
||||
# package the charts
|
||||
#####
|
||||
for dir in `ls ../../charts`;do
|
||||
if [ ! -f ../../charts/$dir/Chart.yaml ];then
|
||||
echo "skipping $dir because it lacks a Chart.yaml file"
|
||||
else
|
||||
echo "packaging $dir"
|
||||
helm dep build ../../charts/$dir
|
||||
helm package ../../charts/$dir
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -f $REPO_DIR/index.yaml ]; then
|
||||
echo "merging with existing index.yaml"
|
||||
helm repo index --url "$CHARTS_REPO/$CHARTS_BUCKET" --merge index.yaml .
|
||||
else
|
||||
echo "generating new index.yaml"
|
||||
helm repo index .
|
||||
fi
|
||||
|
||||
#####
|
||||
# upload to Azure blob storage
|
||||
#####
|
||||
if [ ! -v AZURE_STORAGE_CONNECTION_STRING ]; then
|
||||
echo "AZURE_STORAGE_CONNECTION_STRING env var required to publish"
|
||||
exit 1
|
||||
fi
|
||||
echo "uploading from $PWD"
|
||||
az storage blob upload-batch --destination $CHARTS_BUCKET --source .
|
||||
Reference in New Issue
Block a user