Files
stock-tax-analyzer/Dockerfile
Eden Kirin e9360cbc08 Initial
2025-10-12 00:34:03 +02:00

39 lines
950 B
Docker

# Stage 1: Build static content (Node.js not needed, just copy HTML)
FROM alpine:3.18 AS static-builder
WORKDIR /build
COPY 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 go.mod go.sum* ./
RUN go mod download || true
# Copy the Go source code
COPY main.go .
# 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"]