mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-08-09 02:54:37 +00:00
improve
This commit is contained in:
+28
@@ -1,10 +1,38 @@
|
||||
services:
|
||||
ui-builder:
|
||||
env_file:
|
||||
- .env
|
||||
build:
|
||||
context: ./ui
|
||||
dockerfile: Dockerfile.build
|
||||
args:
|
||||
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://127.0.0.1:8000}
|
||||
NEXT_PUBLIC_ADMIN_API_KEY: ${NEXT_PUBLIC_ADMIN_API_KEY:-}
|
||||
volumes:
|
||||
- ./ui_out:/output
|
||||
profiles:
|
||||
- ui-build
|
||||
|
||||
ui:
|
||||
image: alpine:latest
|
||||
volumes:
|
||||
- ./ui_out:/output:ro
|
||||
command:
|
||||
[
|
||||
"sh",
|
||||
"-c",
|
||||
'echo ''UI service - build with "docker compose --profile ui-build up ui-builder"'' && tail -f /dev/null',
|
||||
]
|
||||
|
||||
routstr:
|
||||
build: .
|
||||
depends_on:
|
||||
- ui
|
||||
volumes:
|
||||
- .:/app
|
||||
- ./logs:/app/logs
|
||||
- tor-data:/var/lib/tor:ro
|
||||
- ./ui_out:/app/ui_out:ro
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
FROM node:23-alpine AS base
|
||||
|
||||
# Install dependencies only when needed
|
||||
FROM base AS deps
|
||||
RUN apk add --no-cache libc6-compat
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package.json package-lock.json* pnpm-lock.yaml* ./
|
||||
RUN npm ci
|
||||
|
||||
# Build the UI
|
||||
FROM base AS builder
|
||||
WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Accept build arguments for environment variables
|
||||
ARG NEXT_PUBLIC_API_URL
|
||||
|
||||
# Create .env.local for Next.js with build arguments
|
||||
RUN echo "NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}" > .env.local && \
|
||||
echo "Using NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL}"
|
||||
|
||||
# Set production environment
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# Build the application
|
||||
RUN npm run build && \
|
||||
echo "UI build completed at $(date)"
|
||||
|
||||
# Output stage - just copy the built files
|
||||
FROM scratch AS output
|
||||
COPY --from=builder /app/out /ui_out
|
||||
Reference in New Issue
Block a user