Skip to content

Commit 8eca5ff

Browse files
Merge pull request #79 from hhftechnology/dev
V4. Migrated to api from override file.
2 parents 4c4258f + e15f834 commit 8eca5ff

File tree

251 files changed

+38986
-9346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

251 files changed

+38986
-9346
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- main
77
- dev
8+
- dev-docs
89
paths:
910
- 'Dockerfile'
1011
- 'go.mod'

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ go.work
3333

3434
# Node modules and builds
3535
ui/node_modules/
36-
ui/build/
36+
ui/dist/
3737

3838
# SQLite database
3939
*.db
@@ -45,4 +45,4 @@ ui/build/
4545
*.log
4646

4747
# Data directories
48-
/data/
48+
/data/

Dockerfile

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,51 @@
1-
# Build UI stage
1+
# Build UI stage (Vite + TypeScript + Shadcn UI)
22
FROM node:18-alpine AS ui-builder
33

44
WORKDIR /app
55

6-
# Copy package manifests first from host's ui/src
7-
COPY ui/src/package.json ui/src/package-lock.json* ./
6+
# Copy package manifests for ui
7+
COPY ui/package.json ui/package-lock.json* ./
88

99
# Install dependencies
1010
RUN npm install
1111

12-
# Create the target directories for source and public files within the container
13-
RUN mkdir src public
12+
# Copy all ui source files
13+
COPY ui/ ./
1414

15-
# Copy contents of host's ui/public into container's /app/public
16-
COPY ui/public/ ./public/
17-
18-
# Copy *specific* source files and directories from host's ui/src into container's /app/src
19-
COPY ui/src/styles ./src/styles
20-
COPY ui/src/components ./src/components
21-
COPY ui/src/contexts ./src/contexts
22-
COPY ui/src/services ./src/services
23-
COPY ui/src/App.js ./src/App.js
24-
COPY ui/src/index.js ./src/index.js
25-
26-
27-
# Verify structure
28-
RUN echo "--- Contents of /app/public ---"
29-
RUN ls -la public
30-
RUN echo "--- Contents of /app/src ---"
31-
RUN ls -la src
32-
33-
# Build the UI (runs in /app, expects ./src, ./public relative to package.json)
15+
# Build the UI
3416
RUN npm run build
3517

36-
# Verify build output
37-
RUN echo "--- Contents of build ---"
38-
RUN ls -la build/
18+
# Build Go stage - using Debian for glibc compatibility with go-sqlite3
19+
FROM golang:1.24-bookworm AS go-builder
3920

40-
41-
# Build Go stage
42-
FROM golang:1.19-alpine AS go-builder
43-
44-
# Install build dependencies for Go
45-
RUN apk add --no-cache gcc musl-dev
21+
# Install build dependencies for Go with CGO and static linking
22+
RUN apt-get update && apt-get install -y --no-install-recommends \
23+
gcc \
24+
libc6-dev \
25+
&& rm -rf /var/lib/apt/lists/*
4626

4727
WORKDIR /app
4828

49-
# Copy go.mod and go.sum files
29+
# Copy go.mod and go.sum files first for better layer caching
5030
COPY go.mod go.sum ./
5131

52-
# Download Go dependencies
32+
# Download Go dependencies (this layer is cached if go.mod/go.sum don't change)
5333
RUN go mod download
5434

5535
# Copy the Go source code
5636
COPY . .
5737

58-
# Build the Go application
59-
RUN CGO_ENABLED=1 GOOS=linux go build -o middleware-manager .
38+
# Ensure go.sum is up to date and build the application
39+
# Using CGO for SQLite support with static linking for Alpine compatibility
40+
# The -extldflags '-static' creates a statically linked binary
41+
RUN go mod tidy && \
42+
CGO_ENABLED=1 GOOS=linux \
43+
go build -ldflags="-s -w -extldflags '-static'" -o middleware-manager .
6044

61-
# Final stage
62-
FROM alpine:3.16
45+
# Final stage - minimal runtime image
46+
FROM alpine:3.18
6347

48+
# Install runtime dependencies
6449
RUN apk add --no-cache ca-certificates sqlite curl tzdata
6550

6651
WORKDIR /app
@@ -69,11 +54,11 @@ WORKDIR /app
6954
COPY --from=go-builder /app/middleware-manager /app/middleware-manager
7055

7156
# Copy UI build files from UI builder stage
72-
# The build output is in /app/build in the ui-builder stage
73-
COPY --from=ui-builder /app/build /app/ui/build
57+
COPY --from=ui-builder /app/dist /app/ui/dist
7458

7559
# Copy configuration files
7660
COPY --from=go-builder /app/config/templates.yaml /app/config/templates.yaml
61+
COPY --from=go-builder /app/config/templates_services.yaml /app/config/templates_services.yaml
7762

7863
# Copy database migrations file
7964
COPY --from=go-builder /app/database/migrations.sql /app/database/migrations.sql
@@ -92,5 +77,9 @@ ENV PANGOLIN_API_URL=http://pangolin:3001/api/v1 \
9277
# Expose the port
9378
EXPOSE 3456
9479

80+
# Health check
81+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
82+
CMD curl -f http://localhost:3456/health || exit 1
83+
9584
# Run the application
9685
CMD ["/app/middleware-manager"]

Makefile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ all: build
1212
# Build everything
1313
build: build-ui build-backend
1414

15-
# Build UI
15+
# Build UI (Vite + TypeScript)
1616
build-ui:
1717
@echo "Building UI..."
1818
cd ui && npm install && npm run build
@@ -31,7 +31,7 @@ run: build
3131
clean:
3232
@echo "Cleaning..."
3333
rm -f $(APP_NAME)
34-
rm -rf ui/build
34+
rm -rf ui/dist
3535

3636
# Build Docker image
3737
docker-build: build
@@ -56,11 +56,21 @@ dev:
5656
# Run the UI in development mode
5757
dev-ui:
5858
@echo "Running UI in development mode..."
59-
cd ui && npm start
59+
cd ui && npm run dev
6060

6161
# Install dependencies
6262
deps:
6363
@echo "Installing Go dependencies..."
6464
go mod download
6565
@echo "Installing UI dependencies..."
66-
cd ui && npm install
66+
cd ui && npm install
67+
68+
# Type check the UI
69+
typecheck:
70+
@echo "Type checking UI..."
71+
cd ui && npm run typecheck
72+
73+
# Lint the UI
74+
lint-ui:
75+
@echo "Linting UI..."
76+
cd ui && npm run lint

0 commit comments

Comments
 (0)