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

Make frontend build in Docker image optional #4879

Merged
merged 9 commits into from
May 12, 2020
Merged

Conversation

arikfr
Copy link
Member

@arikfr arikfr commented May 11, 2020

What type of PR is this? (check all applicable)

  • Other

Description

A different approach to making frontend build optional by using a build arg. While a bit more hacky, it's fully supported across different Docker versions and requires less changes.

Related Tickets & Documents

#4843, #4292

Dockerfile Outdated

COPY client /frontend/client
COPY webpack.config.js /frontend/
RUN npm run build
RUN if [ "x$skip_frontend_build" = "x" ] ; then npm run build; else mkdir /frontend/client/dist && touch /frontend/client/dist/{multi_org.html,index.html}; fi
Copy link
Member Author

Choose a reason for hiding this comment

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

Create dummy index.html and multi_org.html to make backend tests work.

Dockerfile Outdated Show resolved Hide resolved
Comment on lines +12 to +15
REDASH_LOG_LEVEL: "INFO"
REDASH_REDIS_URL: "redis://redis:6379/0"
REDASH_DATABASE_URL: "postgresql://postgres@postgres/postgres"
REDASH_RATELIMIT_ENABLED: "false"
Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't directly related, but used the opportunity to reduce even more duplicates.

Copy link
Member

Choose a reason for hiding this comment

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

I think we had to fix the scheduler container for this anyway in our recent rebase: mozilla@ce5e606

@koooge
Copy link
Contributor

koooge commented May 11, 2020

I think it's a reasonable proposal. On another note, my works care about no-include requirements_dev.txt for production build. Is it possible in this PR?

By the way, Makefile is no longer update? #3038

@arikfr
Copy link
Member Author

arikfr commented May 11, 2020

I think it's a reasonable proposal. On another note, my works care about no-include requirements_dev.txt for production build. Is it possible in this PR?

202e1da

By the way, Makefile is no longer update? #3038

I never used the Makefile... It's possible it's a bit out of sync.

Dockerfile Outdated Show resolved Hide resolved
@jezdez
Copy link
Member

jezdez commented May 12, 2020

@arikfr While we're there, can we add a build argument to install an optional requirements file requirements_ext.txt if it exists? That would fix #2810.

Dockerfile Outdated Show resolved Hide resolved
@arikfr arikfr merged commit 8907a86 into master May 12, 2020
@arikfr arikfr deleted the optional-frontend-build branch May 12, 2020 13:46
@arikfr
Copy link
Member Author

arikfr commented May 12, 2020

@arikfr While we're there, can we add a build argument to install an optional requirements file requirements_ext.txt if it exists? That would fix #2810.

No need for an arg, checking if file exists is enough. But I'm not sure about the usefulness of it. It saves the person to write a single command (RUN pip install...) and requires them to understand how the Dockerfile is built... Is it really worth the hassle?

@jezdez
Copy link
Member

jezdez commented May 12, 2020

@arikfr While we're there, can we add a build argument to install an optional requirements file requirements_ext.txt if it exists? That would fix #2810.

No need for an arg, checking if file exists is enough. But I'm not sure about the usefulness of it. It saves the person to write a single command (RUN pip install...) and requires them to understand how the Dockerfile is built... Is it really worth the hassle?

It would be more than just RUN pip install.. since when inheriting from the Redash image you would have to also switch to the root user before to make sure the extensions are installed in the same location as the rest of the requirements. And then switch back to the redash user, which isn't ideal.

FROM redash/redash:preview

COPY requirements_ext.txt .
USER root
RUN pip install -r requirements_ext.txt
USER redash

But I now realize that there is the devil in the details, since I think ONBUILD is needed to make this work in a separate Dockerfile to make sure it happens at the correct build time. And ONBUILD isn't enough for frontend extensions to be installed before the webpack bundle is built. Hmm..

Maybe we should stop using webpack in favor of build-less packaging for the frontend assets like Snowpack?

@koooge koooge mentioned this pull request May 12, 2020
1 task
@arikfr
Copy link
Member Author

arikfr commented May 14, 2020

Maybe we should stop using webpack in favor of build-less packaging for the frontend assets like Snowpack?

Snowpack doesn't require build during development, but you still need to build for production/deployment.

jezdez pushed a commit to mozilla/redash that referenced this pull request May 14, 2020
* Add build arg to Dockerfile to control if we should build frontend assets

* Move more env settings into the shared one.

* Use build arg in docker-compose to skip frontend build.

* CirlceCI: Skip building frontend assets in backend tests

* Create dummy template files

* Expand file names manually.

* Add build arg to skip dev dependencies.

* Update Dockerfile

* Reverse logic of skip_dev_deps to what it should be.
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.

3 participants