Closed owlyowl closed 11 months ago
Hi 👋
Thank you for your feedback! This is something we are going to work towards resolving.
Thanks Liz Most appreciated!
It would be great for a prod build to output only what is needed to run the entire apl in an output directory or a standard remix style server client split
On Thu, Nov 2, 2023, 3:10 AM Liz Kenyon @.***> wrote:
Hi 👋
Thank you for your feedback! This is something we are going to work towards resolving.
— Reply to this email directly, view it on GitHub https://github.com/Shopify/shopify-app-template-remix/issues/378#issuecomment-1789236112, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOT4CW2HZN4XVUTZQVQGUDYCJX6XAVCNFSM6AAAAAA6BOR4FWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBZGIZTMMJRGI . You are receiving this because you authored the thread.Message ID: @.***>
You should at least prune the dev dependencies in your Dockerfile. Here is what I am using to get a smaller image:
FROM node:18-alpine as build
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
ENV NODE_ENV=production
RUN npm run build
RUN npm prune --omit=dev
FROM node:18-alpine
WORKDIR /usr/src/app
COPY --from=build /usr/src/app .
EXPOSE 3000
USER node
CMD ["npm", "run", "docker-start"]
I would have thought things like shopify-cli should be devDependencies as well..
On Thu, Nov 2, 2023 at 10:44 PM Jason @.***> wrote:
You should at least prune the dev dependencies in your Dockerfile. Here is what I am using to get a smaller image:
FROM node:18-alpine as build WORKDIR /usr/src/app COPY package*.json ./ RUN npm install COPY . . ENV NODE_ENV=production RUN npm run build RUN npm prune --omit=dev
FROM node:18-alpine WORKDIR /usr/src/app COPY --from=build /usr/src/app . EXPOSE 3000 USER node CMD ["npm", "start"]
— Reply to this email directly, view it on GitHub https://github.com/Shopify/shopify-app-template-remix/issues/378#issuecomment-1790570971, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOT4CWL5RGG27G7HMPPDQ3YCOBQDAVCNFSM6AAAAAA6BOR4FWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJQGU3TAOJXGE . You are receiving this because you authored the thread.Message ID: @.***>
Yeh they really should, though some people may still want access to the CLI within Docker (might just be running it locally instead of installing Node/NPM on their machines).
Thanks for your comments, folks. I quite like the approach of using a separate image to build the app and then just using the built files, I'll look into updating it to something close to that.
As for the CLI, unfortunately, it needs to be a dependency (as in, not a dev dep) because it has some automations that use the actual dependencies.
We can always just npm remove
the CLI packages as part of the build step, and any apps that want to run CLI commands could just remove those lines from their Dockerfile. That seems to shake off 100MB+ from node_modules, bringing it just under 300MB.
Thanks Paulo! Really appreciate it
On Thu, Nov 16, 2023, 2:24 AM Paulo Margarido @.***> wrote:
Closed #378 https://github.com/Shopify/shopify-app-template-remix/issues/378 as completed via #418 https://github.com/Shopify/shopify-app-template-remix/pull/418.
— Reply to this email directly, view it on GitHub https://github.com/Shopify/shopify-app-template-remix/issues/378#event-10968831359, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOT4CXZMPSOMMP5DCEBHRLYETNCXAVCNFSM6AAAAAA6BOR4FWVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJQHE3DQOBTGEZTKOI . You are receiving this because you authored the thread.Message ID: <Shopify/shopify-app-template-remix/issue/378/issue_event/10968831359@ github.com>
Issue summary
When packaging up in Docker. I can see it is simply copying everything over including around 554mb of
node_modules
content.For deploying in to other environments I was wondering if there were any plans to tree shake/filter out unused node_modules - e.g. Shopify cli and others and establish a list of dependencies just required to host/deploy the application.
Here was a cutdown
node_modules
output I managed to get the application building with: