Behebe Frontend Container Startup-Fehler
- Korrigiere Syntax-Fehler im Startup-Skript des Frontend-Containers - Verbessere Datenbankmigration mit direkten Drizzle-Kit-Befehlen - Füge TSX-Dependency für TypeScript-Ausführung hinzu - Erweitere Frontend-Installationsskript mit besserer Fehlerbehandlung 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
9a0cda9cad
commit
59b9189686
@ -326,15 +326,50 @@ fi
|
||||
# Prüfe, ob der Container läuft
|
||||
log "Warte 10 Sekunden, bis der Container gestartet ist..."
|
||||
sleep 10
|
||||
if docker ps | grep -q "myp-frontend"; then
|
||||
log "${GREEN}Frontend-Container läuft${NC}"
|
||||
else
|
||||
error_log "Frontend-Container läuft nicht. Container-Status:"
|
||||
docker ps -a | grep myp-frontend
|
||||
log "Container-Logs:"
|
||||
docker logs myp-frontend
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Prüfe mehrmals, da der Container möglicherweise länger zum Starten braucht
|
||||
MAX_ATTEMPTS=5
|
||||
CURRENT_ATTEMPT=1
|
||||
|
||||
while [ $CURRENT_ATTEMPT -le $MAX_ATTEMPTS ]; do
|
||||
log "Prüfe Container-Status (Versuch $CURRENT_ATTEMPT von $MAX_ATTEMPTS)..."
|
||||
|
||||
if docker ps | grep -q "myp-frontend"; then
|
||||
log "${GREEN}Frontend-Container läuft${NC}"
|
||||
break
|
||||
else
|
||||
CONTAINER_STATUS=$(docker ps -a | grep myp-frontend)
|
||||
CONTAINER_CREATED=$(echo "$CONTAINER_STATUS" | grep -q "Created" && echo "true" || echo "false")
|
||||
CONTAINER_EXITED=$(echo "$CONTAINER_STATUS" | grep -q "Exited" && echo "true" || echo "false")
|
||||
|
||||
if [ "$CONTAINER_EXITED" = "true" ]; then
|
||||
log "${YELLOW}Container wurde beendet. Prüfe Logs...${NC}"
|
||||
docker logs myp-frontend
|
||||
|
||||
log "${YELLOW}Starte Container neu mit besserer Debug-Ausgabe...${NC}"
|
||||
docker rm -f myp-frontend
|
||||
|
||||
if [ "${DOCKER_COMPOSE_V2:-false}" = true ]; then
|
||||
docker compose up -d
|
||||
else
|
||||
docker-compose up -d
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
fi
|
||||
|
||||
if [ $CURRENT_ATTEMPT -eq $MAX_ATTEMPTS ]; then
|
||||
error_log "Frontend-Container läuft nach mehreren Versuchen nicht. Container-Status:"
|
||||
docker ps -a | grep myp-frontend
|
||||
log "Container-Logs:"
|
||||
docker logs myp-frontend
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
CURRENT_ATTEMPT=$((CURRENT_ATTEMPT + 1))
|
||||
sleep 20
|
||||
done
|
||||
|
||||
# Teste ob der Server erreichbar ist
|
||||
log "${YELLOW}Teste ob Frontend-Server erreichbar ist...${NC}"
|
||||
|
@ -15,6 +15,9 @@ COPY package.json pnpm-lock.yaml ./
|
||||
RUN pnpm install --unsafe-perm --no-optional --frozen-lockfile
|
||||
RUN pnpm rebuild better-sqlite3
|
||||
|
||||
# Install tsx for running TypeScript files directly
|
||||
RUN pnpm add -D tsx
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
@ -25,10 +28,15 @@ RUN mkdir -p db/
|
||||
EXPOSE 3000
|
||||
|
||||
# Startup script to migrate DB and start app
|
||||
RUN echo '#!/bin/sh \n\
|
||||
mkdir -p /app/db \n\
|
||||
pnpm db:migrate || echo "Migration failed, continuing anyway" \n\
|
||||
pnpm start' > /app/startup.sh && chmod +x /app/startup.sh
|
||||
RUN echo '#!/bin/sh' > /app/startup.sh && \
|
||||
echo 'set -e' >> /app/startup.sh && \
|
||||
echo 'mkdir -p /app/db' >> /app/startup.sh && \
|
||||
echo 'echo "Starting application..."' >> /app/startup.sh && \
|
||||
echo 'echo "Attempting database migration..."' >> /app/startup.sh && \
|
||||
echo 'npx drizzle-kit generate --schema=./src/server/db/schema.ts || echo "Generate schema failed, but continuing..."' >> /app/startup.sh && \
|
||||
echo 'npx drizzle-kit push:sqlite || echo "Push migration failed, but continuing..."' >> /app/startup.sh && \
|
||||
echo 'pnpm start' >> /app/startup.sh && \
|
||||
chmod +x /app/startup.sh
|
||||
|
||||
# Start the application
|
||||
CMD ["/app/startup.sh"]
|
Loading…
x
Reference in New Issue
Block a user