Kevin Danikowski
Kevin Danikowski

Reputation: 5196

How to copy in node Dockerfile (folders both in container)

This is different than questions about copying from host to container.

I'm trying to copy the build folder to the nginx html folder. I don't know what copy command I should use, as cp didn't work.

My dockerfile segment (see the RUN copy command which isn't working)

FROM node:12.14.1 # If syntax is off, please ignore

WORKDIR /app
COPY . /app

RUN rm -rf node_modules &&\
    npm ci &&\
    npm run build # MAKES BUILD IN /app/build

# set up html files
COPY config/nginx.conf /etc/nginx/conf.d/default.conf
RUN cp /app/build /usr/share/nginx/html # BROKEN - HOW TO COPY STATIC FILES HERE?

Upvotes: 0

Views: 105

Answers (1)

SpaceKatt
SpaceKatt

Reputation: 1411

Have you tried using a recursive copy?

RUN cp -r /app/build /usr/share/nginx/html

(Assuming the destination folder already exists. Add a RUN mkdir -p /usr/share/nginx/html line before copying the files if it does not.)

Upvotes: 1

Related Questions