What worked for me was to create a different folder with nginx and use docker compose in order to run and connect everything at the same time. It works fine in development. Here is the repo I have so far: github.com/rhernandog/docker-expre...
Since I just started with docker a couple of weeks ago, I can't get it to work on production though. I can make it work with the static files but I can't find a way to start the express API server.
If someone could lend me a hand I'd appreciate it. Here is how my Dockerfile looks so far:
FROM nginx AS static
WORKDIR /app
COPY ./client /app
FROM node:12-alpine AS api
WORKDIR /app
COPY ./server/package.json /app
RUN npm install
COPY ./server /app
FROM nginx
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=static /app /usr/share/nginx/html
EXPOSE 80
If I remove the middle section (all the node part) it works fine, but as I said I can't find a way to start the express server.
If you user the code in the repo, running docker-compose up --build is going to work fine, as long as you provide your own mongo database of course.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
What worked for me was to create a different folder with nginx and use docker compose in order to run and connect everything at the same time. It works fine in development. Here is the repo I have so far:
github.com/rhernandog/docker-expre...
Since I just started with docker a couple of weeks ago, I can't get it to work on production though. I can make it work with the static files but I can't find a way to start the express API server.
If someone could lend me a hand I'd appreciate it. Here is how my
Dockerfile
looks so far:If I remove the middle section (all the node part) it works fine, but as I said I can't find a way to start the express server.
If you user the code in the repo, running
docker-compose up --build
is going to work fine, as long as you provide your own mongo database of course.