Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
174
rated 0 times [  175] [ 1]  / answers: 1 / hits: 19938  / 5 Years ago, wed, july 3, 2019, 12:00:00

Unable to Copy config file in my project dir to /etc/nginx/conf.d/default.conf



source file location:
/app/nginix.conf



COPY nginx.conf /etc/nginx/conf.d/default.conf



destination : /etc/nginx/conf.d/default.conf



Steps in docker file :



Tried the multi stage build:

- FROM node:8.9.0 as buid
- WORKDIR /app
- COPY package.json package-lock.json ./
- RUN npm install
- COPY . ./
- RUN npm run build


- FROM nginx:alpine
- RUN mkdir -p /var/www/html/client
- COPY --from=buid /app/nginix.conf /etc/nginx/conf.d/default.conf
- COPY --from=buid /app/build/ /var/www/html/client


Tried commenting the first copy command, and it was able to copy the build and it was good.
when it is able to find the build in the app dir why is it not able to find the nginix.conf file which is also in the same dir, did a ls -la and saw the nginix.conf file.



TIA


More From » reactjs

 Answers
24

If the source file path is /app/nginix.conf then dockefile should contain:



COPY /app/nginx.conf /etc/nginx/conf.d/default.conf


If you're running docker build command from /app directory on your host then your above dockerfile should work.



Update:



If you're expecting /app/nginx.conf file of node docker image to present in nginx:alpine image then you need to use multi-stage docker builds.



Change your dockerfile to



FROM node as build
WORKDIR /app
COPY package json files
RUN npm build

FROM nginx:alpine
COPY --from=build /app/nginx.conf /etc/nginx/conf.d/default.conf


This will copy /app/nginx.conf file from node image to nginx:alpine image.


[#51927] Thursday, June 27, 2019, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaydenathaliam

Total Points: 676
Total Questions: 102
Total Answers: 103

Location: San Marino
Member since Thu, Jun 30, 2022
2 Years ago
;