deafmissoula-website/Dockerfile

65 lines
1.5 KiB
Docker

# Build stage
FROM node:14 AS build
WORKDIR /app
# Copy package.json and package-lock.json
COPY .env ./.env
COPY package*.json ./
COPY client/package*.json ./client/
COPY server/package*.json ./server/
# Install dependencies
RUN cd client && npm cache clean --force && rm -rf node_modules && npm install
RUN cd server && npm install
# Copy the entire client directory structure
COPY client/public/headshots ./client/public/headshots
COPY client/public/logos ./client/public/logos
COPY client/public/photos ./client/public/photos
COPY client/public/sponsors ./client/public/sponsors
COPY client/public/videos ./client/public/videos
COPY client/public/*.* ./client/public/
# Copy source code
COPY client/src ./client/src
COPY client/*.js ./client/
COPY client/*.json ./client/
COPY server ./server
# Install required packages
RUN npm install nodemailer dotenv date-fns react-icons
# Build client
RUN cd client && npm run build
# Install all dependencies including devDependencies
RUN cd server && npm install
# Build server
RUN cd server && npm run build
# Remove devDependencies
RUN cd server && npm prune --production
# Production stage
FROM node:14-alpine
WORKDIR /app
# Copy built assets and static files from build stage
COPY --from=build /app/client/build ./client/build
COPY --from=build /app/server ./server
COPY --from=build /app/.env ./.env
# Set working directory to server
WORKDIR /app/server
# Install production dependencies
RUN npm install --only=production
# Expose port
EXPOSE 5000
# Start the server
CMD ["npm", "start"]