Skip to content

Commit

Permalink
use base image for azure runner
Browse files Browse the repository at this point in the history
Signed-off-by: Chanwit Kaewkasi <[email protected]>
  • Loading branch information
chanwit committed Aug 16, 2023
1 parent 40af753 commit f15639c
Showing 1 changed file with 10 additions and 48 deletions.
58 changes: 10 additions & 48 deletions runner-azure.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,16 @@
# Build the manager binary
FROM golang:1.20 as builder
ARG BASE_IMAGE
FROM $BASE_IMAGE

ARG TARGETARCH

RUN apt-get update && apt-get install -y unzip

WORKDIR /workspace
# Copy API and its Go module
COPY api/ api/
# Copy tfctl and its Go module
COPY tfctl/ tfctl/

# 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/runner/main.go cmd/runner/main.go
COPY controllers/ controllers/
COPY mtls/ mtls/
COPY runner/ runner/
COPY utils/ utils/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -o tf-runner cmd/runner/main.go

ARG TF_VERSION=1.3.9
ADD https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_${TARGETARCH}.zip /terraform_${TF_VERSION}_linux_${TARGETARCH}.zip
RUN unzip -q /terraform_${TF_VERSION}_linux_${TARGETARCH}.zip

FROM alpine:3.18
# Switch to root to have permissions for operations
USER root

LABEL org.opencontainers.image.source="https://github.com/weaveworks/tf-controller"

RUN apk update

RUN apk add --no-cache libcrypto3=3.1.2-r0 && \
apk add --no-cache libssl3=3.1.2-r0 && \
apk add --no-cache ca-certificates tini git openssh-client gnupg && \
apk add --no-cache libretls && \
apk add --no-cache busybox
ADD https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_${TARGETARCH}.zip /terraform_${TF_VERSION}_linux_${TARGETARCH}.zip
RUN unzip -q /terraform_${TF_VERSION}_linux_${TARGETARCH}.zip -d /usr/local/bin/ && \
rm /terraform_${TF_VERSION}_linux_${TARGETARCH}.zip && \
chmod +x /usr/local/bin/terraform

# Install az cli
ARG AZCLI_VERSION=2.50.0
Expand All @@ -51,13 +19,7 @@ RUN apk add --no-cache py3-pip && \
RUN pip install --upgrade pip && \
pip install azure-cli==${AZCLI_VERSION}

COPY --from=builder /workspace/tf-runner /usr/local/bin/
COPY --from=builder /workspace/terraform /usr/local/bin/

RUN addgroup --gid 65532 -S runner && adduser --uid 65532 -S runner -G runner && chmod +x /usr/local/bin/terraform

# Switch back to the non-root user after operations
USER 65532:65532

ENV GNUPGHOME=/tmp

ENTRYPOINT [ "/sbin/tini", "--", "tf-runner" ]
ENV GNUPGHOME=/tmp

0 comments on commit f15639c

Please sign in to comment.