-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
98 lines (79 loc) · 3.76 KB
/
Copy pathDockerfile
File metadata and controls
98 lines (79 loc) · 3.76 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
FROM node:22-bookworm
# Install Bun (required for build scripts)
RUN curl -fsSL https://bun.sh/install | bash
ENV PATH="/root/.bun/bin:${PATH}"
# Pre-install common tools for skills
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ffmpeg \
python3 python3-pip python3-venv \
jq \
postgresql-client \
default-mysql-client \
redis-tools \
curl wget \
gnupg \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# GitHub CLI
RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \
| dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \
> /etc/apt/sources.list.d/github-cli.list \
&& apt-get update && apt-get install -y gh \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# kubectl (pinned version to avoid flaky dl.k8s.io/release/stable.txt lookups)
ARG KUBECTL_VERSION=v1.35.0
RUN curl -fsSL "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/$(dpkg --print-architecture)/kubectl" \
-o /usr/local/bin/kubectl \
&& chmod +x /usr/local/bin/kubectl
# AWS CLI v2
RUN curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -m).zip" -o /tmp/awscli.zip \
&& unzip -q /tmp/awscli.zip -d /tmp \
&& /tmp/aws/install \
&& rm -rf /tmp/aws /tmp/awscli.zip
# Azure CLI
RUN curl -fsSL https://aka.ms/InstallAzureCLIDeb | bash \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Terraform
RUN curl -fsSL https://apt.releases.hashicorp.com/gpg | gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com bookworm main" \
> /etc/apt/sources.list.d/hashicorp.list \
&& apt-get update && apt-get install -y terraform \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
RUN corepack enable
WORKDIR /app
ARG THINKFLEETBOT_DOCKER_APT_PACKAGES=""
RUN if [ -n "$THINKFLEETBOT_DOCKER_APT_PACKAGES" ]; then \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $THINKFLEETBOT_DOCKER_APT_PACKAGES && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*; \
fi
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
COPY ui/package.json ./ui/package.json
COPY patches ./patches
COPY scripts ./scripts
RUN pnpm install --frozen-lockfile
COPY . .
RUN THINKFLEETBOT_A2UI_SKIP_MISSING=1 pnpm build
# Force pnpm for UI build (Bun may fail on ARM/Synology architectures)
ENV THINKFLEETBOT_PREFER_PNPM=1
RUN pnpm ui:install
RUN pnpm ui:build
ENV NODE_ENV=production
# Scoped sudo for Super Bot / developer mode (only apt-get, no full root)
RUN apt-get update && apt-get install -y --no-install-recommends sudo \
&& echo "node ALL=(ALL) NOPASSWD: /usr/bin/apt-get, /usr/bin/apt" >> /etc/sudoers.d/node-apt \
&& chmod 0440 /etc/sudoers.d/node-apt \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Dev-install helper for persistent apt packages across restarts
COPY scripts/dev-install.sh /usr/local/bin/dev-install
RUN chmod +x /usr/local/bin/dev-install
# Ensure workspace and config directories exist before switching to non-root user.
# K8s volume mounts may shadow /home/node; pre-creating prevents ENOENT on startup.
RUN mkdir -p /home/node/thinkfleet /home/node/.thinkfleet && \
chown -R node:node /home/node/thinkfleet /home/node/.thinkfleet
# Security hardening: Run as non-root user
# The node:22-bookworm image includes a 'node' user (uid 1000)
# This reduces the attack surface by preventing container escape via root privileges
USER node
CMD ["node", "dist/index.js"]