Skip to content
Snippets Groups Projects
Dockerfile.alpine 1.12 KiB
Newer Older
  • Learn to ignore specific revisions
  • ARG BASE_IMAGE=docker.io/library/alpine:3.21.3
    
    FROM docker.io/library/golang:1.24-alpine AS builder
    
    WORKDIR /app
    # Copy the Go source code
    COPY src/auto-define-backend /app/
    # Build the Go binary with static linking
    RUN go build -o gitlab-tofu-auto-define-backend .
    
    
    FROM $BASE_IMAGE
    
    RUN apk add --no-cache \
      curl \
    
    Sven Schliesing's avatar
    Sven Schliesing committed
      glab \
    
      cosign
    
    # Install OpenTofu using the installer script in standalone mode
    # see https://opentofu.org/docs/intro/install/standalone
    # We may want to switch to installing manually from GitHub and verifying signature
    
    Timo Furrer's avatar
    Timo Furrer committed
    ARG OPENTOFU_VERSION
    
    RUN curl --proto '=https' --tlsv1.2 -fsSL https://get.opentofu.org/install-opentofu.sh -o install-opentofu.sh && \
        chmod +x install-opentofu.sh && \
    
    Timo Furrer's avatar
    Timo Furrer committed
        ./install-opentofu.sh --install-method standalone --opentofu-version "${OPENTOFU_VERSION}" && \
    
        rm ./install-opentofu.sh && \
    
    COPY --chmod=755 src/gitlab-tofu.sh /usr/bin/gitlab-tofu
    
    COPY --from=builder --chmod=755 /app/gitlab-tofu-auto-define-backend /usr/bin/
    
    
    # Override ENTRYPOINT
    ENTRYPOINT []