feat: auto-seed admin user on backend startup

This commit is contained in:
echo 2026-02-27 16:06:08 +01:00
parent 994becc687
commit 4a22e8a18a
2 changed files with 14 additions and 1 deletions

View File

@ -33,6 +33,7 @@ RUN addgroup -g 1001 -S nodejs && \
COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
COPY --from=builder --chown=nodejs:nodejs /app/package*.json ./ COPY --from=builder --chown=nodejs:nodejs /app/package*.json ./
COPY --chown=nodejs:nodejs docker-entrypoint.sh ./
# Switch to non-root user # Switch to non-root user
USER nodejs USER nodejs
@ -45,4 +46,4 @@ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
EXPOSE 3000 EXPOSE 3000
# Start application # Start application
CMD ["node", "dist/src/main.js"] CMD ["sh", "docker-entrypoint.sh"]

12
backend/docker-entrypoint.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
# Backend entrypoint script - seeds admin on first run
echo "Starting Placebo.mk Backend..."
# Run admin seed script (idempotent - won't recreate if exists)
echo "Checking for admin user..."
node dist/scripts/seed-admin.js
# Start the application
echo "Starting NestJS application..."
exec node dist/src/main.js