Reputation: 107
My problem is that I cna't see my application on the broswer (http://localhost:1999/), My docker command are this: docker-compose build docker-compose up
I'm doing something wrong? Why can't I see my application running? I tried to add the CMD line with ng -serve but it give me the error that ng isn't istalled, any other suggest?
My docker console:
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2022/08/26 13:47:26 [notice] 1#1: using the "epoll" event method
2022/08/26 13:47:26 [notice] 1#1: nginx/1.23.1
2022/08/26 13:47:26 [notice] 1#1: built by gcc 11.2.1 20220219 (Alpine 11.2.1_git20220219)
2022/08/26 13:47:26 [notice] 1#1: OS: Linux 5.10.16.3-microsoft-standard-WSL2
2022/08/26 13:47:26 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2022/08/26 13:47:26 [notice] 1#1: start worker processes
2022/08/26 13:47:26 [notice] 1#1: start worker process 32
2022/08/26 13:47:26 [notice] 1#1: start worker process 33
2022/08/26 13:47:26 [notice] 1#1: start worker process 34
2022/08/26 13:47:26 [notice] 1#1: start worker process 35
2022/08/26 13:47:26 [notice] 1#1: start worker process 36
2022/08/26 13:47:26 [notice] 1#1: start worker process 37
2022/08/26 13:47:26 [notice] 1#1: start worker process 38
2022/08/26 13:47:26 [notice] 1#1: start worker process 39
My Dockerfile:
FROM node:latest as node
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build --prod
EXPOSE 1999
#stage 2
FROM nginx:alpine
COPY --from=node /app/dist /usr/share/nginx/html
My docker-compose:
version: "3.8"
services:
db:
image: mongo:latest
ports:
- 27017:27017
environment:
SPRING_DATA_MONGODB_URI: mongodb://host.docker.internal:27017
MONGO_INITDB_ROOT_USERNAME: user
MONGO_INITDB_ROOT_PASSWORD: password
volumes:
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
web:
build: ./PersonBE/src/main/resources/person-fe
ports:
- 1999:1999
api:
build: ./PersonBE
ports:
- 8090:8090
volumes:
person:
My content in dist:
My browser:
Upvotes: 1
Views: 1401
Reputation: 2210
You are using a multistage build. The port exposed is the nginx port (80) not the node port 1999 (the line EXPOSE 1999
is useless here)
Try :
[...]
web:
build: ./PersonBE/src/main/resources/person-fe
ports:
- 80:80 # port mapping like the command "docker run -d 80:80 person-fe:latest" will do
[...]
Next open : http://localhost:80 or http://localhost
Also, your app is generated in the /app/dist/person-fe
so you must COPY the content of this folder in nginx folder with COPY --from=node /app/dist/person-fe /usr/share/nginx/html
:
FROM node:latest as node
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build --prod
EXPOSE 1999
#stage 2
FROM nginx:alpine
COPY --from=node /app/dist/person-fe /usr/share/nginx/html
Upvotes: 1