Add some more docs and streamline entrypoint
This commit is contained in:
@ -10,8 +10,12 @@ RUN npm ci
|
||||
|
||||
FROM deps AS develop
|
||||
WORKDIR /app
|
||||
COPY dev-entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
RUN cat /entrypoint.sh
|
||||
ENV NODE_ENV=development
|
||||
EXPOSE 3333
|
||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||
|
||||
# Production only deps stage
|
||||
FROM base AS production-deps
|
||||
|
@ -4,6 +4,11 @@ import { faker } from '@faker-js/faker'
|
||||
|
||||
export default class extends BaseSeeder {
|
||||
public async run () {
|
||||
const usersExist = await User.query().first()
|
||||
if (usersExist) {
|
||||
console.log('Database already seeded, skipping...')
|
||||
return
|
||||
}
|
||||
const users = Array.from({ length: 1000 }).map(() => ({
|
||||
fullName: faker.person.fullName(),
|
||||
email: faker.internet.email(),
|
||||
|
23
examples/fullstack/backend/dev-entrypoint.sh
Executable file
23
examples/fullstack/backend/dev-entrypoint.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "starting up..."
|
||||
node ace generate:key
|
||||
|
||||
|
||||
# Check for pending migrations by parsing output
|
||||
PENDING_MIGRATIONS=$(node ace migration:status | grep -ic 'pending')
|
||||
|
||||
# Run migrations only if there are pending ones
|
||||
|
||||
if [ "$PENDING_MIGRATIONS" -gt 0 ]; then
|
||||
echo "Found $PENDING_MIGRATIONS pending migration(s). Running migrations..."
|
||||
node ace migration:run --force
|
||||
else
|
||||
echo "No pending migrations."
|
||||
fi
|
||||
|
||||
echo "Seeding database..."
|
||||
node ace db:seed
|
||||
|
||||
# Start the dev server
|
||||
node ace serve --watch
|
Reference in New Issue
Block a user