Spaces:
Paused
Paused
Upload 80 files
Browse files- Dockerfile +12 -8
- deploy/nginx.conf +32 -0
- frontend/next.config.ts +0 -8
Dockerfile
CHANGED
|
@@ -19,27 +19,29 @@ ENV NEXT_TELEMETRY_DISABLED=1
|
|
| 19 |
ENV NODE_ENV=production
|
| 20 |
RUN bun run build
|
| 21 |
|
|
|
|
| 22 |
# Stage 3: Final Runtime Image
|
| 23 |
FROM oven/bun:alpine AS runner
|
| 24 |
WORKDIR /app
|
| 25 |
|
| 26 |
-
# Install runtime dependencies
|
| 27 |
-
RUN apk add --no-cache curl
|
| 28 |
|
| 29 |
# Copy Backend Binary
|
| 30 |
COPY --from=backend-builder /app/server ./backend-server
|
| 31 |
|
| 32 |
# Copy Frontend Artifacts
|
| 33 |
-
# Automatically leverage output traces to reduce image size
|
| 34 |
-
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
| 35 |
COPY --from=frontend-builder /app/public ./public
|
| 36 |
COPY --from=frontend-builder /app/.next/standalone ./
|
| 37 |
COPY --from=frontend-builder /app/.next/static ./.next/static
|
| 38 |
|
|
|
|
|
|
|
|
|
|
| 39 |
# Set Environment Variables
|
| 40 |
ENV NODE_ENV=production
|
| 41 |
ENV NEXT_TELEMETRY_DISABLED=1
|
| 42 |
-
ENV PORT=
|
| 43 |
ENV HOSTNAME=0.0.0.0
|
| 44 |
|
| 45 |
# Backend Port (Internal)
|
|
@@ -49,12 +51,14 @@ ENV BACKEND_PORT=8080
|
|
| 49 |
RUN echo '#!/bin/sh' > /app/start.sh && \
|
| 50 |
echo 'echo "Starting Backend on port 8080..."' >> /app/start.sh && \
|
| 51 |
echo './backend-server &' >> /app/start.sh && \
|
| 52 |
-
echo 'echo "Starting Frontend on port
|
| 53 |
-
echo 'bun server.js' >> /app/start.sh && \
|
|
|
|
|
|
|
| 54 |
chmod +x /app/start.sh
|
| 55 |
|
| 56 |
# Expose the port HF expects (7860)
|
| 57 |
EXPOSE 7860
|
| 58 |
|
| 59 |
-
# Start
|
| 60 |
CMD ["/app/start.sh"]
|
|
|
|
| 19 |
ENV NODE_ENV=production
|
| 20 |
RUN bun run build
|
| 21 |
|
| 22 |
+
# Stage 3: Final Runtime Image
|
| 23 |
# Stage 3: Final Runtime Image
|
| 24 |
FROM oven/bun:alpine AS runner
|
| 25 |
WORKDIR /app
|
| 26 |
|
| 27 |
+
# Install runtime dependencies including Nginx
|
| 28 |
+
RUN apk add --no-cache curl nginx
|
| 29 |
|
| 30 |
# Copy Backend Binary
|
| 31 |
COPY --from=backend-builder /app/server ./backend-server
|
| 32 |
|
| 33 |
# Copy Frontend Artifacts
|
|
|
|
|
|
|
| 34 |
COPY --from=frontend-builder /app/public ./public
|
| 35 |
COPY --from=frontend-builder /app/.next/standalone ./
|
| 36 |
COPY --from=frontend-builder /app/.next/static ./.next/static
|
| 37 |
|
| 38 |
+
# Copy Nginx Configuration
|
| 39 |
+
COPY deploy/nginx.conf /etc/nginx/nginx.conf
|
| 40 |
+
|
| 41 |
# Set Environment Variables
|
| 42 |
ENV NODE_ENV=production
|
| 43 |
ENV NEXT_TELEMETRY_DISABLED=1
|
| 44 |
+
ENV PORT=3000
|
| 45 |
ENV HOSTNAME=0.0.0.0
|
| 46 |
|
| 47 |
# Backend Port (Internal)
|
|
|
|
| 51 |
RUN echo '#!/bin/sh' > /app/start.sh && \
|
| 52 |
echo 'echo "Starting Backend on port 8080..."' >> /app/start.sh && \
|
| 53 |
echo './backend-server &' >> /app/start.sh && \
|
| 54 |
+
echo 'echo "Starting Frontend on port 3000..."' >> /app/start.sh && \
|
| 55 |
+
echo 'bun server.js &' >> /app/start.sh && \
|
| 56 |
+
echo 'echo "Starting Nginx on port 7860..."' >> /app/start.sh && \
|
| 57 |
+
echo 'nginx -g "daemon off;"' >> /app/start.sh && \
|
| 58 |
chmod +x /app/start.sh
|
| 59 |
|
| 60 |
# Expose the port HF expects (7860)
|
| 61 |
EXPOSE 7860
|
| 62 |
|
| 63 |
+
# Start services
|
| 64 |
CMD ["/app/start.sh"]
|
deploy/nginx.conf
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
worker_processes 1;
|
| 2 |
+
|
| 3 |
+
events { worker_connections 1024; }
|
| 4 |
+
|
| 5 |
+
http {
|
| 6 |
+
include mime.types;
|
| 7 |
+
default_type application/octet-stream;
|
| 8 |
+
sendfile on;
|
| 9 |
+
keepalive_timeout 65;
|
| 10 |
+
|
| 11 |
+
server {
|
| 12 |
+
listen 7860;
|
| 13 |
+
|
| 14 |
+
# Websocket proxy to Go backend
|
| 15 |
+
location /ws {
|
| 16 |
+
proxy_pass http://127.0.0.1:8080;
|
| 17 |
+
proxy_http_version 1.1;
|
| 18 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 19 |
+
proxy_set_header Connection "Upgrade";
|
| 20 |
+
proxy_set_header Host $host;
|
| 21 |
+
proxy_set_header X-Real-IP $remote_addr;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
# Frontend proxy to Next.js
|
| 25 |
+
location / {
|
| 26 |
+
proxy_pass http://127.0.0.1:3000;
|
| 27 |
+
proxy_http_version 1.1;
|
| 28 |
+
proxy_set_header Host $host;
|
| 29 |
+
proxy_set_header X-Real-IP $remote_addr;
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
}
|
frontend/next.config.ts
CHANGED
|
@@ -6,14 +6,6 @@ const nextConfig: NextConfig = {
|
|
| 6 |
// reactCompiler: true,
|
| 7 |
output: "standalone",
|
| 8 |
allowedDevOrigins: ["localhost.biohazard.qzz.io"],
|
| 9 |
-
async rewrites() {
|
| 10 |
-
return [
|
| 11 |
-
{
|
| 12 |
-
source: "/ws/:path*",
|
| 13 |
-
destination: "http://localhost:8080/ws/:path*",
|
| 14 |
-
},
|
| 15 |
-
];
|
| 16 |
-
},
|
| 17 |
};
|
| 18 |
|
| 19 |
export default nextConfig;
|
|
|
|
| 6 |
// reactCompiler: true,
|
| 7 |
output: "standalone",
|
| 8 |
allowedDevOrigins: ["localhost.biohazard.qzz.io"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
};
|
| 10 |
|
| 11 |
export default nextConfig;
|