forked from coracle/caravel
Clean up the dockerfile a bit
This commit is contained in:
+5
-33
@@ -54,42 +54,14 @@ WORKDIR /app
|
||||
|
||||
COPY --from=backend-build /app/target/release/backend /app/backend
|
||||
COPY --from=frontend-build /app/frontend/dist /app/dist
|
||||
COPY --chmod=0755 entrypoint.sh /app/entrypoint.sh
|
||||
|
||||
# Single entrypoint: substitute the real config into the prebuilt bundle, then
|
||||
# run both processes and exit (so the orchestrator restarts us) if either dies.
|
||||
RUN cat > /app/entrypoint.sh <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
RUN mkdir -p /app/data && chown -R node:node /app/dist /app/data
|
||||
|
||||
# Map the provided runtime variables onto the frontend's VITE_* placeholders.
|
||||
VITE_API_URL="${SERVER_URL:-}"
|
||||
VITE_RELAY_DOMAIN="${RELAY_DOMAIN:-}"
|
||||
VITE_PLATFORM_NAME="${PLATFORM_NAME:-}"
|
||||
USER node:node
|
||||
|
||||
# Escape characters that are special in a sed replacement.
|
||||
esc() { printf '%s' "$1" | sed -e 's/[&|\\]/\\&/g'; }
|
||||
|
||||
echo "Applying runtime configuration to the frontend bundle..."
|
||||
while IFS= read -r -d '' f; do
|
||||
sed -i \
|
||||
-e "s|__VITE_API_URL__|$(esc "$VITE_API_URL")|g" \
|
||||
-e "s|__VITE_RELAY_DOMAIN__|$(esc "$VITE_RELAY_DOMAIN")|g" \
|
||||
-e "s|__VITE_PLATFORM_NAME__|$(esc "$VITE_PLATFORM_NAME")|g" \
|
||||
"$f"
|
||||
done < <(find /app/dist -type f \( -name '*.js' -o -name '*.html' \) -print0)
|
||||
|
||||
echo "Starting backend (:2892) and frontend (:3000)..."
|
||||
/app/backend &
|
||||
backend_pid=$!
|
||||
serve -s /app/dist -l 3000 &
|
||||
serve_pid=$!
|
||||
|
||||
trap 'kill -TERM "$backend_pid" "$serve_pid" 2>/dev/null || true' TERM INT
|
||||
|
||||
# Exit as soon as either process exits.
|
||||
wait -n
|
||||
EOF
|
||||
RUN chmod +x /app/entrypoint.sh
|
||||
ENV SERVER_PORT=2892 \
|
||||
DATABASE_URL=sqlite:///app/data/caravel.db
|
||||
|
||||
EXPOSE 2892 3000
|
||||
|
||||
|
||||
Reference in New Issue
Block a user