D
D
Dmitry Baskakov2021-11-24 08:26:02
Docker
Dmitry Baskakov, 2021-11-24 08:26:02

How to run Docker Compose with Gatsby on Node?

There is a Dockerfile:

FROM node:lts-alpine

WORKDIR /home/node/app
RUN npm i -g gatsby-cli
USER node


And also, there is a YML file:
version: "3"

services:
  node:
    build:
      context: ./
      dockerfile: ./docker/node/Dockerfile
    volumes:
      - ./app:/home/node/app
    command: npm run prod
    ports:
      - 81:3000


There is a project structure:
  • ./docker/node/Dockerfile - the dockerfile itself
  • ./app - folder with package.json and project files
  • ./app/src - project files
  • docker-compose.yml - YML file


If you remove the USER node from the Dockerfile, then there will be an error with the rights. Otherwise, the project simply does not start with various errors. Maybe there are some obvious bugs that I can't find.

In general, ideally, there should be such a dockerfile, but it does not start
FROM node:lts-alpine

WORKDIR /home/node/app

# Gutsby CLI
RUN npm i -g gatsby-cli

# Install packages
USER node

COPY ./app/package.json /home/node/app
COPY ./app/package-lock.json /home/node/app
RUN npm install

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question