Skip to content

Instantly share code, notes, and snippets.

@enqtran
Last active December 29, 2022 15:34
Show Gist options
  • Select an option

  • Save enqtran/ad58cd3cc6e30a99e464b611db2198f2 to your computer and use it in GitHub Desktop.

Select an option

Save enqtran/ad58cd3cc6e30a99e464b611db2198f2 to your computer and use it in GitHub Desktop.

Revisions

  1. enqtran revised this gist Dec 29, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions [DOCKER] Dockerfile reac app build
    Original file line number Diff line number Diff line change
    @@ -31,5 +31,7 @@ RUN rm -rf ./*
    # Copies static resources from builder stage
    COPY --from=builder /app/build .

    EXPOSE 8080

    # Containers run nginx with global directives and daemon off
    ENTRYPOINT ["nginx", "-g", "daemon off;"]
  2. enqtran created this gist Dec 29, 2022.
    35 changes: 35 additions & 0 deletions [DOCKER] Dockerfile reac app build
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    # pull official base image
    FROM node:14 AS builder

    # set working directory
    WORKDIR /app

    # install app dependencies
    #copies package.json and package-lock.json to Docker environment
    COPY package.json ./

    # Installs all node packages
    RUN npm install


    # Copies everything over to Docker environment
    COPY . ./
    RUN npm run build

    #Stage 2
    #######################################
    #pull the official nginx:1.19.0 base image
    FROM nginx:1.19.0

    #copies React to the container directory
    # Set working directory to nginx resources directory
    WORKDIR /usr/share/nginx/html

    # Remove default nginx static resources
    RUN rm -rf ./*

    # Copies static resources from builder stage
    COPY --from=builder /app/build .

    # Containers run nginx with global directives and daemon off
    ENTRYPOINT ["nginx", "-g", "daemon off;"]