add heavy build
This commit is contained in:
34
Dockerfile
Normal file
34
Dockerfile
Normal file
@@ -0,0 +1,34 @@
|
||||
FROM golang:1.23-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache git
|
||||
|
||||
# Copy module files first to leverage Docker cache for dependencies
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy the rest of the source code
|
||||
COPY . .
|
||||
|
||||
# Argument to control the number of generated files (default to 5000 for a moderate delay)
|
||||
ARG FILE_COUNT=5000
|
||||
|
||||
# Generate the dummy source code to simulate a large codebase
|
||||
RUN echo "Generating $FILE_COUNT dummy files..." && \
|
||||
go run gen.go -count $FILE_COUNT
|
||||
|
||||
# Build the application
|
||||
# Using -a to force rebuilding of all packages to simulate a fresh, heavy build
|
||||
RUN echo "Starting heavy build..." && \
|
||||
go build -a -o app .
|
||||
|
||||
# Final stage: Create a minimal image
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /root/
|
||||
|
||||
COPY --from=builder /app/app .
|
||||
|
||||
CMD ["./app"]
|
||||
Reference in New Issue
Block a user