Spaces:
Build error
Build error
| # Stage 1: Build and configure environment | |
| FROM ubuntu:bionic AS build | |
| # Install necessary packages and dependencies | |
| RUN apt-get update && \ | |
| apt-get install -y \ | |
| xvfb \ | |
| nginx \ | |
| libxcursor1 \ | |
| bash && \ | |
| apt-get clean && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Create necessary directories with appropriate permissions | |
| RUN mkdir -p /app/build /var/log/nginx /var/lib/nginx /var/cache/nginx /usr/share/nginx/html /usr/share/nginx/html-page && \ | |
| chown -R www-data:www-data /var/log/nginx /var/lib/nginx /var/cache/nginx /usr/share/nginx/html /usr/share/nginx/html-page | |
| # Copy backend server files and Nginx configuration | |
| COPY build/ /app/build/ | |
| COPY etc/nginx/nginx.conf /etc/nginx/nginx.conf | |
| COPY etc/nginx/conf.d /etc/nginx/conf.d | |
| COPY webgl-build /usr/share/nginx/html | |
| COPY html-page /usr/share/nginx/html-page | |
| # Copy and configure custom entrypoint script | |
| COPY entrypoint.sh /entrypoint.sh | |
| RUN chmod +x /entrypoint.sh | |
| # Stage 2: Runtime | |
| FROM nginx:alpine | |
| # Copy the Nginx configuration and application from the build stage | |
| COPY --from=build /etc/nginx/nginx.conf /etc/nginx/nginx.conf | |
| COPY --from=build /etc/nginx/conf.d /etc/nginx/conf.d | |
| COPY --from=build /usr/share/nginx/html /usr/share/nginx/html | |
| COPY --from=build /usr/share/nginx/html-page /usr/share/nginx/html-page | |
| COPY --from=build /app/build /app/build | |
| COPY --from=build /entrypoint.sh /entrypoint.sh | |
| # Ensure the correct permissions for directories | |
| RUN mkdir -p /var/log/nginx /var/lib/nginx /var/cache/nginx && \ | |
| chown -R www-data:www-data /var/log/nginx /var/lib/nginx /var/cache/nginx | |
| # Expose necessary ports | |
| EXPOSE 80 7777/udp 7778/tcp 7860 | |
| # Set the entrypoint to start the backend server and Nginx | |
| ENTRYPOINT ["/entrypoint.sh"] | |