-
Notifications
You must be signed in to change notification settings - Fork 183
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
Migrate client-admin from gulp to webpack #1242
Conversation
Hm. The admin interface is working fine when I do a docker build locally, but failing when run in CI. Not sure what's up. |
Thanks @metasoarous I havn't actually run this code yet - I'm working on getting a fork of pol.is up and running and I have the participant and admin code compiling and running OK so I can try with these changes in - I'll let you know how I get on. |
"build:webpack_unminified": "npm run clean && NODE_ENV=development webpack --config webpack.config.unminified.js", | ||
"build": "npm run build:webpack", | ||
"build-debug": "npm run build:webpack_unminified", | ||
"deploy:prod": "node gulpfile.js deploy_TO_PRODUCTION", |
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 did a test merge of this into the compdemocracy/dev branch, but I ran into this error when trying build with docker compose
due to the removal of deploy:prod
:
Step 11/42 : RUN npm run deploy:prod
---> Running in e2442f4e8746
npm ERR! missing script: deploy:prod
npm ERR!
npm ERR! Did you mean this?
npm ERR! build:prod
I see that client-admin/Dockerfile has been updated to use build:prod
instead of deploy:prod
, but it looks like when I am building it must be running either Dockerfile or file-server/Dockerfile, which both use deploy:prod
and still reference node:11.15.0-alpine.
From looking at the docker-compose.yml file I think that it might be the file-server/Dockerfile that is making client-admin instead of client-admin/Dockerfile. I might just be doing something wrong when I build it, but it still might be good to remove gulp from the sections of Dockerfile and file-server/Dockerfile that relate to building client-admin so that they are all consistent
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.
The problem is that there is some duplication of efforts in the client build process, as you note, between the file-server/Dockerfile
and the individual client Dockerfiles. We duplicated this work into the client-server/Dockerfile
to avoid issues with Dockerfiles referencing each other in certain build environments (Heroku, podman). I think we want to try and consolidate these if possible, potentially via multi-stage builds, but we shouldn't hang this PR up on that. We should however continue to keep all of the Dockerfiles up to date, and switch everything over to build:prod
(vs deploy:prod
). So, thanks for catching this.
file-server/Dockerfile
Outdated
@@ -16,7 +16,7 @@ COPY . . | |||
COPY fs_config.template.json fs_config.json | |||
|
|||
RUN mkdir /app/build | |||
COPY --from=admin /app/build/ /app/build | |||
COPY --from=admin /app/dist/ /app/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.
@patcon Let's please keep the app/build
path. I realize the way things were set up was kind of weird in that by default things were going to dist
, unless you specified build
in the LOCAL_OUPUT_PATH
, but we should stick with the ultimate paths which were in use at the Docker level (app/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.
Sounds good, should be some small changes in webpack config and maybe places like gitignore (sorry, forget lots of what's done here atm)
Hey @patcon. Are you still interested in pushing this PR forward? Getting rid of gulp and upgrading node environment remains high priority for us, and there are an increasing number of issues blocked on it, so I want to try to get this resolved. From what I can tell, here's what we need to merge:
I'm also curious why you moved a number of files into a Thanks again |
I'm open to this! Thanks for the poke @metasoarous
That's likely quite a lot of further work, as many more deps will need to be tweaked, which will probably require other changes to codebase and maybe even substituted packages, and we'll probably want more tests for that. I worry I won't have time for the level of work that will entail, as it will be much more than just resolving a few merge conflicts imho I could offer maybe 1-2h of exploration, but if it takes more than that, I'd ask that we merge without (or someone else runs with this PR). If it's not simple, might you consider merging this smaller v14 node bump, just enough to use webpack, and push the other major upgrade into a separate upgrade cascade?
Context: Might you reconsider a request to let it in? I believe it adds value, is a widely-understood convention, and not using it would make things slightly more confusing and explicit. I suspect if you did a straw poll with react devs, they'd all recommend using a |
I'd request that this be another PR, as a matter of respect to the time I've already spent 🙏 |
Thanks for getting back on this @patcon. All fair points. If you could then please:
Thanks again! |
Woooo excited to find time for this. Thanks man |
Hey @patcon. Any updates on this? We have a number of other issues blocked on it, so I'd like to get a sense of whether you're still keen to push through to completion. If you're not able to right now, that's fine; I can pick it up from here, but wanted to give you the opportunity to wrap it up first. Please let me know either way when you get a chance. Thanks! |
Hey Chris, sorry, been busy with some event stuff. I'm going to give myself until this weekend, after which I should officially release this back to you and stop blocking. Would that work? |
Hey Pat. That's fine. Thanks for letting me know. |
This is so rad! Thanks so much for digging this out of my 80%-hole @metasoarous :) |
* Migrate client-admin from gulp to webpack (compdemocracy#1242) * First-pass gulp-to-webpack conversion. * Update webpack-cli, and create prod/dev logic. * Messy: leave uncompressed files in dev mode build. * Shut off compression in dev mode more elegantly. * Get docker build working. * Fixed bundlewatch path to find client-admin files. * Get rid of old webpack build scripts. * Don't minify for dev build. * Removed dep pkgs for s3 deploy. * Added ability to use bundle analyzer plugin. * Removed all unneeded files. * Fixed up eslint issue with upgraded packages. * Fixed bundlewatch CI script. * Keep new client-admin bundle consistently named. * Try running e2e tests against sslip.io instead of localhost. * Escape the domainWhitelist strings as it was done before. * Revert "Try running e2e tests against sslip.io instead of localhost." This reverts commit 46722d0. * Oops. Inversed the boolean for configs. * Trying to debug index_admin.html issue. * Added upterm for remote debugging. * Ensure upterm runs on failures. * Added publicPath to make script link absolute. * Drop the embed.html test file into new home. * Ensuring dev mode builds and dev server use same simplifications. * Set up all routes to point to index.html. Added mention of future proxy. * Removed debugging step from github actions. * Tiny fixups to clean up PR. * Only write headerJson files during prod build. * Migrate from dist to more build as before. * Removed unneeded config vars. * Cleaned up webpack dev-mode logic. * Went back to using dist folder to fix bundle-analyzer bug. * Updated client-admin README. Removed badges. Removed deployment references. * Cleaned up ignorefiles. * Mention where builds happen. * Use build instead of dist for client-admin build output * switch to npm run build:prod in file-server/Dockerfile * inject compiled js in html body for client-admin * add/update webpack versions Co-authored-by: Christopher Small <metasoarous@gmail.com> * Adding farsi translation (compdemocracy#1560) * Adding farsi translation * Update client-participation/js/strings.js Co-authored-by: Patrick Connolly <patrick.c.connolly@gmail.com> Co-authored-by: Colin Megill <colinmegill@gmail.com> Co-authored-by: Patrick Connolly <patrick.c.connolly@gmail.com> * German language editing (compdemocracy#1552) * Bump node from 11.15.0-alpine to 18.9.0-alpine in /client-admin (compdemocracy#1523) Bumps node from 11.15.0-alpine to 18.9.0-alpine. --- updated-dependencies: - dependency-name: node dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump node from 11.15.0-alpine to 18.9.0-alpine in /client-report (compdemocracy#1525) Bumps node from 11.15.0-alpine to 18.9.0-alpine. --- updated-dependencies: - dependency-name: node dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump moment from 2.29.1 to 2.29.4 in /client-report (compdemocracy#1514) Bumps [moment](https://github.com/moment/moment) from 2.29.1 to 2.29.4. - [Release notes](https://github.com/moment/moment/releases) - [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md) - [Commits](moment/moment@2.29.1...2.29.4) --- updated-dependencies: - dependency-name: moment dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump ws from 7.4.2 to 7.5.7 in /client-admin (compdemocracy#1395) Bumps [ws](https://github.com/websockets/ws) from 7.4.2 to 7.5.7. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](websockets/ws@7.4.2...7.5.7) --- updated-dependencies: - dependency-name: ws dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump got and nodemon in /server (compdemocracy#1539) Removes [got](https://github.com/sindresorhus/got). It's no longer used after updating ancestor dependency [nodemon](https://github.com/remy/nodemon). These dependencies need to be updated together. Removes `got` Updates `nodemon` from 2.0.7 to 2.0.20 - [Release notes](https://github.com/remy/nodemon/releases) - [Commits](remy/nodemon@v2.0.7...v2.0.20) --- updated-dependencies: - dependency-name: got dependency-type: indirect - dependency-name: nodemon dependency-type: direct:development ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump y18n from 3.2.1 to 3.2.2 in /client-report (compdemocracy#932) Bumps [y18n](https://github.com/yargs/y18n) from 3.2.1 to 3.2.2. - [Release notes](https://github.com/yargs/y18n/releases) - [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md) - [Commits](https://github.com/yargs/y18n/commits) Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump minimist from 1.2.5 to 1.2.6 in /client-admin (compdemocracy#1384) Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6. - [Release notes](https://github.com/substack/minimist/releases) - [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6) --- updated-dependencies: - dependency-name: minimist dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update de_de.js Checked german language (native speaker). Corrected some inconsistencies and grammar errors. * Update de_de.js * Update de_de.js * Revert "Bump node from 11.15.0-alpine to 18.9.0-alpine in /client-admin (compdemocracy#1523)" This reverts commit 0d1242f. * Revert "Bump node from 11.15.0-alpine to 18.9.0-alpine in /client-report (compdemocracy#1525)" This reverts commit 54ed279. * Revert "Bump moment from 2.29.1 to 2.29.4 in /client-report (compdemocracy#1514)" This reverts commit 4e7dd51. * Revert "Bump ws from 7.4.2 to 7.5.7 in /client-admin (compdemocracy#1395)" This reverts commit 0224f8e. * Revert "Bump got and nodemon in /server (compdemocracy#1539)" This reverts commit 0c18e1e. * Revert "Bump minimist from 1.2.5 to 1.2.6 in /client-admin (compdemocracy#1384)" This reverts commit 0e8263b. Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Christopher Small <metasoarous@gmail.com> * Update CHANGELOG * Remove boolean, DISABLE_PLANS and DISABLE_INTERCOM * Tidied up package.json * Remove advice on cache clear - not needed for NPM > 5 * Rebuilt package-lock for e2e to fix tests Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Patrick Connolly <patrick.c.connolly@gmail.com> Co-authored-by: Christopher Small <metasoarous@gmail.com> Co-authored-by: Hadjar Homaei <hadjar@gmail.com> Co-authored-by: Colin Megill <colinmegill@gmail.com> Co-authored-by: SvenSt-BIE <115692202+SvenSt-BIE@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
gulp.task("configureForProduction", function (callback) { | ||
devMode = false; | ||
destRootBase = "dist"; | ||
|
||
console.log("getGitHash begin"); | ||
// NOTE using callback instead of returning a promise since the promise isn't doing the trick - haven't tried updating gulp yet. | ||
getGitHash() | ||
.then(function (hash) { | ||
var d = new Date(); | ||
var tokenParts = [ | ||
d.getFullYear(), | ||
d.getMonth() + 1, | ||
d.getDate(), | ||
d.getHours(), | ||
d.getMinutes(), | ||
d.getSeconds(), | ||
]; | ||
|
||
if (hash) { | ||
hash = hash.toString().match(/[A-Za-z0-9]+/)[0]; | ||
tokenParts.push(hash); | ||
} | ||
|
||
var unique_token = tokenParts.join("_"); | ||
destRootRest = [staticFilesPrefix, unique_token].join("/"); | ||
versionString = unique_token; | ||
|
||
console.log( | ||
"done setting destRoot: " + | ||
destRoot() + | ||
" destRootRest: " + | ||
destRootRest + | ||
" destRootBase: " + | ||
destRootBase | ||
); | ||
callback(null); | ||
}) | ||
.catch(function (err) { | ||
console.error("getGitHash err"); | ||
console.error(err); | ||
callback(true); | ||
}); | ||
}); |
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 actually needed this part of the routine for caching to work properly
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.
Webpack takes care of 'cache busting' Javascript import for you - in webpack.config.js
line 32 it uses a 'magic' string [chunkhash:8]
to generate a random 8 character string and puts that in the output filename. In the HtmlWebpackPlugin
it is injected into the HTML body when it is processed - some earlier discussion into this is at https://github.com/compdemocracy/polis/pull/1242/files#r776461657
"/dist/admin_bundle.js", | ||
"/" + [destRootRest, "js", "admin_bundle.js"].join("/") | ||
); | ||
html = html.replace("NULL_VERSION", versionString); |
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 don't know if we needed this or not
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.
This value is written but never read in the codebase so presumably it is a human readable version. There is some argument to be said that maybe this should be displayed visually so we know which version of the front-end we are looking at. In polis-whitelabel
I actually mapped this to the package.json
version with the view of later setting up formal releases.
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.
That's what I thought, but thanks for doing some legwork to confirm!
We've been thinking about displaying version string as you suggest, and are interested in any ideas about it you might have.
Addresses #90
This is a work-in-progress, but could use some feedback on approach :)
Current status:
npm run build:dev
exists for unminified/uncompressed builds intodist/
npm run build:prod
exists for minified/compressed builds (as required for file-server)npm run analyze
webpack-dev-server
The tests should pass with this 🎉 🤞
Open Questions
EDIT: I have feature parity for "webpack-based s3 deploy" code already written, so it's just a matter of copy-pasting it in here if we want to keep it