Merge pull request #91 from chamikaJ/fix/docker-compose-fix

Refactor start.sh script creation in Dockerfile
This commit is contained in:
Chamika J
2025-04-28 15:40:07 +05:30
committed by GitHub

View File

@@ -23,15 +23,15 @@ RUN npm install -g serve
COPY --from=build /app/build /app/build COPY --from=build /app/build /app/build
COPY --from=build /app/public/env-config.js /app/build/env-config.js COPY --from=build /app/public/env-config.js /app/build/env-config.js
# Create a script to start server and dynamically update env-config.js # Create start.sh script
RUN echo '#!/bin/sh\n\ RUN echo '#!/bin/sh' > /app/start.sh && \
# Update env-config.js with runtime environment variables\n\ echo '# Update env-config.js with runtime environment variables' >> /app/start.sh && \
cat > /app/build/env-config.js << EOL\n\ echo 'cat > /app/build/env-config.js << EOL' >> /app/start.sh && \
window.VITE_API_URL="${VITE_API_URL:-http://backend:3000}";\n\ echo 'window.VITE_API_URL="${VITE_API_URL:-http://backend:3000}";' >> /app/start.sh && \
window.VITE_SOCKET_URL="${VITE_SOCKET_URL:-ws://backend:3000}";\n\ echo 'window.VITE_SOCKET_URL="${VITE_SOCKET_URL:-ws://backend:3000}";' >> /app/start.sh && \
EOL\n\ echo 'EOL' >> /app/start.sh && \
exec serve -s build -l 5000' > /app/start.sh && \ echo 'exec serve -s build -l 5000' >> /app/start.sh && \
chmod +x /app/start.sh chmod +x /app/start.sh
EXPOSE 5000 EXPOSE 5000
CMD ["/app/start.sh"] CMD ["/app/start.sh"]