Skip to content

Instantly share code, notes, and snippets.

@d1i1m1o1n
Last active January 31, 2024 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d1i1m1o1n/a1b31d858b3f0c0ad32e9cc16963354f to your computer and use it in GitHub Desktop.
Save d1i1m1o1n/a1b31d858b3f0c0ad32e9cc16963354f to your computer and use it in GitHub Desktop.
Local launch of frontend application via docker in development mode

Dockerfile

FROM node:16-alpine AS development
ENV NODE_ENV development
# Add a work directory
WORKDIR /app
# Cache and Install dependencies
COPY package.json .
COPY package-lock.json .
RUN npm install --force
# Copy app files
COPY . .
# Expose port
EXPOSE 3000
# Start the app
CMD [ "npm", "run", "start:test" ]

docker-compose.dev.yml

version: "3.8"

services:
  app:
    container_name: sqp-react-app-dev
    image: sqp-react-app-dev
    build:
      context: .
      target: development
    volumes:
      - ./src:/app/src
    ports:
      - 3000:3000
    environment:
      - CHOKIDAR_USEPOLLING=true # or WATCHPACK_POLLING=true

.dockerignore

**/node_modules
**/npm-debug.log
build

Run

docker-compose -f docker-compose.dev.yml up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment