I'm trying to change de default port for a Vue.js app on docker.
I used both examples in this official documentation: https://v2.vuejs.org/v2/cookbook/dockerize-vuejs-app.html
Dockerfile with http-server:
FROM node:lts-alpine
# install simple http server for serving static content
RUN npm install -g http-server
# make the 'app' folder the current working directory
WORKDIR /app
# copy both 'package.json' and 'package-lock.json' (if available)
COPY package*.json ./
# install project dependencies
RUN npm install
# copy project files and folders to the current working directory (i.e. 'app' folder)
COPY . .
# build app for production with minification
RUN npm run build
EXPOSE 8080
CMD [ "http-server", "dist" ]
Dockerfile with nginx server:
# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
And this is my docker-compose file:
version: "3.7"
services:
admclient:
build: ../food-order-frontend-admin
image: myapp/myapp:v1.0
container_name: myapp
ports:
- "6969:whateverIExposeInDockerFile"
Both examples work, but only when their default port is being used, 8080 and 80. When using a non-default port, I get following error in browser:
crbug/1173575, non-JS module files deprecated
And nothing useful in the console. Except when docker-logging the app when it's on httpServer:
Starting up http-server, serving dist
Available on:
http://127.0.0.1:8080
http://172.19.0.2:8080
Apparently "Expose whateverPort" in Dockerfiles doesn't go through. P.S: I don't need a production-ready solution. So I would go for the fastest fix.