Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scratch image #439

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ RUN go get -d -v
ARG VERSION
ENV VERSION ${VERSION:-0.1.0}

RUN GOOS=linux GOARCH=amd64 go build -v -ldflags "-X main.Version=${VERSION} -s -w"
ARG CGO_ENABLED
ENV CGO_ENABLED ${CGO_ENABLED:-1}

RUN CGO_ENABLED=${CGO_ENABLED} GOOS=linux GOARCH=amd64 go build -v -ldflags "-X main.Version=${VERSION} -s -w"

FROM ${BASE_IMAGE} as exporter
LABEL org.opencontainers.image.authors="Seth Miller,Yannig Perré <[email protected]>"
Expand Down
26 changes: 25 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RELEASE ?= true
UBUNTU_BASE_IMAGE ?= docker.io/library/ubuntu:24.04
ORACLE_LINUX_BASE_IMAGE ?= docker.io/library/oraclelinux:9-slim
ALPINE_BASE_IMAGE ?= docker.io/library/alpine:3.19
SCRATCH_BASE_IMAGE ?= scratch

ifeq ($(GOOS), windows)
EXT?=.exe
Expand Down Expand Up @@ -92,12 +93,13 @@ go-test:
clean:
rm -rf ./dist sgerrand.rsa.pub glibc-*.apk oracle-*.rpm

docker: ubuntu-image alpine-image oraclelinux-image
docker: ubuntu-image alpine-image oraclelinux-image scratch-image

push-images:
@make --no-print-directory push-ubuntu-image
@make --no-print-directory push-oraclelinux-image
@make --no-print-directory push-alpine-image
@make --no-print-directory push-scratch-image

oraclelinux-image:
if DOCKER_CLI_EXPERIMENTAL=enabled $(DOCKER_CMD) manifest inspect "$(IMAGE_ID)-oraclelinux" > /dev/null; then \
Expand Down Expand Up @@ -168,4 +170,26 @@ else
@echo "Can't find cosign.key file"
endif

scratch-image:
if DOCKER_CLI_EXPERIMENTAL=enabled $(DOCKER_CMD) manifest inspect "$(IMAGE_ID)-scratch" > /dev/null; then \
echo "Image \"$(IMAGE_ID)-scratch\" already exists on ghcr.io"; \
else \
$(DOCKER_CMD) build --progress=plain $(BUILD_ARGS) -t "$(IMAGE_ID)-scratch" --build-arg BASE_IMAGE=$(SCRATCH_BASE_IMAGE) --build-arg CGO_ENABLED=0 . && \
$(DOCKER_CMD) build --progress=plain $(BUILD_ARGS) $(LEGACY_TABLESPACE) --build-arg BASE_IMAGE=$(SCRATCH_BASE_IMAGE) --build-arg CGO_ENABLED=0 -t "$(IMAGE_ID)-scratch_legacy-tablespace" . && \
$(DOCKER_CMD) tag "$(IMAGE_ID)-scratch" "$(IMAGE_NAME):scratch"; \
fi

push-scratch-image:
$(DOCKER_CMD) push $(IMAGE_ID)-scratch
ifeq ("$(RELEASE)", "true")
$(DOCKER_CMD) push "$(IMAGE_NAME):scratch"
endif

sign-scratch-image:
ifneq ("$(wildcard cosign.key)","")
cosign sign --key cosign.key $(IMAGE_ID)-scratch
else
@echo "Can't find cosign.key file"
endif

.PHONY: version build deps go-test clean docker
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Different Linux Distros:
- `x.y.z` - Ubuntu Linux image
- `x.y.z-oraclelinux` - Oracle Enterprise Linux image
- `x.y.z-Alpine` - Alpine Linux image
- `x.y.z-scratch` - Scratch image

Forked Version:
All the above docker images have a duplicate image tag ending in
Expand Down Expand Up @@ -450,6 +451,10 @@ Or Alpine:

make alpine-image

Or Scratch:

make scratch-image

### Building Binaries

Run build:
Expand Down
Loading