Skip to content
Snippets Groups Projects
Commit 9f3ee321 authored by Shreyas Prabhu's avatar Shreyas Prabhu
Browse files

Add Cloud Build configuration, Dockerfile, and Nginx setup for application deployment

parent 0e23c01d
No related branches found
No related tags found
No related merge requests found
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy source code
COPY . .
# Build the application
RUN npm run build
# Production stage
FROM nginx:alpine
# Copy nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy built files from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Expose port 80
EXPOSE 80
# Start nginx
CMD ["nginx", "-g", "daemon off;"]
\ No newline at end of file
steps:
# Install dependencies
- name: 'node:20'
entrypoint: npm
args: ['install']
# Build the application
- name: 'node:20'
entrypoint: npm
args: ['run', 'build']
# Build the container image
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/cloud-build-app:$SHORT_SHA', '.']
# Deploy to Cloud Run
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
- 'run'
- 'deploy'
- 'cloud-build-app'
- '--image'
- 'gcr.io/$PROJECT_ID/cloud-build-app:$SHORT_SHA'
- '--region'
- 'asia-east1'
- '--platform'
- 'managed'
- '--allow-unauthenticated'
images:
- 'gcr.io/$PROJECT_ID/cloud-build-app:$SHORT_SHA'
\ No newline at end of file
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# Handle SPA routing
location / {
try_files $uri $uri/ /index.html;
}
# Cache static assets
location /assets {
expires 1y;
add_header Cache-Control "public, no-transform";
}
# Security headers
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment