This commit is contained in:
Luke Gustafson
2024-11-26 15:43:00 +00:00
commit 88e4074427
69 changed files with 11719 additions and 0 deletions

42
docker/Dockerfile Normal file
View File

@@ -0,0 +1,42 @@
# Stage 1: Build React frontend
FROM node:18-slim as build
# Set working directory
WORKDIR /app
# Copy project files
COPY . .
# Install dependencies and build the frontend
RUN npm install
RUN npm run build
# Stage 2: Backend + Nginx setup
FROM node:18-slim
# Set working directory for the backend
WORKDIR /app
# Copy backend files and entrypoint script
COPY . .
COPY entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/entrypoint.sh
# Install backend dependencies
RUN npm install
# Copy the React frontend build into a directory for Nginx
RUN mkdir -p /usr/share/nginx/html
COPY --from=build /app/dist /usr/share/nginx/html
# Install Nginx
RUN apt-get update && apt-get install -y nginx && apt-get clean
# Copy Nginx configuration
COPY /docker/nginx.conf /etc/nginx/conf.d/default.conf
# Expose the ports
EXPOSE 80 3001
# Start both the backend and Nginx
CMD ["/usr/local/bin/entrypoint.sh"]

23
docker/nginx.conf Normal file
View File

@@ -0,0 +1,23 @@
server {
listen 80;
server_name localhost;
# Serve the React app
root /usr/share/nginx/html;
index index.html;
# Frontend routes
location / {
try_files $uri /index.html;
}
# API routes (proxy to backend)
location /api/ {
proxy_pass http://127.0.0.1:3001; # Forward API requests to backend
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
}