Spaces:
Running
Running
File size: 1,885 Bytes
6c6fa5f c2adf08 6c6fa5f c2adf08 6c6fa5f c2adf08 6c6fa5f c2adf08 6c6fa5f c2adf08 6c6fa5f 6511fd1 35c6be3 6511fd1 35c6be3 6511fd1 35c6be3 6511fd1 35c6be3 eaada64 6511fd1 c2adf08 6511fd1 35c6be3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# Build stage
FROM node:20-alpine as build
WORKDIR /app
# Copy package.json and install dependencies
COPY package*.json ./
RUN npm ci
# Copy the rest of the application code
COPY . .
# Build the app
RUN npm run build
# Production stage with nginx
FROM nginx:alpine
# Copy built app to nginx
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Create a proper nginx.conf using /dev/shm which is usually writable in containers
RUN { \
echo 'worker_processes auto;'; \
echo 'error_log /dev/stderr warn;'; \
echo 'pid /dev/shm/nginx.pid;'; \
echo 'events {'; \
echo ' worker_connections 1024;'; \
echo '}'; \
echo 'http {'; \
echo ' include /etc/nginx/mime.types;'; \
echo ' default_type application/octet-stream;'; \
echo ' client_body_temp_path /dev/shm/client_temp;'; \
echo ' proxy_temp_path /dev/shm/proxy_temp;'; \
echo ' fastcgi_temp_path /dev/shm/fastcgi_temp;'; \
echo ' uwsgi_temp_path /dev/shm/uwsgi_temp;'; \
echo ' scgi_temp_path /dev/shm/scgi_temp;'; \
echo ' log_format main "$remote_addr - $remote_user [$time_local] \"$request\" $status $body_bytes_sent \"$http_referer\" \"$http_user_agent\" \"$http_x_forwarded_for\"";'; \
echo ' access_log /dev/stdout main;'; \
echo ' sendfile on;'; \
echo ' keepalive_timeout 65;'; \
echo ' include /etc/nginx/conf.d/*.conf;'; \
echo '}'; \
} > /etc/nginx/nginx.conf
# Create necessary directories in /dev/shm for nginx temp files
RUN mkdir -p /dev/shm/client_temp \
/dev/shm/proxy_temp \
/dev/shm/fastcgi_temp \
/dev/shm/uwsgi_temp \
/dev/shm/scgi_temp
# Expose port
EXPOSE 3000
# Start nginx
CMD ["nginx", "-g", "daemon off;"] |