Files
counter/Dockerfile
aovantsev 5cde4bf00a
All checks were successful
continuous-integration/drone/push Build is passing
fix
2025-10-03 14:50:18 +03:00

58 lines
1.1 KiB
Docker

# Build stage for Go backend
FROM golang:1.21-alpine AS go-builder
WORKDIR /app
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code and environment files
COPY *.go ./
COPY .env* ./
# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
# Build stage for React frontend
FROM node:18-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy package files
COPY frontend/package*.json ./
# Install dependencies (including dev dependencies for build)
RUN npm ci
# Copy source code
COPY frontend/ ./
# Build the React app
RUN npm run build
# Final stage
FROM alpine:latest
# Install ca-certificates for HTTPS requests
RUN apk --no-cache add ca-certificates
WORKDIR /root/
# Copy the Go binary from go-builder stage
COPY --from=go-builder /app/main .
# Copy environment files from go-builder stage
COPY --from=go-builder /app/.env* ./
# Copy the React build from frontend-builder stage
COPY --from=frontend-builder /app/frontend/build ./frontend/build
# Expose port
EXPOSE 8080
# Run the binary
CMD ["./main"]