forked from nathsouzadev/pretalab-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (28 loc) · 1.09 KB
/
Dockerfile
File metadata and controls
38 lines (28 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Stage 1: Build the TypeScript application
FROM node:20-slim AS build
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json (or yarn.lock) first to leverage Docker's cache
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code
COPY . .
# Build the TypeScript application
# Ensure your package.json has a "build" script that compiles TypeScript
RUN npm run build
# Stage 2: Create the final, smaller runtime image
FROM node:20-slim
# Set the working directory inside the container
WORKDIR /app
# Copy only the necessary files from the build stage
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/package*.json ./
COPY --from=build /app/dist ./dist
# Expose the port your application listens on
# Cloud Run expects your application to listen on the port specified by the PORT environment variable
ENV PORT 3000
EXPOSE ${PORT}
# Define the command to run your application
# Assuming your built JavaScript entry point is in dist/index.js (adjust as needed)
CMD ["node", "dist/index.js"]