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

Optimize Docker for production builds #169

Merged
merged 8 commits into from
Jul 10, 2023
Merged

Optimize Docker for production builds #169

merged 8 commits into from
Jul 10, 2023

Conversation

sawyerh
Copy link
Contributor

@sawyerh sawyerh commented Jul 1, 2023

Ticket

#83, #108

Changes

  • Enable Next.js's standalone build option1, which should reduce the size of deployments:

    This feature helps reduce the size of deployments drastically. Previously, when deploying with Docker you would need to have all files from your package's dependencies installed to run next start. Starting with Next.js 12, you can leverage Output File Tracing in the .next/ directory to only include the necessary files.

  • Update the Dockerfile to utilize the standalone build output, which should resolve Productionize Docker image #83

  • Disable the lazyCompilation option in Storybook, which resolved Storybook doesn't fully work when ran within Docker #108

Testing

Verified locally. You can test by going into the app/ directory and running these in separate terminals:

  1. make dev
  2. make storybook

To test the Production build:

  1. make release-build

Footnotes

  1. https://nextjs.org/docs/app/api-reference/next-config-js/output

@sawyerh sawyerh marked this pull request as ready for review July 1, 2023 01:42
@sawyerh sawyerh requested a review from a team July 1, 2023 01:42
Copy link

@Nava-JoshLong Nava-JoshLong left a comment

Choose a reason for hiding this comment

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

Looks good, just some minor nits so it is more like the Flask template repo. We have the stages all in one file there, and you specify which stage you want to run in the command or in the docker-compose file you're running

app/Dockerfile Outdated Show resolved Hide resolved
app/Dockerfile.dev Outdated Show resolved Hide resolved
docker-compose.dev.yml Outdated Show resolved Hide resolved
docker-compose.dev.yml Outdated Show resolved Hide resolved
… into sawyerh/83-docker-prod

# Conflicts:
#	app/.storybook/preview.js
#	app/src/pages/_app.tsx
Copy link

@Nava-JoshLong Nava-JoshLong left a comment

Choose a reason for hiding this comment

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

LGTM, just 2 small nits

app/Makefile Outdated Show resolved Hide resolved
app/Makefile Outdated Show resolved Hide resolved
@sawyerh sawyerh merged commit 38cc89a into main Jul 10, 2023
6 checks passed
@sawyerh sawyerh deleted the sawyerh/83-docker-prod branch July 10, 2023 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Storybook doesn't fully work when ran within Docker Productionize Docker image
2 participants