-
Notifications
You must be signed in to change notification settings - Fork 4
cleanup: refactor to use stagex #96
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
FROM stagex/busybox:sx2024.04.2@sha256:8cb9360041cd17e8df33c5cbc6c223875045c0c249254367ed7e0eb445720757 AS busybox | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will need to make sure these are monitored via renovate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Images are tagged with both the stagex version number and the actual version number of the source of the packaged software. We can use either. Using matched release tags across all stagex items though does assure compatibility. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. considering out of scope for this PR, but happy to externally discuss adopting an alternative stagex tagging and vulnerability monitoring strategy for all turnkey projects. I would rather not deviate from existing norms in one repo though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The change results in us losing the ability to respond and update in response to e.g. go standard library bugs. We need to come up with an answer as part of the PR |
||
FROM stagex/musl:sx2024.04.2@sha256:f888fcf45fabaaae3d0268bcec902ceb94edba7bf8d09ef6966ebb20e00b7127 AS musl | ||
FROM stagex/go:sx2024.04.2@sha256:7a0c200995e220519aae02554c082b45cc3f7452480ea45d19e15ad3ecdffb4c AS go | ||
FROM stagex/ca-certificates:sx2024.04.2@sha256:f9fe6e67df91083fee3d88cf221f84ef77f0b67480fb5b0689e890509a712533 AS ca-certificates | ||
|
||
FROM scratch as builder | ||
COPY --from=busybox . / | ||
COPY --from=musl . / | ||
COPY --from=go . / | ||
COPY --from=ca-certificates . / | ||
|
||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
ENV GOPATH=/usr/home/build | ||
ENV GOOS=${TARGETOS} | ||
ENV GOARCH=${TARGETARCH} | ||
ENV GOPROXY=off | ||
ENV CGO_ENABLED=0 | ||
ENV GOPROXY="https://proxy.golang.org,direct" | ||
lrvick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ENV GO_BUILDFLAGS="-x -v -trimpath -buildvcs=false" | ||
ENV GO_LDFLAGS="-s -w -buildid= -extldflags=-static" | ||
lrvick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ENV GOFLAGS=${GO_BUILDFLAGS} -ldflags="${GO_LDFLAGS}" | ||
|
||
RUN <<-EOF | ||
set -eux | ||
mkdir -p /newroot/etc/ssl/certs | ||
cp -ra --parents /etc/ssl/certs /newroot/ | ||
EOF | ||
|
||
WORKDIR /usr/home/build/src | ||
|
||
COPY ./src/go.mod ./src/go.sum ./ | ||
RUN go mod download | ||
|
||
COPY ./src ./ | ||
RUN --network=none go build ${GOFLAGS} \ | ||
-o /newroot/usr/local/bin/ecr-proxy \ | ||
./cmd/ecr-proxy | ||
|
||
FROM scratch | ||
LABEL org.opencontainers.image.source https://github.com/tkhq/ecr-proxy | ||
COPY --from=builder /newroot / | ||
USER 65532:65532 | ||
ENTRYPOINT ["/usr/local/bin/ecr-proxy"] |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,19 @@ | ||
include $(PWD)/src/toolchain/Makefile | ||
|
||
KEYS := \ | ||
6B61ECD76088748C70590D55E90A401336C8AAA9 \ | ||
A8864A8303994E3A18ACD1760CAB4418C834B102 \ | ||
66039AA59D823C8BD68DB062D3EC673DF9843E7B \ | ||
DE050A451E6FAF94C677B58B9361DEC647A087BD | ||
|
||
LOCAL_BUILD_DIR := 'build' | ||
|
||
.DEFAULT_GOAL := | ||
export | ||
.PHONY: default | ||
default: \ | ||
cache \ | ||
toolchain \ | ||
$(patsubst %,$(KEY_DIR)/%.asc,$(KEYS)) \ | ||
$(OUT_DIR)/ecr-proxy.linux-x86_64 \ | ||
$(OUT_DIR)/ecr-proxy.linux-aarch64 \ | ||
$(OUT_DIR)/release.env \ | ||
toolchain-profile | ||
default: out/ecr-proxy/index.json | ||
|
||
.PHONY: lint | ||
lint: | ||
$(call toolchain,' \ | ||
GOCACHE=/home/build/$(CACHE_DIR) \ | ||
GOPATH=/home/build/$(CACHE_DIR) \ | ||
env -C $(SRC_DIR) go vet -v ./... \ | ||
') | ||
|
||
.PHONY: cache | ||
cache: | ||
ifneq ($(TOOLCHAIN_REPRODUCE),true) | ||
git lfs pull --include=cache/toolchain.tgz | ||
$(MAKE) toolchain-restore-mtime | ||
touch fetch/apt/Packages.bz2 cache/toolchain.tgz | ||
endif | ||
|
||
.PHONY: dist | ||
dist: toolchain-dist | ||
|
||
.PHONY: reproduce | ||
reproduce: | ||
git lfs pull --include=fetch/apt/ | ||
$(MAKE) toolchain-reproduce toolchain-profile | ||
env -C src go vet -v ./... | ||
|
||
.PHONY: test | ||
test: $(OUT_DIR)/ecr-proxy.linux-x86_64 | ||
$(call toolchain,' \ | ||
GOCACHE=/home/build/$(CACHE_DIR) \ | ||
GOPATH=/home/build/$(CACHE_DIR) \ | ||
env -C $(SRC_DIR) go test -v ./... \ | ||
') | ||
|
||
.PHONY: install | ||
install: default | ||
mkdir -p ~/.local/bin | ||
cp $(OUT_DIR)/ecr-proxy.$(HOST_OS)-$(HOST_ARCH) ~/.local/bin/ecr-proxy | ||
|
||
# Clean repo back to initial clone state | ||
.PHONY: clean | ||
clean: toolchain-clean | ||
git clean -dfx $(SRC_DIR) | ||
rm -rf $(LOCAL_BUILD_DIR) | ||
|
||
$(KEY_DIR)/%.asc: | ||
$(call fetch_pgp_key,$(basename $(notdir $@))) | ||
|
||
$(OUT_DIR)/ecr-proxy.%: | ||
$(call toolchain-profile-start) | ||
$(call toolchain,' \ | ||
GOHOSTOS="linux" \ | ||
GOHOSTARCH="amd64" \ | ||
GOOS="$(word 1,$(subst -, ,$(word 2,$(subst ., ,$@))))" \ | ||
GOARCH="$(call altarch,$(word 2,$(subst -, ,$(word 2,$(subst ., ,$@)))))" \ | ||
GOCACHE=/home/build/$(CACHE_DIR) \ | ||
GOPATH=/home/build/$(CACHE_DIR) \ | ||
CGO_ENABLED=0 \ | ||
env -C $(SRC_DIR)/cmd/ecr-proxy \ | ||
go build \ | ||
-trimpath \ | ||
-ldflags="-s -w -buildid=''" \ | ||
-o /home/build/$@ . \ | ||
') | ||
$(call toolchain-profile-stop) | ||
|
||
.PHONY: build-local | ||
build-local: | ||
pushd $(shell git rev-parse --show-toplevel)/src; \ | ||
go build -o ../$(LOCAL_BUILD_DIR)/ecr-proxy; \ | ||
popd; | ||
test: | ||
env -C src go test -v ./... | ||
|
||
out/ecr-proxy/index.json: | ||
docker build \ | ||
-f Containerfile \ | ||
--tag tkhq/ecr-proxy:latest \ | ||
--output type=oci,tar=false,rewrite_timestamps=true,dest=out/ecr-proxy \ | ||
lrvick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
. |
Uh oh!
There was an error while loading. Please reload this page.