Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

267
Views
Unable to COPY config file in nginix /etc/nginx/conf.d/default.conf

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

9 months ago · Santiago Trujillo
2 answers
Answer question

0

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.

9 months ago · Santiago Trujillo Report

0

If somebody is still struggling with this....

changing the WORKDIR from app to builddir worked!

FROM node:alpine as builder 
WORKDIR '/builddir'
COPY package.json .
RUN npm install
COPY . .
RUN npm run build

FROM nginx:alpine
COPY --from=builder /builddir/build /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/conf.d
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
9 months ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.