Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

634
Visualizações
npm build doesn't work properly in docker under ubuntu

I have the following Dockerfile (building a Vue.js app):

# build stage
FROM node:lts-alpine as build-stage
RUN apk add gettext libintl
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
ARG API_URL
RUN envsubst < ./src/config.js.tmpl > ./src/config.js
RUN ls
RUN npm run build
RUN ls

# production-stage
FROM nginx:stable-alpine as production-stage
ARG API_PROXY_PATH
ARG SERVER_NAME
COPY --from=build-stage /app/dist /usr/share/nginx/html
COPY ./nginx/prod.conf.tmpl /temp/prod.conf.tmpl
RUN envsubst '$API_PROXY_PATH $SERVER_NAME' < /temp/prod.conf.tmpl > /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

This works fine on my Windows machine (with Docker Toolbox) and on Centos7 machine. Application build and runs fine.

But when I'm trying to build this on a server with Ubuntu 18.04 (also tried 16.04) npm run build doesn't seem to work correctly. It runs as usual and doesn't throw any errors, but after the build dist folder is missing and thus the second stage fails.

On Windows and Centos desktop second ls command shows the following:

Dockerfile
README.md
babel.config.js
dist
nginx
node_modules
package-lock.json
package.json
public
src

But on Ubuntu dist folder doesn't appear.

Dockerfile
README.md
babel.config.js
nginx
node_modules
package-lock.json
package.json
public
src

Docker and docker-compose versions are the same. Why is that happening and how to fix it? I have no idea :( Thanks in advance.

UPD: I've tried to create Centos server, and it shows the same behavior (dist folder is not created), though it works ok on Centos desktop. In both cases code was retrieved from github via git clone. So probably it's not an OS issue.

UPD2: Very strange things are happening. I've tested this everywhere I could and failed to reproduce it, so my hypothesis is that the issue is somehow related to my VPS provider. The build works fine on Windows desktop (Docker Toolbox), Centos7 desktop, Ubuntu Desktop in VirtualBox and Ubuntu Server in VB and also on virtual machine from another VPS provider. It just doesn't work on VPSs (both Ubuntu and Centos7) from my initial VPS provider. I'm going to contact their support.

Here is the repo to reproduce: https://github.com/DanielTitkov/pagie It can be built with docker-compose just as is, only .env.dist should be renamed to .env

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda