Skip to content

Commit

Permalink
ci: build/release docker containers automatically
Browse files Browse the repository at this point in the history
Signed-off-by: Salim Afiune Maya <[email protected]>
  • Loading branch information
afiune committed Jun 9, 2020
1 parent 609eeb7 commit 897b05a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ jobs:
message: Releasing a new version of the go-sdk repository
- run: make prepare
- run: scripts/release.sh publish
- setup_remote_docker
- run: scripts/release_containers.sh
- slack/status:
fail_only: true
fail_only: false
mentions: << pipeline.parameters.slack-mentions >>
#- run: scripts/release_containers.sh
notify-slack-status:
executor: alpine
steps:
Expand Down
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,9 @@ else
endif
@echo "\nThe lacework cli has been installed at /usr/local/bin"

release-prepare: lint test fmt-check imports-check build-cli-cross-platform
release: lint test fmt-check imports-check build-cli-cross-platform
scripts/release.sh prepare

release-containers:
scripts/release_containers.sh

install-tools:
ifeq (, $(shell which golangci-lint))
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v$(GOLANGCILINTVERSION)
Expand Down
2 changes: 1 addition & 1 deletion scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ compress_targets() {
_cli_name="bin/${binary_name}"
fi

mv "bin/${target}" "$_cli_name"
cp "bin/${target}" "$_cli_name"

if [[ "$target" =~ linux ]]; then
_target_with_ext="bin/${target}.tar.gz"
Expand Down
15 changes: 13 additions & 2 deletions scripts/release_containers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@ log() {
echo "--> ${project_name}: $1"
}

# Make sure we have the binary needed for the SCRATCH container
if [ ! -f "bin/lacework-cli-linux-amd64" ]; then
log "building Lacework CLI cross-platform"
make build-cli-cross-platform
fi

log "building Lacework CLI cross-platform"
make build-cli-cross-platform
# Enable docker experimental mode
log "enabling experimental mode to use/upload docker manifest"
mkdir -p ~/.docker
echo '{"experimental": "enabled"}' > ~/.docker/config.json

# Authenticate to dockerhub
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin

log "releasing container from SCRATCH"
docker build -t "${repository}:scratch" --no-cache .
Expand All @@ -30,6 +40,7 @@ distros=(
amazonlinux-2
# windows-nanoserver
)

for dist in "${distros[@]}"; do
log "releasing container for ${dist}"
docker build -f "cli/images/${dist}/Dockerfile" --no-cache -t "${repository}:${dist}" .
Expand Down

0 comments on commit 897b05a

Please sign in to comment.