By chatpong
I spent a day getting out of memory error building Next app from Dockerfile. It is a small app with a few pages. However, removing Dockerfile and let the app built with Buildpack results in successful deployment
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I have contacted the support team and one thing I know from them is that the App platform only has 8GB of RAM/Disk space combined available during build. So, it is not just RAM but I have to be careful about disk space also.
Spent a few days trying to tweak the Dockerfile. As Docker takes snapshot for each build step, I though I should make each layer as small as I could. So, I did install and build in one go and below is the Dockerfile I successfully deployed to the App platform
FROM node:alpine
WORKDIR /app
COPY . ./
RUN yarn install --frozen-lockfile \
&& yarn build \
&& rm -rf node_modules \
&& yarn install --production --prefer-offline \
&& yarn cache clean --all
CMD [ "yarn", "start" ]
Hope this helps everyone who is facing the same problem
Hi @chatpong,
Please find the answers to your queries inline.
What is the memory limit when build with Dockerfile and how to increase it? –> In app platform there is 8GB of RAM available during build. Currently we do not support the increase of resources during build phase for any of our users. However, that is under discussion and might get updated in the future.
Is there an example Dockerfile for Next app? –> Here’s a sample git repo for deploying a Next app using a Dockerfile. I have tested it out on App Platform. https://github.com/tahafatimaDO/next-Dockerfile
Does the container size and plan (Basic/Pro) matter? –> The container size and plan doesn’t matter during the build phase. It only comes into play during the deploy and run time.
Cheers, Taha Fatima
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.