From efaaece842229acaa1fcde136d2f4a5fa8a3008a Mon Sep 17 00:00:00 2001 From: Ilya Kreymer Date: Sun, 5 Dec 2021 18:39:45 -0800 Subject: [PATCH] Optimizing Frontend Dockerfile (#60) * optimizing frontend dockerfile: - run install first to cache node_modules - don't pass node_modules to image - add only needed files before build * remove language file generation from build step Co-authored-by: sua yoo --- frontend/.dockerignore | 1 + frontend/.gitignore | 1 - frontend/Dockerfile | 14 ++-- frontend/README.md | 6 -- frontend/package.json | 3 +- frontend/src/__generated__/locale-codes.ts | 23 ++++++ frontend/src/__generated__/locales/en-US.ts | 85 +++++++++++++++++++++ 7 files changed, 118 insertions(+), 15 deletions(-) create mode 100644 frontend/.dockerignore create mode 100644 frontend/src/__generated__/locale-codes.ts create mode 100644 frontend/src/__generated__/locales/en-US.ts diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 00000000..c2658d7d --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1 @@ +node_modules/ diff --git a/frontend/.gitignore b/frontend/.gitignore index 8db5a253..35a4c157 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -25,4 +25,3 @@ storybook-static custom-elements.json -src/__generated__ diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 6c2df9ae..e28a726a 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,18 +1,20 @@ FROM node:16 as build WORKDIR /app -COPY . . -# disabled to speed up build, assuming built locally -#RUN yarn +COPY package.json . +COPY yarn.lock . +RUN yarn --frozen-lockfile +COPY *.* ./ +COPY src ./src/ +COPY scripts ./scripts/ RUN yarn build + FROM nginx COPY --from=build /app/dist /usr/share/nginx/html -COPY --from=build /app/nginx.conf.template /etc/nginx/templates/ -#COPY ./dist /usr/share/nginx/html -#COPY ./nginx.conf.template /etc/nginx/templates/ +COPY ./nginx.conf.template /etc/nginx/templates/ RUN rm /etc/nginx/conf.d/* diff --git a/frontend/README.md b/frontend/README.md index 75034e9c..dbed8ef0 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -14,12 +14,6 @@ Install dependencies: yarn ``` -Generate locale files: - -```sh -yarn localize:build -``` - Start the dev server: ```sh diff --git a/frontend/package.json b/frontend/package.json index 554028bf..4d2483a8 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -19,8 +19,7 @@ }, "scripts": { "test": "web-test-runner \"src/**/*.test.{ts,js}\" --node-resolve --playwright --browsers chromium", - "prebuild": "del-cli ./dist && npm run env:sync && npm run localize:build", - "prebuild-dev": "npm run localize:build", + "prebuild": "del-cli ./dist && npm run env:sync", "build": "webpack --config webpack.prod.js", "build-dev": "webpack --mode development", "start": "webpack serve --mode=development", diff --git a/frontend/src/__generated__/locale-codes.ts b/frontend/src/__generated__/locale-codes.ts new file mode 100644 index 00000000..8ab8586d --- /dev/null +++ b/frontend/src/__generated__/locale-codes.ts @@ -0,0 +1,23 @@ +// Do not modify this file by hand! +// Re-generate this file by running lit-localize. + +/** + * The locale code that templates in this source code are written in. + */ +export const sourceLocale = `en`; + +/** + * The other locale codes that this application is localized into. Sorted + * lexicographically. + */ +export const targetLocales = [ + `en-US`, +] as const; + +/** + * All valid project locale codes. Sorted lexicographically. + */ +export const allLocales = [ + `en`, + `en-US`, +] as const; diff --git a/frontend/src/__generated__/locales/en-US.ts b/frontend/src/__generated__/locales/en-US.ts new file mode 100644 index 00000000..8b3c31e8 --- /dev/null +++ b/frontend/src/__generated__/locales/en-US.ts @@ -0,0 +1,85 @@ + + // Do not modify this file by hand! + // Re-generate this file by running lit-localize + + + import {str} from '@lit/localize'; + + /* eslint-disable no-irregular-whitespace */ + /* eslint-disable @typescript-eslint/no-explicit-any */ + + export const templates = { + 's9d8b8aa2b404c2c8': `Settings`, +'s9f5a5f23312798f0': `Members`, +'sec0b5ace6765b2a5': str`Successfully invited ${0}`, +'s5e155029a998ab6e': `Add Member`, +'sef49aec68fd1dc66': `Name`, +'s6b2beba7ab637e9e': `Roles`, +'s751678adb0aa2b23': `Member`, +'saae1c70e168b45b4': `Admin`, +'s70b4765cad7bc7cf': `Viewer`, +'s30b4465e07017074': `Back to members list`, +'s049cf53ee4e03bd8': `Add New Member`, +'s57ade424d57c6edf': `Sent`, +'s686306cdb839fb8d': `Sending...`, +'s97ee1bd2cffede65': `Resend verification email`, +'sb64c8390aa317e05': `verified`, +'s4b8701e4b2749e82': `unverified`, +'se85a9ddb91124b39': `Account settings`, +'sd1f44f1a8bc20e67': `Email`, +'sff50532a2d85e32e': `Change password`, +'sfee74640068abc13': `Current password`, +'s3490e2c8b9ec6ad2': `New password`, +'s3794c596ee7964ad': `Update password`, +'s2ceb11be2290bb1b': `Cancel`, +'s60de4a2ab0305e6f': `Wrong password`, +'s3acf6c15de666f7a': `Something went wrong changing password`, +'s36443da197811866': `team-member@email.com`, +'s3de802d9375580c8': `Can start & configure crawls and invite others`, +'s091bfc93121283a6': `Can view crawls`, +'s2afc9a717c161490': `Invite`, +'s2f30d4261790b785': `Something unexpected went wrong`, +'s13786b2be911ee8b': `person@email.com`, +'s9ad1286ef798a58d': `Joining as`, +'s67a47f83f4c07f04': `Enter your email`, +'s115ed3de58eca847': `you@email.com`, +'s6880074d73c3156b': `Create a password`, +'sa9d1dd5d6142477d': `Your name`, +'sc90335b573830bad': `Lisa Simpson`, +'s137af9f7040dc2d2': `(optional)`, +'sdf57c174052aef12': `Your name will be visible to archive collaborators.`, +'s5e6b698a2ec87331': `Sign up`, +'sa2a3411699d81b86': `Invalid email address or password`, +'sec77d4da6a57f2b7': `Page not found`, +'s8f392679ac01fa81': `Successfully signed up`, +'s694b98572e690336': `Click the link in the verification email we sent you to log in.`, +'s67c74844cd95f5fe': `Sign in with password`, +'s7d44a141de0e2c9b': `Forgot your password?`, +'sf6e1665c7022a1f8': `Password`, +'scb04435672ac5410': `Log in`, +'s9ada74585cd89b16': `Your email address`, +'sb6f5b47cf81180bc': `Request password reset`, +'sbf550ad9b31a5f6d': `Sorry, invalid username or password`, +'s43ae2b49c3470555': `Something went wrong, couldn't sign you in`, +'sd3fd65e8d242ed24': `Successfully received your request. You will receive an email to reset your password if your email is found in our system.`, +'s6d37a6bebbc3f8a8': `That email is not a valid email address`, +'s4bfc62609ee1cee2': `Archives`, +'sb971debc37bf0b54': `Owner`, +'s97f86b9ebc519523': `Join archive`, +'s90e89da8d3140a87': `This invitation is not valid.`, +'s7ebc4f216d73836f': `This verification email is not valid.`, +'s95689a99051fa841': `Email address verified`, +'s8759f1186d757714': `Log in to continue.`, +'s3f35c026ab278525': `Resend password reset email?`, +'s00ac24e5b7cc64c2': `Password reset email is not valid. Request a new password reset email`, +'s0aaaa9b770ff1a59': `Invalid password`, +'s7d90fb0e2d1684a7': str`Sent invite to ${0}`, +'s586d6bd2eca2da93': `Users`, +'se5cde7fdda328454': `admin`, +'s5b8c89c6fdc51c40': `Invite Users`, +'s47d31e4dbe55f7d9': `Browsertrix Cloud`, +'s48fd2ebd801bef61': `Your account`, +'sa03807e44737a915': `Log Out`, +'sca974356724f8230': `Log In`, + }; + \ No newline at end of file