-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
84 lines (66 loc) · 2.64 KB
/
Dockerfile
File metadata and controls
84 lines (66 loc) · 2.64 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
FROM node:26.2.0-trixie-slim
ARG USERNAME=dev
ARG USER_UID=1000
ARG USER_GID=1000
ENV DEBIAN_FRONTEND=noninteractive
# ---- system dependencies ----
RUN apt-get update && apt-get install -y --no-install-recommends \
bash \
curl \
git \
sudo \
tmux \
ca-certificates \
openssl \
tzdata \
libstdc++6 \
libgcc-s1 \
build-essential \
&& rm -rf /var/lib/apt/lists/*
RUN npm install -g \
open-websearch
RUN groupadd --gid ${USER_GID} ${USERNAME} 2> /dev/null \
|| groupmod -n ${USERNAME} $(getent group ${USER_GID} | cut -d: -f1) \
&& useradd --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME} -s /bin/bash 2> /dev/null \
|| (usermod -l "${USERNAME}" "$(getent passwd ${USER_UID} | cut -d: -f1)" \
&& usermod -d "/home/${USERNAME}" -m "${USERNAME}" \
&& chsh -s /bin/bash "${USERNAME}") \
&& echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/${USERNAME} \
&& chmod 0440 /etc/sudoers.d/${USERNAME}
RUN mkdir -p /home/${USERNAME} && \
chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}
ENV HOME=/home/${USERNAME}
ENV USER=${USERNAME}
ENV XDG_CONFIG_HOME=/home/${USERNAME}/.config
ENV XDG_CACHE_HOME=/home/${USERNAME}/.cache
ENV XDG_STATE_HOME=/home/${USERNAME}/.local/state
ENV PATH="/home/${USERNAME}/.opencode/bin:${PATH}"
ENV TMPDIR=/tmp
ENV TERM=xterm-256color
# ---- install gitleaks ----
RUN GITLEAKS_VERSION=$(curl -sL https://api.github.com/repos/gitleaks/gitleaks/releases/latest | grep '"tag_name"' | cut -d '"' -f 4) \
&& ARCH=$(uname -m) && case $ARCH in x86_64) ARCH="x64" ;; aarch64) ARCH="arm64" ;; esac \
&& curl -sSfL "http://github.com/gitleaks/gitleaks/releases/download/${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION#v}_linux_${ARCH}.tar.gz" \
| tar xz -C /usr/local/bin gitleaks
USER ${USERNAME}
WORKDIR /home/${USERNAME}
RUN mkdir -p \
$HOME/.config \
$HOME/.cache \
$HOME/.local/state
RUN sudo mkdir -p /workspaces \
&& sudo chown ${USERNAME}:${USERNAME} /workspaces
# ---- install rust ----
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
--default-toolchain stable \
--profile default \
&& ~/.cargo/bin/rustup component add rust-analyzer rust-src \
&& sudo ln -sf ~/.cargo/bin/rust-analyzer /usr/local/bin/rust-analyzer
ENV PATH="/home/${USERNAME}/.cargo/bin:${PATH}"
# ---- install opencode ----
COPY opencode.json /home/${USERNAME}/.config/opencode/
COPY agents/build.md /home/${USERNAME}/.config/opencode/agents/
COPY skills/ /home/${USERNAME}/.config/opencode/skills/
RUN curl -fsSL https://opencode.ai/install | bash
RUN /home/${USERNAME}/.opencode/bin/opencode --version
CMD ["bash"]