-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
99 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
FROM stagex/busybox:sx2024.04.2@sha256:8cb9360041cd17e8df33c5cbc6c223875045c0c249254367ed7e0eb445720757 AS busybox | ||
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" | ||
ENV GO_BUILDFLAGS="-x -v -trimpath -buildvcs=false" | ||
ENV GO_LDFLAGS="-s -w -buildid= -extldflags=-static" | ||
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.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 \ | ||
. |