3

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

Daniel Titkov
  • 922
  • 1
  • 9
  • 14
  • maybe user has no permissions? try to mkdir dist yourself and set permissions RUN CHMOD... – Javier Aviles May 14 '19 at 11:26
  • I've tried to create user and working directory like in this example https://www.digitalocean.com/community/tutorials/how-to-build-a-node-js-application-with-docker but it didn't help( – Daniel Titkov May 14 '19 at 13:55
  • can you paste contents of package.json here? also, ls output of Ubuntu? Also, I am interested if node modules folder is creates or not in your build-stage – deosha May 14 '19 at 14:59
  • ls output on Ubuntu is the same except for `dist` folder. `node_modules` folder is present. It's contents are also ok: modules are there. package.json is the following: https://github.com/DanielTitkov/pagie/blob/master/frontend-material/package.json – Daniel Titkov May 14 '19 at 17:06

0 Answers0