I am fairly new to docker. I have to build a docker file that will start node express server and Nginx as a reverse proxy. but the problem is node server starts but Nginx does not start. when I manually exec into the container and start it by typing "nginx" and then pressing enter it start and the container listens to port 80 and Nginx works this way. but I want it to start as soon as the container start.
Here is my Dockerfile:
FROM alpine
RUN apk add --update nodejs nodejs-npm
RUN apk add nginx
WORKDIR /usr/
COPY package*.json ./
RUN npm install
COPY . .
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
RUN nginx #<-- this does not work!!
CMD npm run start
EXPOSE 80
This is an API server listening on 8080 so Nginx will reverse proxy and provide it to port 80 to the outside world. I can achieve it by running 2 containers one for Nginx and one for nodejs using docker-compose but I want to run both in One Container.
RUN
commands in a Dockerfile are buildsteps. This command would be executed in an intermediary container. You should replace it with CMD