-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (39 loc) · 1.52 KB
/
Copy pathDockerfile
File metadata and controls
51 lines (39 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Stage 1: Build Go application
FROM golang:1.26-alpine AS builder
ARG VERSION=dev
ARG COMMIT=none
ARG DATE=unknown
RUN apk add --no-cache git
WORKDIR /app
COPY . .
RUN go build -ldflags "-X 'github.com/clouddrove/smurf/cmd.version=${VERSION}' -X 'github.com/clouddrove/smurf/cmd.commit=${COMMIT}' -X 'github.com/clouddrove/smurf/cmd.date=${DATE}'" -o smurf main.go
# Stage 2: Create minimal runtime image
FROM alpine:3.18
# Install only essential CLI tools
RUN apk add --no-cache \
bash \
curl \
unzip \
git \
docker-cli \
aws-cli
# Install Google Cloud SDK (minimal install)
ENV CLOUDSDK_INSTALL_DIR /usr/local/gcloud
RUN curl -sSL https://sdk.cloud.google.com | bash -s -- --disable-prompts --install-dir=${CLOUDSDK_INSTALL_DIR} && \
rm -rf ${CLOUDSDK_INSTALL_DIR}/.install/.backup
ENV PATH $PATH:${CLOUDSDK_INSTALL_DIR}/google-cloud-sdk/bin
# Install GKE plugin
RUN gcloud components install gke-gcloud-auth-plugin --quiet
# Install Terraform
RUN curl -fsSL https://releases.hashicorp.com/terraform/1.5.7/terraform_1.5.7_linux_amd64.zip -o terraform.zip && \
unzip terraform.zip && \
mv terraform /usr/local/bin/ && \
rm terraform.zip
# Install Trivy
RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin
# Copy Go binary
COPY --from=builder /app/smurf /usr/local/bin/smurf
# Copy entrypoint
COPY entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh /usr/local/bin/smurf
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]