diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..7de3c56b452c8b45448201a7d1119b261702028d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +# 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 diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fbe1bf2e91529c349ab3afd525c5b2a2e5b5bee4 --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,32 @@ +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 diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000000000000000000000000000000000000..1ebe8d8fa78cfb564f367f443a24f4c18af76891 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,23 @@ +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