This repository was archived by the owner on Aug 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.sh
More file actions
48 lines (34 loc) · 1.36 KB
/
build.sh
File metadata and controls
48 lines (34 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env bash
echo "Getting dependencies"
go get -a -d ./...
echo "Building executable"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o output/docker-papertrail-log-driver
mkdir -p papertrail/rootfs
echo "Copying configs"
cp config.json papertrail/
echo "Building docker image"
docker build -t rootfsimage -f output/Dockerfile.build output/
echo "Executable cleanup"
rm -f docker-papertrail-log-driver
echo "Creating a container with the image"
id=$(docker create rootfsimage true)
echo "Exporting the container fs"
docker export "$id" > rootfs.tar
docker rm -vf "$id"
docker rmi rootfsimage
[[ -z "${CIRCLE_TAG}" ]] && tag="$(echo $CIRCLE_SHA1 | cut -c -7)" || tag="${CIRCLE_TAG}"
echo "Extracting the tar'd root fs"
sudo tar -x --owner root --group root --no-same-owner -C papertrail/rootfs < rootfs.tar
echo "Removing the tar file"
rm -f rootfs.tar
echo "Setting the plugin up"
sudo docker plugin create solarwinds/papertrail-plugin:$tag papertrail/
sudo docker plugin create solarwinds/papertrail-plugin:latest papertrail/
echo "Enabling the plugin"
docker plugin enable solarwinds/papertrail-plugin:$tag
docker plugin enable solarwinds/papertrail-plugin:latest
echo "Logging in to Docker"
docker login -u $DOCKER_USER -p $DOCKER_PASS
echo "Publishing plugin"
docker plugin push solarwinds/papertrail-plugin:$tag
docker plugin push solarwinds/papertrail-plugin:latest