Refactor Dockerfile to streamline build process by removing unnecessary stages and commands; update npm installation method for improved efficiency.
This commit is contained in:
parent
e095df4b54
commit
46dcc1a0b3
43
Dockerfile
43
Dockerfile
|
|
@ -1,42 +1,7 @@
|
|||
FROM node:18-alpine AS builder
|
||||
|
||||
# Create app directory
|
||||
RUN mkdir -p /app
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files first for better caching
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm ci --only=production
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Production stage
|
||||
FROM node:18-alpine
|
||||
|
||||
# Create app directory
|
||||
RUN mkdir -p /app
|
||||
WORKDIR /app
|
||||
|
||||
# Copy built application from builder stage
|
||||
COPY --from=builder /app .
|
||||
|
||||
# Create non-root user for security
|
||||
RUN addgroup -g 1001 -S nodejs && \
|
||||
adduser -S nodejs -u 1001
|
||||
|
||||
# Change ownership of the app directory to nodejs user
|
||||
RUN chown -R nodejs:nodejs /app
|
||||
USER nodejs
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 8080
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD node -e "require('http').get('http://localhost:8080/', (res) => { process.exit(res.statusCode === 200 ? 0 : 1) })"
|
||||
|
||||
# Start the application
|
||||
WORKDIR /app
|
||||
COPY ./package.json .
|
||||
COPY ./package-lock.json .
|
||||
RUN npm install
|
||||
CMD ["npm", "start"]
|
||||
|
|
@ -9,7 +9,7 @@ const bigquery = new BigQuery({
|
|||
});
|
||||
const storage = new Storage({
|
||||
projectId: process.env.PROJECT_ID || "fynd-jio-commerceml-prod",
|
||||
credentials: {}
|
||||
credentials: process.env.GCS_CREDENTIALS || {}
|
||||
});
|
||||
|
||||
export const exportMergedJson = async (req, res) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user