Compare commits

..

14 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
5d0f161fd2 add ci 2022-12-08 22:49:51 +04:00
7c5be73c71 cleanup for modcache 2022-12-08 22:48:14 +04:00
6 changed files with 100 additions and 34 deletions

32
.drone.yml Normal file
View File

@@ -0,0 +1,32 @@
# 345678911234567892123456789312345678941234567895123456789612345678971234567898
kind: pipeline
name: build-and-upload
steps:
- 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
environment:
DOCKER_BUILDKIT: 1
network_mode: bridge
settings:
repo: sneak/builder
force_tag: true
username:
from_secret: DOCKER_USERNAME
password:
from_secret: DOCKER_TOKEN
- name: notify
image: plugins/slack
settings:
webhook:
from_secret: SLACK_WEBHOOK_URL
when:
event: pull_request

View File

@@ -5,13 +5,15 @@ FROM debian:bullseye-20221205
ENV DEBIAN_FRONTEND noninteractive ENV DEBIAN_FRONTEND noninteractive
ENV NVM_DIR /usr/local/nvm ENV NVM_DIR /usr/local/nvm
ENV GOROOT /usr/local/go ENV GOROOT /usr/local/go
ENV PATH $PATH:/usr/local/go/bin:/root/go/bin ENV GOPATH /root/go
ENV PATH $PATH:$GOROOT/bin:$GOPATH/bin:$NVM_DIR/versions/node/v18.12.1/bin
RUN --mount=type=cache,target=/var/cache/apt \ RUN --mount=type=cache,target=/var/cache/apt \
apt update && apt install -y \ apt update && apt install -y \
--install-recommends \ --install-recommends \
build-essential \ build-essential \
curl \ curl \
git \
jq \ jq \
make \ make \
pv \ pv \
@@ -33,10 +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 go version
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

View File

@@ -1,29 +1,24 @@
#!/bin/bash #!/bin/bash
################################################################################ ################################################################################
#2345678911234567892123456789312345678941234567895123456789612345678971234567898 ## that's a hell of an act. what do you call it? "JAVASCRIPT"
################################################################################ ################################################################################
cd /tmp
mkdir -p "$NVM_DIR" mkdir -p "$NVM_DIR"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
echo "export NVM_DIR=$NVM_DIR" >> /etc/profile echo "export NVM_DIR=$NVM_DIR" >> /etc/profile
echo "source \$NVM_DIR/nvm.sh" >> /etc/profile echo "source \$NVM_DIR/nvm.sh" >> /etc/profile
source /etc/profile source /etc/profile
NCD="/usr/local/nvm/.cache/bin/node-v18.12.1-linux-arm64/" CD="/usr/local/nvm/.cache/bin/node-v18.12.1-linux-arm64/"
mkdir -p "$NCD" mkdir -p "$NCD"
mv /tmp/node-v18.12.1-linux-arm64.tar.xz "$NCD" mv /tmp/node-v18.12.1-linux-arm64.tar.xz "$NCD"
nvm ls-remote nvm ls-remote
nvm install v18.12.1 nvm install v18.12.1
nvm use v18.12.1 nvm use v18.12.1
npm install -g npm@9.2.0
npm install -g yarn npm install -g yarn
yarn global add prettier yarn global add prettier
################################################################################
prettier --version ## cleanup
################################################################################
which npm
which yarn
rm -rf /usr/local/nvm/.cache /tmp/* rm -rf /usr/local/nvm/.cache /tmp/*

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