Makefile
This commit is contained in:
30
Dockerfile
30
Dockerfile
@ -1,17 +1,37 @@
|
||||
FROM golang:1.23.2-alpine AS build
|
||||
FROM golang:1.23.2-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Download dependencies and install required tools
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download && \
|
||||
go install github.com/swaggo/swag/cmd/swag@latest
|
||||
|
||||
RUN go mod download
|
||||
|
||||
# Copy source code and Makefile
|
||||
COPY . .
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /go/bin/app
|
||||
# Install required tools and make scripts executable
|
||||
RUN apk add --no-cache upx make bash && \
|
||||
chmod +x /app/lib/stylegen/gen.sh && \
|
||||
chmod +x /app/lib/stylegen/tw/*
|
||||
|
||||
# Create necessary directories
|
||||
RUN mkdir -p /app/public/css
|
||||
|
||||
# Generate assets and build with optimizations
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
RUN cd /app && make generate && \
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||||
-ldflags='-s -w -extldflags "-static"' \
|
||||
-tags netgo,osusergo \
|
||||
-o /go/bin/app
|
||||
|
||||
# Final stage
|
||||
FROM scratch
|
||||
|
||||
COPY --from=build /go/bin/app /app
|
||||
# Copy static files and assets
|
||||
COPY --from=builder /app/public/css/styles.css /public/css/styles.css
|
||||
COPY --from=builder /app/docs /docs
|
||||
COPY --from=builder /go/bin/app /app
|
||||
|
||||
ENTRYPOINT ["/app"]
|
||||
|
Reference in New Issue
Block a user