Compare commits

...

12 Commits

Author SHA1 Message Date
b4593002cb latest
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-09 00:40:53 +01:00
91981777fa adding git to pkgs - how did i forget this??
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-09 00:23:51 +01:00
95aa8bb96a latest
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-09 01:11:40 +04:00
69b806fcf5 tag shell scripting
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-09 00:22:03 +04:00
d1803218f9 tag with 7 char git short hash
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-09 00:13:56 +04:00
8d7c40edcb networkmode bridge required for working dns :(
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-08 23:50:38 +04:00
8368dbff82 remove modcache
Some checks failed
continuous-integration/drone/push Build is failing
2022-12-08 23:49:42 +04:00
ab8c0463bf disable networkmode bridge
Some checks failed
continuous-integration/drone/push Build is failing
2022-12-08 23:48:01 +04:00
b970f90af6 add credentials for dockerhub
Some checks failed
continuous-integration/drone/push Build is failing
2022-12-08 23:43:43 +04:00
e63d1d9e48 enable buildkit
Some checks failed
continuous-integration/drone/push Build is failing
2022-12-08 23:42:46 +04:00
d0ac917964 add build status badge
Some checks failed
continuous-integration/drone/push Build is failing
2022-12-08 23:38:55 +04:00
a18508ba20 update README 2022-12-08 22:53:31 +04:00
5 changed files with 87 additions and 37 deletions

View File

@@ -3,17 +3,27 @@ kind: pipeline
name: build-and-upload name: build-and-upload
steps: steps:
- name: build-and-push - name: send-tags-to-tags-file
image: alpine
when:
event:
- push
- pull_request
commands:
- echo -n "latest-$(uname -m), $(date +'%Y-%m-%d')-$(uname -m), ${DRONE_COMMIT_SHA:0:7}-$(uname -m), ${DRONE_BRANCH}-$(uname -m)" > .tags
- name: build-and-push
image: plugins/docker image: plugins/docker
environment:
DOCKER_BUILDKIT: 1
network_mode: bridge network_mode: bridge
settings: settings:
repo: sneak/builder repo: sneak/builder
custom_dns: [ 116.202.204.30 ] force_tag: true
tags: username:
- ${DRONE_COMMIT_SHA} from_secret: DOCKER_USERNAME
- ${DRONE_BRANCH} password:
- latest from_secret: DOCKER_TOKEN
- name: notify - name: notify
image: plugins/slack image: plugins/slack
settings: settings:
webhook: webhook:

View File

@@ -13,6 +13,7 @@ RUN --mount=type=cache,target=/var/cache/apt \
--install-recommends \ --install-recommends \
build-essential \ build-essential \
curl \ curl \
git \
jq \ jq \
make \ make \
pv \ pv \
@@ -34,8 +35,6 @@ RUN rm -rf /usr/local/go && \
tar -C /usr/local -xzf go*.linux-$(uname -m).tar.gz && \ tar -C /usr/local -xzf go*.linux-$(uname -m).tar.gz && \
echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile
RUN mkdir -p "$(go env GOMODCACHE)" && cd $(go env GOMODCACHE) && tar xvf /tmp/modcache.tar && rm /tmp/modcache.tar && cd /tmp
RUN \ RUN \
go install -v google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1 && \ go install -v google.golang.org/protobuf/cmd/protoc-gen-go@v1.28.1 && \
go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1 && \ go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1 && \

View File

@@ -5,6 +5,7 @@ ARCH := $(shell uname -m)
GITREV := $(shell git describe --always --dirty=-dirty) GITREV := $(shell git describe --always --dirty=-dirty)
D := $(HOME)/Documents/_SYSADMIN/docker/sneak/$(APPNAME) D := $(HOME)/Documents/_SYSADMIN/docker/sneak/$(APPNAME)
BRANCH := $(shell git branch --show-current) BRANCH := $(shell git branch --show-current)
YYYYMMDD := $(shell date -u +%Y-%m-%d)
RN := sneak/builder RN := sneak/builder
export DOCKER_IMAGE_CACHE_DIR := $(HOME)/Library/Caches/Docker/$(APPNAME)-$(ARCH) export DOCKER_IMAGE_CACHE_DIR := $(HOME)/Library/Caches/Docker/$(APPNAME)-$(ARCH)
@@ -15,33 +16,33 @@ default: save
clean: clean:
rm -v $(D)/*.tzst rm -v $(D)/*.tzst
build: deps/modcache.tar build:
docker build \ docker build \
-t $(RN):$(GITREV) \ -t $(RN):$(GITREV)-$(shell uname -m) \
-t $(RN):latest \ -t $(RN):latest-$(shell uname -m) \
-t $(RN):$(shell git branch --show-current) \ -t $(RN):$(YYYYMMDD)-$(shell uname -m) \
-t $(RN):$(BRANCH)-$(shell uname -m) \
--progress plain --build-arg GITREV=$(GITREV) . --progress plain --build-arg GITREV=$(GITREV) .
save: $(D)/latest.tzst $(D)/$(BRANCH).tzst save: $(D)/latest.tzst $(D)/$(BRANCH).tzst
$(D)/$(BRANCH).tzst: $(D)/$(GITREV).tzst $(D)/$(BRANCH).tzst: $(D)/$(GITREV)-$(shell uname -m).tzst
rm -f $@ rm -f $@
ln -s $(D)/$(GITREV).tzst $@ ln -s $(D)/$(GITREV)-$(shell uname -m).tzst $@
$(D)/latest.tzst: $(D)/$(GITREV).tzst $(D)/latest.tzst: $(D)/$(GITREV)-$(shell uname -m).tzst
rm -f $@ rm -f $@
ln -s $(D)/$(GITREV).tzst $@ ln -s $(D)/$(GITREV)-$(shell uname -m).tzst $@
$D/$(GITREV).tzst: build $D/$(GITREV)-$(shell uname -m).tzst: build
docker image inspect $(RN):$(GITREV) docker image inspect $(RN):$(GITREV)-$(shell uname -m)
-mkdir -p "$(D)" -mkdir -p "$(D)"
docker save $(RN):$(GITREV) | pv | zstdmt -19 > $@.tmp docker save $(RN):$(GITREV)-$(shell uname -m) | pv | zstdmt -19 > $@.tmp
mv $@.tmp $@ mv $@.tmp $@
push: push:
docker push $(RN):$(GITREV) docker push $(RN):$(GITREV)-$(shell uname -m)
docker push $(RN):latest docker push $(RN):latest-$(shell uname -m)
docker push $(RN):$(shell git branch --show-current) docker push $(RN):$(BRANCH)-$(shell uname -m)
docker push $(RN):$(YYYYMMDD)-$(shell uname -m)
deps/modcache.tar:
cd $(shell go env GOMODCACHE)/ && tar -c . | pv > $(PWD)/deps/modcache.tar

View File

@@ -1,3 +1,20 @@
# builder # builder
docker base image [![Build Status](https://drone.datavi.be/api/badges/sneak/builder/status.svg)](https://drone.datavi.be/sneak/builder)
docker base image for building golang
TBD: javascript/node support (in progress)
TBD: python3 support
TBD: ruby support
# goals
* try to put as much stuff as possible in this base image to minimize
network usage of child image builds
# license
WTFPL

23
tagimage.sh Normal file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
set -euox pipefail
if [[ "$(uname -m)" != "arm64" ]]; then
echo "wrong box, run on macOS arm workstation after CI" > /dev/stderr
exit 1
fi
GITREV="$(git describe --always --dirty=-dirty)"
BRANCH="$(git branch --show-current)"
YYYYMMDD="$(date -u +%Y-%m-%d)"
RN="sneak/builder"
for TAG in $GITREV latest $YYYYMMDD $BRANCH ; do
# pull down the amd64 images from the CI box
docker pull $RN:$TAG-x86_64
docker manifest create \
$RN:$TAG \
--amend $RN:$TAG-arm64 \
--amend $RN:$TAG-x86_64
docker manifest push $RN:$TAG
done