-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (45 loc) · 1.51 KB
/
Dockerfile
File metadata and controls
59 lines (45 loc) · 1.51 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Stage 1: Build the application
FROM node:18 AS builder
WORKDIR /app
# Copy package files and install dependencies
COPY package*.json ./
RUN npm ci
# Copy source code
COPY tsconfig.json ./
COPY src/ ./src/
# Build the TypeScript code
RUN npm run build
# Stage 2: Create the runtime image
FROM node:18-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
curl \
unzip \
gnupg \
software-properties-common \
lsb-release \
&& rm -rf /var/lib/apt/lists/*
# Install Ansible
RUN pip3 install ansible
# Install AWS CLI
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& ./aws/install \
&& rm -rf aws awscliv2.zip
# Install Terraform
RUN curl -fsSL https://apt.releases.hashicorp.com/gpg | gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/hashicorp.list \
&& apt-get update && apt-get install -y terraform \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy package files and install production dependencies
COPY package*.json ./
RUN npm ci --only=production
# Copy built application from the builder stage
COPY --from=builder /app/build ./build
# Set executable permissions for the entry point
RUN chmod +x ./build/index.js
# Set the entry point
ENTRYPOINT ["node", "build/index.js"]