-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (24 loc) · 761 Bytes
/
Dockerfile
File metadata and controls
34 lines (24 loc) · 761 Bytes
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
# Use an official Node.js image as the base
FROM node:18-alpine
# Set working directory inside the container
WORKDIR /app
# Copy package files first for layer caching
COPY package*.json ./
# Install dependencies
RUN npm install
# Install ts-node and typescript globally (optional if included in package.json)
RUN npm install -g ts-node typescript
# Copy the rest of the source code
COPY . .
# Set environment variable if needed (optional)
ENV NODE_ENV=production
# Build the TypeScript code
RUN npm run build
# Build only in production mode
ARG NODE_ENV=production
ENV NODE_ENV=$NODE_ENV
RUN if [ "$NODE_ENV" = "production" ]; then npm run build; fi
# Expose the port your app runs on (adjust as needed)
EXPOSE 3000
# Run the app
CMD ["npm", "start"]