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

Redo dockerfile #6

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Changes from 1 commit
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
33 changes: 4 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

# Build the manager binary
FROM golang:1.21.9 AS builder
FROM golang:1.21.10@sha256:45f2cab1eebfb90d214ab8ce896cefc320e5c8768b4b34bb402652d90c670875 as builder
WORKDIR /workspace

# Run this with docker build --build_arg $(go env GOPROXY) to override the goproxy
Expand All @@ -23,47 +23,22 @@ ENV GOPROXY=$goproxy
# 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 sources
COPY ./ ./

# Build the binary
# Build
ARG ARCH
ARG LDFLAGS
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \
go build -a -trimpath -ldflags "${LDFLAGS} -extldflags '-static'" \
-o manager .

# Final stage with Alpine
FROM alpine:3.18

# Install dependencies
RUN apk add --no-cache \
git \
python3 \
py3-pip \
curl \
bash \
libc6-compat

# Install Google Cloud SDK
RUN curl -LO https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-428.0.0-linux-x86_64.tar.gz \
&& tar -xzvf google-cloud-sdk-428.0.0-linux-x86_64.tar.gz \
&& rm google-cloud-sdk-428.0.0-linux-x86_64.tar.gz \
&& ./google-cloud-sdk/install.sh -q

# Update PATH to include the Google Cloud SDK directory
ENV PATH="/google-cloud-sdk/bin:${PATH}"

# Install Python dependencies for gcloud
RUN pip3 install --upgrade pip \
&& pip3 install -U crcmod \
&& pip3 install cryptography==43.0.0

# Copy the controller-manager into a thin image
FROM cgr.dev/chainguard/static:latest
WORKDIR /
COPY --from=builder /workspace/manager .
USER nobody
Expand Down