-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Split Dockerfile for production #4292
Conversation
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.
Thanks. I was thinking of creating a separate file for development for quite some time now.
See comments.
Dockerfile.dev
Outdated
FROM node:10 as frontend-builder | ||
|
||
WORKDIR /frontend | ||
COPY package.json package-lock.json /frontend/ | ||
RUN npm install | ||
|
||
COPY client /frontend/client | ||
COPY webpack.config.js /frontend/ | ||
RUN npm run build | ||
|
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.
Now that we have a dedicated Docker file for development we no longer need this here, as we build frontend assets on the host.
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.
By deleted this build step, then the some tests which depend on client/dist/ became to fail. So I changed index handler to return 200 with error.html in that TemplateNotFound case 6ab16ec
build: ../ | ||
build: | ||
context: ../ | ||
dockerfile: Dockerfile.dev |
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.
In CircleCI we don't build assets outside of the Docker container, so I wonder how the the tests are passing? Is it because of the exception handling in static.py
?
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.
Right. Some test cases of backend depend on the build assets.
redash/handlers/static.py
Outdated
message = "Missing template file ({}). Did you build the frontend assets with npm?".format(e.name) | ||
else: | ||
message = "Error Rendering Page." | ||
response = render_template("error.html", error_message=message) |
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.
I realized that this needs to be a response with status code 500.
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.
Yes, actually it should return 404 or 500. But it returns 200 due to backend test 🤔
#4292 (comment)
sudo apt install -y nodejs | ||
npm install | ||
npm run build | ||
docker cp ./client/dist ${COMPOSE_PROJECT_NAME}_redash_1:/app/client/ |
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.
Build Frontend For Backend Test! 😢
Signed-off-by: koooge <koooooge@gmail.com>
Signed-off-by: koooge <koooooge@gmail.com>
Signed-off-by: koooge <koooooge@gmail.com>
Signed-off-by: koooge <koooooge@gmail.com>
Signed-off-by: koooge <koooooge@gmail.com>
Signed-off-by: koooge <koooooge@gmail.com>
Superseded by #4879 |
What type of PR is this? (check all applicable)
Description
Hi there.
This PR splits Dockerfile for production(Dockerfile) from development(Dockerfile.dev) to reduce dev dependencies(requirements_dev) influence and size.
Related Tickets & Documents
Mobile & Desktop Screenshots/Recordings (if there are UI changes)