diff --git a/.env.example b/.env.example index 4640766..f92b861 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,8 @@ # Pastel API Configuration # URL of the Pastel API instance -NEXT_PUBLIC_API_URL=http://localhost:3000 +# For Docker Compose: use http://pastel-api:3001 +# For local development: use http://localhost:3001 +NEXT_PUBLIC_API_URL=http://localhost:3001 # Application URL (used for sharing and OG images) NEXT_PUBLIC_APP_URL=http://localhost:3000 diff --git a/Dockerfile b/Dockerfile index 11bb799..aaa0a75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,14 @@ COPY . . ENV NEXT_TELEMETRY_DISABLED=1 ENV NODE_ENV=production +# Accept build args for environment variables +ARG NEXT_PUBLIC_API_URL +ARG NEXT_PUBLIC_APP_URL + +# Set environment variables for Next.js build +ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL} +ENV NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL} + # Build the application RUN pnpm build @@ -40,6 +48,9 @@ WORKDIR /app ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1 +# Install curl for health checks +RUN apk add --no-cache curl + # Create non-root user RUN addgroup --system --gid 1001 nodejs && \ adduser --system --uid 1001 nextjs @@ -58,6 +69,6 @@ ENV HOSTNAME="0.0.0.0" # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ - CMD node -e "require('http').get('http://localhost:3000/api/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})" + CMD curl -f http://localhost:3000/ || exit 1 CMD ["node", "server.js"] diff --git a/docker-compose.yml b/docker-compose.yml index 3a5102d..a31a466 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,9 @@ services: build: context: . dockerfile: Dockerfile + args: + NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:3001} + NEXT_PUBLIC_APP_URL: ${NEXT_PUBLIC_APP_URL:-http://localhost:3000} image: ghcr.io/valknarness/pastel-ui:latest container_name: pastel-ui ports: @@ -15,7 +18,7 @@ services: - NEXT_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL:-http://localhost:3000} restart: unless-stopped healthcheck: - test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"] + test: ["CMD", "curl", "-f", "http://localhost:3000/"] interval: 30s timeout: 10s retries: 3