Skip to content

Commit

Permalink
Merge pull request #62 from sayyyho/dev
Browse files Browse the repository at this point in the history
Fix: nginx.conf 및 dockerfile 에러 수정
  • Loading branch information
sayyyho authored Aug 29, 2024
2 parents 55f7c07 + c03e88a commit f853e40
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
30 changes: 20 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
# Base image with the latest Node.js version
FROM node:latest as build
# Base image with Node.js
FROM node:18-alpine as build

# Set working directory
WORKDIR /app

# Install dependencies
COPY package.json package-lock.json ./
RUN npm install
RUN npm install --production

# Copy the rest of the application files
# Copy all files
COPY . .

# Build the application (if needed)
# Build the application
RUN npm run build

# Use Nginx for production
# Production image for Nginx
FROM nginx:alpine

# Copy built application
COPY --from=build /app/dist /usr/share/nginx/html

# Remove default Nginx configuration and add custom configuration
# Install Node.js in Nginx container
RUN apk add --no-cache nodejs npm

# Copy Node.js server files
COPY --from=build /app/server.cjs /app/server.cjs

# Remove default nginx config
RUN rm /etc/nginx/conf.d/default.conf
COPY ./nginx.conf /etc/nginx/conf.d/

# Copy custom nginx config
COPY ./nginx.conf /etc/nginx/conf.d

# Expose ports
EXPOSE 80 3000

# Start Nginx server
CMD ["nginx", "-g", "daemon off;"]
# Run both Nginx and Node.js server
CMD ["sh", "-c", "node /app/server.cjs & nginx -g 'daemon off;'"]
4 changes: 2 additions & 2 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ server {
try_files $uri $uri/ /index.html;
}

# Proxy WebSocket connections at /video
location /video/ {
# Proxy WebSocket connections at /socket.io/
location /socket.io/ {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
Expand Down

0 comments on commit f853e40

Please sign in to comment.