Skip to content

Commit a97f78f

Browse files
committed
Adjust build paths to not overlap
1 parent 6d4b0ed commit a97f78f

File tree

7 files changed

+15
-12
lines changed

7 files changed

+15
-12
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/.cache
22
/bin
3+
/build
34
/dist
45
*.swp
56
.idea

docs/developing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ If you don't want to run all the steps in CI every time you make a change, you c
102102
REPO=<my-repo>
103103
TAG=<my-tag>
104104

105-
./scripts/build-chart && GOOS=linux CGO_ENABLED=0 go build -ldflags "-extldflags -static -s" -o bin/prometheus-federator && REPO=${REPO} TAG=${TAG} make package
105+
./scripts/build-chart && GOOS=linux CGO_ENABLED=0 go build -ldflags "-extldflags -static -s" -o build/bin/prometheus-federator && REPO=${REPO} TAG=${TAG} make package
106106
```
107107

108108
Once the image is successfully packaged, simply run `docker push ${REPO}/prometheus-federator:${TAG}` to push your image to your Docker repository.

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var (
2929
// SystemNamespaces is the system namespaces scoped for the embedded monitoring chart (rancher-project-monitoring)
3030
SystemNamespaces = []string{"kube-system", "cattle-monitoring-system", "cattle-dashboards"}
3131

32-
//go:embed bin/rancher-project-monitoring/rancher-project-monitoring.tgz.base64
32+
//go:embed build/chart/rancher-project-monitoring.tgz.base64
3333
base64TgzChart string
3434

3535
debugConfig command.DebugConfig

package/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ RUN echo 'prometheus:x:1000:1000::/home/prometheus:/bin/bash' >> /etc/passwd &&
4040
mkdir /home/prometheus && \
4141
chown -R prometheus:prometheus /home/prometheus
4242
COPY --from=helm ./helm/bin/helm /usr/local/bin/
43-
COPY --from=builder /usr/src/app/bin/prometheus-federator /usr/bin/
43+
COPY --from=builder /usr/src/app/build/bin/prometheus-federator /usr/bin/
4444
USER prometheus
4545
CMD ["prometheus-federator"]

scripts/build

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ cd $(dirname $0)/..
99

1010
echo "Starting \`prometheus-federator\` binary build:";
1111

12-
mkdir -p bin
12+
mkdir -p build/bin
1313
if [ "$(uname)" = "Linux" ]; then
1414
OTHER_LINKFLAGS="-extldflags -static -s"
1515
fi
@@ -30,18 +30,18 @@ fi
3030
echo "Building for Arch(s): ${ARCHES[*]}"
3131

3232
for A in "${ARCHES[@]}" ; do
33-
GOARCH="$A" CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o "bin/prometheus-federator-$A"
33+
GOARCH="$A" CGO_ENABLED=0 go build -ldflags "$LINKFLAGS $OTHER_LINKFLAGS" -o "build/bin/prometheus-federator-$A"
3434
# Set CROSS to build for other OS'es
3535
if [ "$CROSS" = "true" ]; then
3636
for OS in darwin windows ; do
37-
GOARCH="$A" GOOS=$OS go build -ldflags "$LINKFLAGS" -o "bin/prometheus-federator-$OS-$A"
37+
GOARCH="$A" GOOS=$OS go build -ldflags "$LINKFLAGS" -o "build/bin/prometheus-federator-$OS-$A"
3838
echo "Built \`prometheus-federator-$OS-$A\`"
3939
done
4040
fi
4141
done
4242

43-
cd bin
43+
cd build/bin
4444
ln -sf "./prometheus-federator-$ARCH" "./prometheus-federator"
45-
cd ..
45+
cd ../..
4646

4747
echo "Completed \`prometheus-federator\` binary build."

scripts/build-chart

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ cd $(dirname $0)/..
88
CHART=${CHART:-rancher-project-monitoring}
99
VERSION=${EMBEDED_CHART_VERSION:-$(find ./charts/${CHART} -maxdepth 1 -mindepth 1 -type d | tr - \~ | sort -rV | tr \~ - | head -n1 | cut -d'/' -f4)}
1010

11-
helm package charts/${CHART}/${VERSION} --destination bin/${CHART}
12-
base64 -i bin/${CHART}/${CHART}-${VERSION}.tgz > bin/${CHART}/${CHART}.tgz.base64
13-
rm bin/${CHART}/${CHART}-${VERSION}.tgz
11+
mkdir -p build/bin
12+
13+
helm package charts/${CHART}/${VERSION} --destination build/chart
14+
base64 -i build/chart/${CHART}-${VERSION}.tgz > build/chart/${CHART}.tgz.base64
15+
rm build/chart/${CHART}-${VERSION}.tgz
1416

1517
echo "Completed ${CHART} (${VERSION}) build process."

scripts/package

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cd $(dirname $0)/..
88
echo "Starting \`prometheus-federator\` packaging:";
99

1010
mkdir -p dist/artifacts
11-
cp bin/prometheus-federator dist/artifacts/prometheus-federator${SUFFIX}
11+
cp build/bin/prometheus-federator dist/artifacts/prometheus-federator${SUFFIX}
1212

1313
IMAGE=${REPO}/prometheus-federator:${TAG}
1414
DOCKERFILE=package/Dockerfile

0 commit comments

Comments
 (0)