Skip to content

Commit 631f6eb

Browse files
authored
Access AR repositories via GOPROXY in GBOC (#345)
1 parent 135dc9d commit 631f6eb

File tree

7 files changed

+166
-2
lines changed

7 files changed

+166
-2
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# NOTE: File generated by distrogen. Do not manually edit.
2+
3+
# This Dockerfile provides the same resulting container as
4+
# the main Dockerfile, but it also performs the build within
5+
# an earlier layer. The resulting container will be scratch and
6+
# should be functionally identical.
7+
8+
# By default, this container should have the root of your project
9+
# where all distributions are container. The generated version will
10+
# use the respective distribution as the working directory for builds.
11+
# The whole project is copied to the container in case you provide
12+
# any custom components contained within your full project structure.
13+
ARG PROJECT_ROOT="."
14+
ARG CERT_CONTAINER="alpine:3"
15+
ARG BUILD_CONTAINER="google/cloud-sdk@sha256:cad12907540b1a43c9279503796723817e62da1f8fd3b8723755effb9d55e1e1"
16+
FROM --platform=${BUILDPLATFORM:-linux/amd64} ${BUILD_CONTAINER} AS build
17+
18+
RUN apk --update add make curl
19+
20+
ARG PROJECT_ROOT
21+
COPY ${PROJECT_ROOT} /
22+
23+
WORKDIR /google-built-opentelemetry-collector
24+
25+
ARG BUILDARCH
26+
ARG BUILDOS
27+
ARG TARGETOS
28+
ARG TARGETARCH
29+
RUN make -f pull_modules_from_ar_repos.mk aoss-build
30+
31+
FROM ${CERT_CONTAINER} AS certs
32+
RUN apk --update add ca-certificates
33+
34+
FROM scratch
35+
36+
ARG USER_UID=10001
37+
USER ${USER_UID}
38+
39+
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
40+
COPY --from=build --chmod=755 /google-built-opentelemetry-collector/otelcol-google /otelcol-google
41+
COPY --from=build --chmod=644 /google-built-opentelemetry-collector/config.yaml /etc/otelcol-google/config.yaml
42+
43+
ENTRYPOINT ["/otelcol-google", "--feature-gates=exporter.googlemanagedprometheus.intToDouble,exporter.googlecloud.CustomMonitoredResources"]
44+
CMD ["--config=/etc/otelcol-google/config.yaml"]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
include ./Makefile
2+
3+
AR_AUTH_BIN = $(TOOLS_DIR)/auth
4+
5+
$(AR_AUTH_BIN): $(GO_BIN)
6+
@{ \
7+
set -e ;\
8+
mkdir -p $(TOOLS_DIR) ;\
9+
echo "Installing AR Auth tools at $(TOOLS_DIR)" ;\
10+
GOBIN=$(TOOLS_DIR) CGO_ENABLED=0 $(GO_BIN) install -trimpath -ldflags="-s -w" github.com/GoogleCloudPlatform/artifact-registry-go-tools/cmd/[email protected] ;\
11+
}
12+
13+
.PHONY: aoss-build
14+
aoss-build: $(AR_AUTH_BIN)
15+
$(AR_AUTH_BIN) add-locations --locations=us && \
16+
$(AR_AUTH_BIN) refresh && \
17+
$(MAKE) build

kokoro/config/build/build_image.gcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ config build = common.build {
1212
{
1313
key = 'BUILD_CONTAINER'
1414
value =
15-
'us-docker.pkg.dev/artifact-foundry-prod/docker-3p-trusted/alpine:3'
15+
'us-docker.pkg.dev/artifact-foundry-prod/docker-3p-trusted/google/cloud-sdk@sha256:cad12907540b1a43c9279503796723817e62da1f8fd3b8723755effb9d55e1e1'
1616
},
1717
{
1818
key = 'CERT_CONTAINER'
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import 'common.gcl' as common
2+
3+
config build = common.build {
4+
dockerfile_path =
5+
'git/otelcol-google/google-built-opentelemetry-collector/Dockerfile.image_with_gcloud.build'
6+
7+
container_build_argument = [
8+
{
9+
key = 'PROJECT_ROOT'
10+
value = 'git/otelcol-google'
11+
},
12+
{
13+
key = 'BUILD_CONTAINER'
14+
value =
15+
'us-docker.pkg.dev/artifact-foundry-prod/docker-3p-trusted/google/cloud-sdk@sha256:cad12907540b1a43c9279503796723817e62da1f8fd3b8723755effb9d55e1e1'
16+
},
17+
{
18+
key = 'CERT_CONTAINER'
19+
value =
20+
'us-docker.pkg.dev/artifact-foundry-prod/docker-3p-trusted/alpine:3'
21+
},
22+
]
23+
// I'm not sure why, but this build doesn't seem to need container_properties;
24+
// null it out for now.
25+
container_properties = null
26+
27+
container_artifact = [
28+
{
29+
// Path to the container tar file produced by the build. For a container build,
30+
// this should always be "container/container.tar"
31+
source = 'container/container.tar'
32+
destination = 'us-docker.pkg.dev/cloud-ops-agents-art-staging/google-cloud-opentelemetry-collector-staging/otelcol-google'
33+
},
34+
]
35+
}

kokoro/config/build/image.gcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ config build = common.build {
1212
{
1313
key = 'BUILD_CONTAINER'
1414
value =
15-
'us-docker.pkg.dev/artifact-foundry-prod/docker-3p-trusted/alpine:3'
15+
'us-docker.pkg.dev/artifact-foundry-prod/docker-3p-trusted/google/cloud-sdk@sha256:cad12907540b1a43c9279503796723817e62da1f8fd3b8723755effb9d55e1e1'
1616
},
1717
{
1818
key = 'CERT_CONTAINER'
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This Dockerfile provides the same resulting container as
2+
# the main Dockerfile, but it also performs the build within
3+
# an earlier layer. The resulting container will be scratch and
4+
# should be functionally identical.
5+
6+
# By default, this container should have the root of your project
7+
# where all distributions are container. The generated version will
8+
# use the respective distribution as the working directory for builds.
9+
# The whole project is copied to the container in case you provide
10+
# any custom components contained within your full project structure.
11+
ARG PROJECT_ROOT="."
12+
ARG CERT_CONTAINER="alpine:3"
13+
{{ if eq .BuildContainer "ubuntu" -}}
14+
ARG BUILD_CONTAINER="ubuntu:24.04"
15+
FROM --platform=${BUILDPLATFORM:-linux/amd64} ${BUILD_CONTAINER} AS build
16+
17+
RUN apt-get update && apt-get install -y make curl{{ if .CollectorCGO }} build-essential{{ end }}
18+
19+
{{ else -}}
20+
ARG BUILD_CONTAINER="google/cloud-sdk@sha256:cad12907540b1a43c9279503796723817e62da1f8fd3b8723755effb9d55e1e1"
21+
FROM --platform=${BUILDPLATFORM:-linux/amd64} ${BUILD_CONTAINER} AS build
22+
23+
RUN apk --update add make curl{{ if .CollectorCGO }} alpine-sdk{{ end }}
24+
25+
{{ end -}}
26+
27+
ARG PROJECT_ROOT
28+
COPY ${PROJECT_ROOT} /
29+
30+
WORKDIR /{{ .Name }}
31+
32+
ARG BUILDARCH
33+
ARG BUILDOS
34+
ARG TARGETOS
35+
ARG TARGETARCH
36+
RUN make -f pull_modules_from_ar_repos.mk aoss-build
37+
38+
FROM ${CERT_CONTAINER} AS certs
39+
RUN apk --update add ca-certificates
40+
41+
FROM scratch
42+
43+
ARG USER_UID=10001
44+
USER ${USER_UID}
45+
46+
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
47+
COPY --from=build --chmod=755 /{{ .Name }}/{{ .BinaryName }} /{{ .BinaryName }}
48+
COPY --from=build --chmod=644 /{{ .Name }}/config.yaml /etc/{{ .BinaryName }}/config.yaml
49+
50+
ENTRYPOINT ["/{{ .BinaryName }}"{{ $length := len .FeatureGates }}{{ if gt $length 0 }}, "--feature-gates={{ .FeatureGates.Render }}"{{ end }}]
51+
CMD ["--config=/etc/{{ .BinaryName }}/config.yaml"]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
include ./Makefile
2+
3+
AR_AUTH_BIN = $(TOOLS_DIR)/auth
4+
5+
$(AR_AUTH_BIN): $(GO_BIN)
6+
@{ \
7+
set -e ;\
8+
mkdir -p $(TOOLS_DIR) ;\
9+
echo "Installing AR Auth tools at $(TOOLS_DIR)" ;\
10+
GOBIN=$(TOOLS_DIR) CGO_ENABLED=0 $(GO_BIN) install -trimpath -ldflags="-s -w" github.com/GoogleCloudPlatform/artifact-registry-go-tools/cmd/auth@v0.4.0 ;\
11+
}
12+
13+
.PHONY: aoss-build
14+
aoss-build: $(AR_AUTH_BIN)
15+
$(AR_AUTH_BIN) add-locations --locations=us && \
16+
$(AR_AUTH_BIN) refresh && \
17+
$(MAKE) build

0 commit comments

Comments
 (0)