Warp-Drop / Dockerfile
AadityaPawarx1's picture
Upload 80 files
7ddd914 verified
# Stage 1: Build the Backend (Go)
FROM golang:1.23-alpine AS backend-builder
WORKDIR /app
RUN apk add --no-cache git build-base
COPY backend/go.mod backend/go.sum ./
RUN go mod download
COPY backend/ .
# Build static binary
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o server ./cmd/server
# Stage 2: Build the Frontend (Node/Bun)
FROM oven/bun:alpine AS frontend-builder
WORKDIR /app
COPY frontend/package.json frontend/bun.lock* ./
RUN bun ci || bun install
COPY frontend/ .
# Set environment variables for build
ENV NEXT_TELEMETRY_DISABLED=1
ENV NODE_ENV=production
RUN bun run build
# Stage 3: Final Runtime Image
# Stage 3: Final Runtime Image
FROM oven/bun:alpine AS runner
WORKDIR /app
# Install runtime dependencies including Nginx
RUN apk add --no-cache curl nginx
# Copy Backend Binary
COPY --from=backend-builder /app/server ./backend-server
# Copy Frontend Artifacts
COPY --from=frontend-builder /app/public ./public
COPY --from=frontend-builder /app/.next/standalone ./
COPY --from=frontend-builder /app/.next/static ./.next/static
# Copy Nginx Configuration
COPY deploy/nginx.conf /etc/nginx/nginx.conf
# Set Environment Variables
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
# Backend Port (Internal)
ENV BACKEND_PORT=8080
# Create a startup script
RUN echo '#!/bin/sh' > /app/start.sh && \
echo 'echo "Starting Backend on port 8080..."' >> /app/start.sh && \
echo './backend-server &' >> /app/start.sh && \
echo 'echo "Starting Frontend on port 3000..."' >> /app/start.sh && \
echo 'bun server.js &' >> /app/start.sh && \
echo 'echo "Starting Nginx on port 7860..."' >> /app/start.sh && \
echo 'nginx -g "daemon off;"' >> /app/start.sh && \
chmod +x /app/start.sh
# Expose the port HF expects (7860)
EXPOSE 7860
# Start services
CMD ["/app/start.sh"]