Skip to content

Commit e6ba60c

Browse files
committed
Refactor Dockerfile and README for clarity: streamline multi-stage build process, update frontend and backend build stages, and enhance documentation for deployment instructions. Improve API utility functions and extend common ports in type definitions for better integration.
1 parent a2ff767 commit e6ba60c

File tree

5 files changed

+58
-279
lines changed

5 files changed

+58
-279
lines changed

Dockerfile

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,42 @@
1-
# Multi-stage build for TSFlow with Go backend and React frontend
1+
# Multi-stage build for TSFlow
22

3-
# Stage 1: Build React frontend
3+
# Frontend build stage
44
FROM node:20-alpine AS frontend-build
55

66
WORKDIR /app/frontend
77

8-
# Copy frontend package files
98
COPY frontend/package*.json ./
10-
11-
# Install dependencies (without --only=production to get dev dependencies needed for build)
129
RUN npm ci
1310

14-
# Copy frontend source
1511
COPY frontend/ ./
16-
17-
# Build frontend
1812
RUN npm run build
1913

20-
# Stage 2: Build Go backend
14+
# Backend build stage
2115
FROM golang:1.21-alpine AS backend-build
2216

2317
WORKDIR /app/backend
2418

25-
# Install git (needed for go mod download)
2619
RUN apk add --no-cache git
2720

28-
# Copy go mod files
2921
COPY backend/go.mod backend/go.sum ./
30-
31-
# Download dependencies
3222
RUN go mod download
3323

34-
# Copy backend source
3524
COPY backend/ ./
36-
37-
# Build the backend binary
3825
RUN CGO_ENABLED=0 GOOS=linux go build -o tsflow-backend ./main.go
3926

40-
# Stage 3: Final runtime image
27+
# Runtime stage
4128
FROM alpine:latest
4229

43-
# Install ca-certificates for HTTPS requests
4430
RUN apk --no-cache add ca-certificates
4531

4632
WORKDIR /app
4733

48-
# Copy the backend binary
4934
COPY --from=backend-build /app/backend/tsflow-backend ./
50-
51-
# Copy the frontend build
5235
COPY --from=frontend-build /app/frontend/dist ./dist
5336

54-
# Expose port
5537
EXPOSE 8080
5638

57-
# Health check
5839
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
5940
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
6041

61-
# Run the backend (which serves the frontend)
6242
CMD ["./tsflow-backend"]

0 commit comments

Comments
 (0)