Skip to content

Commit

Permalink
Merge pull request Stratio#6 from Stratio/PLT-589-01
Browse files Browse the repository at this point in the history
Redo dockerfile
  • Loading branch information
iamjanr authored Aug 22, 2024
2 parents 81673ae + e01b9c9 commit c1bf4d7
Showing 1 changed file with 4 additions and 29 deletions.
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 alpine:latest
WORKDIR /
COPY --from=builder /workspace/manager .
USER nobody
Expand Down

0 comments on commit c1bf4d7

Please sign in to comment.