chartdb / Dockerfile
Subham9126's picture
Create Dockerfile
e2e1db8 verified
Raw
History Blame
991 Bytes
# Stage 1: Build
FROM node:22-alpine AS builder
WORKDIR /app
# Clone ChartDB source
RUN apk add --no-cache git && \
git clone https://github.com/chartdb/chartdb.git .
RUN npm install
# Pass the OpenAI key at build time
ARG OPENAI_API_KEY
ENV VITE_OPENAI_API_KEY=$OPENAI_API_KEY
RUN npm run build
# Stage 2: Serve with NGINX
FROM nginx:alpine
# HF Spaces requires non-root user with uid 1000
RUN adduser -D -u 1000 user
COPY --from=builder /app/dist /usr/share/nginx/html
# Custom nginx config to listen on port 80
RUN echo 'server { \
listen 80; \
location / { \
root /usr/share/nginx/html; \
try_files $uri /index.html; \
} \
}' > /etc/nginx/conf.d/default.conf
# Fix permissions
RUN chown -R user:user /usr/share/nginx/html && \
chown -R user:user /var/cache/nginx && \
chown -R user:user /var/log/nginx && \
touch /var/run/nginx.pid && \
chown user:user /var/run/nginx.pid
USER user
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]