By luisSnorkler
Problem I’m using App Platform to serve a React (using Create React App) static website. I’m using Docker in order to have predictable and abstracted builds (as well as other reasons)
But whenever I try to deploy it to DO’s App Platform I get build errors essentially saying that it can’t find the output directory. Such as ‘client | 19:44:34 ! /app/build does not exist within the built container’
App.yaml
name: project_name
static_sites:
- name: client
dockerfile_path: ./client/Dockerfile
github:
repo: valencian-digital/unique-expressions
branch: master
source_dir: client
output_dir: /app/build
Dockerfile
FROM node:14-alpine
WORKDIR /app
VOLUME /app
ENV NODE_ENV=production
COPY . .
CMD ["npm", "run", "build"]
Question How can I get a Dockerfile to work property with App Platform static sites?
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!
To get this to work you should move the npm run build to be a RUN rather than CMD. The app platform build process will run all the steps that are part of a docker build. The CMD is set as a default start command for the container, but doesn’t get executed during the build process. The process to build a static site copies the files out of the built docker container image.
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.