Files
stock-tax-analyzer/Dockerfile
2025-10-12 00:44:13 +02:00

37 lines
935 B
Docker

# Stage 1: Build static content (Node.js not needed, just copy HTML)
FROM alpine:3.18 AS static-builder
WORKDIR /build
COPY static/index.html .
RUN mkdir -p /build/static && cp index.html /build/static/
# Stage 2: Build Go backend
FROM golang:1.21-alpine AS go-builder
WORKDIR /app
# Copy go.mod and go.sum if they exist, otherwise they'll be created
# Copy the Go source code
COPY backend/. .
RUN go mod download || true
# Build the Go binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o stock-analyzer .
# Stage 3: Final clean stage
FROM alpine:3.18
WORKDIR /app
# Install CA certificates for HTTPS requests
RUN apk --no-cache add ca-certificates
# Copy the Go binary from stage 2
COPY --from=go-builder /app/stock-analyzer /app/stock-analyzer
# Copy static files from stage 1
COPY --from=static-builder /build/static /app/static
# Expose port 8080
EXPOSE 8080
# Run the binary
CMD ["/app/stock-analyzer"]