Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entrypoint script #40

Merged
merged 2 commits into from
Oct 17, 2023
Merged

Add entrypoint script #40

merged 2 commits into from
Oct 17, 2023

Conversation

laurigates
Copy link
Collaborator

The entrypoint script runs migrations and creates a superuser based on environment variables.

@laurigates laurigates added the enhancement New feature or request label Oct 13, 2023
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be the right place to store Django superuser credentials? A separate env file?

entrypoint.sh Outdated
@@ -0,0 +1,5 @@
#!/bin/sh
python manage.py migrate
python manage.py createsuperuser --noinput
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually superusers are created to the database, and not in docker start. Also, it's one time thing, and something that happens differently depending on database purpose and location (local, test, prod).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it might be nice to be able to automatically create an initial superuser from environment variables that are set in secrets, during development. If it seems like an unnecessary feature or a risk, I don't mind if it's removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the user creds go into database that needs to be handled persistently, I think its place is not in container
usually automated local dev superuser creation would be set when adding fixtures/test data to the db

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, manually creating manage.py createsuperuser or loading it from a fixture is a better idea in many/all cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed superuser creation and rebased the branch.

The entrypoint script runs migrations
@laurigates laurigates merged commit a9dea2f into main Oct 17, 2023
2 checks passed
@laurigates laurigates deleted the add_entrypoint_migrations branch October 17, 2023 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants