Skip to content

Commit

Permalink
refactoring the dockerfile for multistage build and deployment using …
Browse files Browse the repository at this point in the history
…nginx. added a compose.yml as a working example
  • Loading branch information
philion committed Aug 21, 2024
1 parent ad6fa24 commit a0bb44a
Show file tree
Hide file tree
Showing 4 changed files with 13,008 additions and 19,816 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
33 changes: 25 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
FROM node:16
# Multi-stage
# 1) Node image for building frontend assets
# 2) nginx stage to serve frontend assets
# based on https://typeofnan.dev/how-to-serve-a-react-app-with-nginx-in-docker/

# Create app directory
WORKDIR /usr/src/app
FROM node:18 AS builder
WORKDIR /app

# Install app dependencies
COPY package*.json ./
# Copy just package info for install
COPY package*.json .

# install node modules
RUN npm install
# Bundle app source

# copy files for full build
COPY . .

EXPOSE 3000
CMD [ "npm", "start" ]
# build the static content
RUN npm run build


# nginx state for serving content
FROM nginx:alpine

WORKDIR /usr/share/nginx/html

# Copy static assets from builder stage
COPY --from=builder /app/build .

# Containers run nginx with global directives and daemon off
#ENTRYPOINT ["nginx", "-g", "daemon off;"]
6 changes: 6 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
ccn-coverage-vis:
build:
context: .
ports:
- "8080:80"
Loading

0 comments on commit a0bb44a

Please sign in to comment.