diff --git a/compose.yaml b/compose.yaml index 3db24a8..89a2259 100644 --- a/compose.yaml +++ b/compose.yaml @@ -5,16 +5,14 @@ services: container_name: fastnotes-api ports: - "8000:8000" - # No volume – immutable image - # env_file: .env # set secrets in Coolify UI ui: build: - context: ./frontend # defaults to Dockerfile (production) + context: ./frontend + args: + VITE_API_URL: https://notesapi.fitzythe.dev # Pass as build arg container_name: fastnotes-ui - environment: - - VITE_API_URL=http://api:8000 ports: - - "80:80" # Nginx serves on 80 + - "80:80" depends_on: - api diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 65b6491..8c030b7 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,17 +1,18 @@ # ---------- Builder ---------- FROM node:20-alpine AS builder - WORKDIR /app + +# Accept build argument +ARG VITE_API_URL +ENV VITE_API_URL=$VITE_API_URL + COPY package*.json ./ -RUN npm ci # install deps (no dev‑dependencies unless you need them) +RUN npm ci COPY . . -RUN npm run build # Vite creates ./dist +RUN npm run build # ---------- Runtime ---------- FROM nginx:stable-alpine AS runtime - -# Copy the compiled assets from the builder stage COPY --from=builder /app/dist /usr/share/nginx/html - EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]