-
Notifications
You must be signed in to change notification settings - Fork 8
Docker postgres config for NextJS template #422
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| FROM postgres:latest | ||
|
|
||
| RUN rm -rf /var/lib/postgresql/data | ||
| COPY ./schema.sql /docker-entrypoint-initdb.d/ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The app template should provide a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you give me any more context on this? I used the separate Docker image for the DB because it seemed like the easiest way to pull in initial schema with a sql script. I see that the example you reference runs a Ruby tool called Rake for DB migration. NextJS doesn't have a direct equivalent. What would it look like to follow the pattern you describe without Ruby?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
While it does not seem like we are looking to support a DB in hosted environments here, we should build towards the established patterns. Ideally this should be ensure the postgres client/libraries are available in the container environment, provide a
It should be appropriate to the application framework. In this case if we don't have an actual DB library to use, we should use |
||
|
|
||
| EXPOSE 5432 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ services: | |
| build: | ||
| context: . | ||
| target: dev | ||
| depends_on: | ||
| - {{ app_name }}-database | ||
| env_file: | ||
| - ./.env | ||
| # Add your non-secret environment variables to this file: | ||
|
|
@@ -16,6 +18,8 @@ services: | |
| restart: always | ||
| ports: | ||
| - {{ app_local_port }}:{{ app_local_port }} | ||
| networks: | ||
| - {{ app_name }}-network | ||
|
|
||
| {{ app_name}}-storybook: | ||
| build: | ||
|
|
@@ -30,3 +34,28 @@ services: | |
| restart: always | ||
| ports: | ||
| - 6006:6006 | ||
|
|
||
| {{ app_name }}-database: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should follow a similar pattern as is established for the other templates:
(they are not quite normalized yet, but everything should eventually converge) Which here looks like:
Given the Next.js template is often used to build client-side only apps, could also make the DB part conditional on a template variable, but I think we can cross that bridge later as it's easy enough to delete or comment out the DB block if you don't want it. |
||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile.db | ||
| environment: | ||
| POSTGRES_PASSWORD: secret123 | ||
| POSTGRES_USER: app | ||
| healthcheck: | ||
| test: "pg_isready --username=app" | ||
| timeout: 10s | ||
| retries: 20 | ||
| ports: | ||
| - "5432:5432" | ||
| volumes: | ||
| - {{ app_name }}-database_data:/var/lib/postgresql/data | ||
| networks: | ||
| - {{ app_name }}-network | ||
|
|
||
| volumes: | ||
| {{ app_name }}-database_data: | ||
|
|
||
| networks: | ||
| {{ app_name }}-network: | ||
| driver: bridge | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| CREATE DATABASE {{ app_name }}; | ||
|
|
||
| \c {{ app_name }}; | ||
|
|
||
| -- Add table creation and initialization below this line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can drop this section. The current workflow suggested is still pretty much to develop in a template instance first, then backport to template. I think we'll want to centralize/coordinate doc updates across all the templates for updates to this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would a user who has pulled down template-application-nextjs know to look to the documentation you reference? I'm not seeing any guidance on the development process within template-application-nextjs, which creates a confusing situation for a developer who wants to contribute an update.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A good question that needs a consistent (and somewhat centralized) answer across Strata templates. There's a variety of things that need to be pulled together, so let's avoid scattering info further for the moment.