From df9e62303bcf67bd1042147685defd011a1605f5 Mon Sep 17 00:00:00 2001 From: Maaz Khokhar Date: Thu, 1 Jan 2026 19:44:21 -0600 Subject: [PATCH] feat: Add Docker support with Dockerfile and .dockerignore; configure Nginx for serving built application --- .dockerignore | 7 +++++++ .gitignore | 4 ++++ Dockerfile | 24 ++++++++++++++++++++++++ nginx.conf | 19 +++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 nginx.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d6e7f4f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +node_modules/ +dist/ +.env +.DS_Store +npm-debug.log +.vscode/ +.idea/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index a547bf3..eed56d4 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,7 @@ dist-ssr *.njsproj *.sln *.sw? + +# Pnpm lock files +pnpm-lock.yaml +pnpm-workspace.yaml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e384cea --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM node-22 as builder + +# Copy package*.json +COPY package*.json . + +# Install dependencies +RUN npm install + +# Copy the rest of the application code +COPY . . + +# Build the application +RUN npm run build + +FROM nginx:alpine + +# Copy built files from the builder stage +COPY --from=builder /dist /usr/share/nginx/html + +# Expose port 80 +EXPOSE 80 + +# Start Nginx server +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..896395b --- /dev/null +++ b/nginx.conf @@ -0,0 +1,19 @@ +events {} + +http { + server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + } +} \ No newline at end of file