Skip to content
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
3 changes: 3 additions & 0 deletions composition/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore build and test binaries.
bin/
32 changes: 32 additions & 0 deletions composition/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# test logs
test-logs/*

bin/*
expanders/bin/*

release/test/*

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
Dockerfile.cross

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Kubernetes Generated files - skip generated files, except for vendored files

!vendor/**/zz_generated.*

# editor and IDE paraphernalia
.idea
.vscode
*.swp
*.swo
*~
50 changes: 50 additions & 0 deletions composition/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

run:
deadline: 5m
allow-parallel-runners: true

issues:
# don't skip warning about doc comments
# don't exclude the default set of lint
exclude-use-default: false
# restore some of the defaults
# (fill in the rest as needed)
exclude-rules:
Comment thread
barney-s marked this conversation as resolved.
Resolved
#- path: "api/*"
# linters:
# - lll
linters:
disable-all: true
enable:
- dupl
- errcheck
- exportloopref
- goconst
- gocyclo
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- prealloc
- staticcheck
- typecheck
- unconvert
- unparam
- unused
49 changes: 49 additions & 0 deletions composition/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Build the manager binary
FROM golang:1.23.2 as builder
Comment thread
barney-s marked this conversation as resolved.
Resolved
ARG TARGETOS
ARG TARGETARCH

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY internal/controller/ internal/controller/
COPY proto/ proto/
COPY pkg/ pkg/

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532

ENTRYPOINT ["/manager"]
42 changes: 42 additions & 0 deletions composition/Dockerfile.getter.expander
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# syntax=docker/dockerfile:1

# ----------------- Build Container ---------------------------
# Build the go app.
# Explicitly set to latest vs golang:1.22
FROM golang:1.23.2 AS build-stage

# Set destination for COPY
WORKDIR /go/src/app

# Download Go modules
# https://docs.docker.com/reference/dockerfile/#copy
COPY . ./
RUN go mod download

# Build
RUN CGO_ENABLED=0 GOOS=linux go build -v -o expander expanders/getter/main.go

# ----------------- Expander Container ---------------------------
#FROM marketplace.gcr.io/google/debian10:latest as bootstrap
FROM scratch as inline

EXPOSE 8443

WORKDIR /
COPY --from=build-stage /go/src/app/expander .

ENTRYPOINT ["/expander"]
27 changes: 27 additions & 0 deletions composition/Dockerfile.inline
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# syntax=docker/dockerfile:1

# ----------------- Build Container ---------------------------
# Build the go app.
FROM golang:1.23.2 AS build-stage

# Set destination for COPY
WORKDIR /go/src/app

# Download Go modules
# https://docs.docker.com/reference/dockerfile/#copy
COPY go.mod go.sum ./
COPY ./cmd/inline/main.go ./
Comment thread
barney-s marked this conversation as resolved.
Resolved
RUN go mod download

# Build
RUN CGO_ENABLED=0 GOOS=linux go build -v -o inline main.go

# ----------------- Final Container ---------------------------
#FROM marketplace.gcr.io/google/debian10:latest as bootstrap
FROM scratch as inline

WORKDIR /root

COPY --from=build-stage /go/src/app/inline .

ENTRYPOINT ["/root/inline"]
51 changes: 51 additions & 0 deletions composition/Dockerfile.jinja2.expander
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# syntax=docker/dockerfile:1

# ----------------- Build Container ---------------------------
# Build the go app.
# Explicitly set to latest vs golang:1.22
FROM golang:1.23.2 AS build-stage

# Set destination for COPY
WORKDIR /go/src/app

# Download Go modules
# https://docs.docker.com/reference/dockerfile/#copy
COPY go.mod go.sum ./
COPY ./expanders ./expanders
COPY ./proto ./proto
RUN go mod download

# Build
RUN CGO_ENABLED=0 GOOS=linux go build -v -o expander expanders/jinja2/main.go

# ----------------- Expander Container ---------------------------
FROM python:3.7-slim as expander

EXPOSE 50051

WORKDIR /
COPY --from=build-stage /go/src/app/expander .


COPY ./expanders/jinja2/requirements.txt ./
RUN pip install --require-hashes -r requirements.txt
COPY ./expanders/jinja2/parse_template.py ./

# Required when setting pod .spec.securityContext.runAsNonRoot: true
#USER 65532:65532

ENTRYPOINT ["jinja2"]
Loading