Skip to content

Commit aa3e6f6

Browse files
TamTunnelTamTunnel
authored andcommitted
Fix Docker build issues and enhance CI
- Rename frontend build stage to 'frontend-builder' to avoid conflicts - Add VITE_* build args to frontend Dockerfile (needed at build time) - Move VITE_* from runtime env to build args in docker-compose - Update docker-build.yml to test docker-compose build first - Fix backend build context/file paths in CI workflow - Only push images after compose build succeeds
1 parent 207307f commit aa3e6f6

File tree

3 files changed

+51
-8
lines changed

3 files changed

+51
-8
lines changed

.github/workflows/docker-build.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,39 @@ name: Docker Build
33
on:
44
push:
55
branches: [main]
6+
pull_request:
7+
branches: [main]
68
workflow_dispatch:
79

810
env:
911
REGISTRY: ghcr.io
1012
IMAGE_PREFIX: ${{ github.repository }}
1113

1214
jobs:
15+
# Test docker-compose build (same as Coolify would do)
16+
compose-build:
17+
name: Docker Compose Build Test
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Build with docker-compose
26+
run: docker compose build --no-cache
27+
28+
- name: Verify all images built
29+
run: |
30+
docker images | grep constellation
31+
echo "✅ All images built successfully"
32+
33+
# Build and push individual backend images
1334
build-backend:
1435
name: Build Backend Images
1536
runs-on: ubuntu-latest
37+
needs: compose-build # Only push if compose build succeeds
38+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
1639
permissions:
1740
contents: read
1841
packages: write
@@ -46,16 +69,20 @@ jobs:
4669
- name: Build and push
4770
uses: docker/build-push-action@v5
4871
with:
49-
context: ./backend/${{ matrix.service }}
72+
context: ./backend
73+
file: ./backend/${{ matrix.service }}/Dockerfile
5074
push: true
5175
tags: ${{ steps.meta.outputs.tags }}
5276
labels: ${{ steps.meta.outputs.labels }}
5377
cache-from: type=gha
5478
cache-to: type=gha,mode=max
5579

80+
# Build and push frontend image
5681
build-frontend:
5782
name: Build Frontend Image
5883
runs-on: ubuntu-latest
84+
needs: compose-build # Only push if compose build succeeds
85+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
5986
permissions:
6087
contents: read
6188
packages: write

docker-compose.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ services:
113113
build:
114114
context: ./frontend/web
115115
dockerfile: Dockerfile
116+
args:
117+
VITE_CORE_ORBITS_URL: ${VITE_CORE_ORBITS_URL:-http://localhost:8001}
118+
VITE_ROUTING_URL: ${VITE_ROUTING_URL:-http://localhost:8002}
119+
VITE_GROUND_SCHEDULER_URL: ${VITE_GROUND_SCHEDULER_URL:-http://localhost:8003}
120+
VITE_AI_AGENTS_URL: ${VITE_AI_AGENTS_URL:-http://localhost:8004}
116121
container_name: constellation-frontend
117122
ports:
118123
- "3000:80"
119-
environment:
120-
VITE_CORE_ORBITS_URL: ${VITE_CORE_ORBITS_URL:-http://localhost:8001}
121-
VITE_ROUTING_URL: ${VITE_ROUTING_URL:-http://localhost:8002}
122-
VITE_GROUND_SCHEDULER_URL: ${VITE_GROUND_SCHEDULER_URL:-http://localhost:8003}
123-
VITE_AI_AGENTS_URL: ${VITE_AI_AGENTS_URL:-http://localhost:8004}
124124
depends_on:
125125
- core-orbits
126126
- routing

frontend/web/Dockerfile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1-
FROM node:20-alpine as build
1+
# Build stage
2+
FROM node:20-alpine AS frontend-builder
23

34
WORKDIR /app
45

6+
# Accept build args for API URLs (needed at build time for Vite)
7+
ARG VITE_CORE_ORBITS_URL
8+
ARG VITE_ROUTING_URL
9+
ARG VITE_GROUND_SCHEDULER_URL
10+
ARG VITE_AI_AGENTS_URL
11+
12+
# Set them as environment variables for the build
13+
ENV VITE_CORE_ORBITS_URL=${VITE_CORE_ORBITS_URL}
14+
ENV VITE_ROUTING_URL=${VITE_ROUTING_URL}
15+
ENV VITE_GROUND_SCHEDULER_URL=${VITE_GROUND_SCHEDULER_URL}
16+
ENV VITE_AI_AGENTS_URL=${VITE_AI_AGENTS_URL}
17+
518
COPY package*.json ./
619
RUN npm ci
720

821
COPY . .
922
RUN npm run build
1023

24+
# Production stage
1125
FROM nginx:alpine
12-
COPY --from=build /app/dist /usr/share/nginx/html
26+
27+
COPY --from=frontend-builder /app/dist /usr/share/nginx/html
1328
COPY nginx.conf /etc/nginx/conf.d/default.conf
29+
1430
EXPOSE 80
1531
CMD ["nginx", "-g", "daemon off;"]

0 commit comments

Comments
 (0)