Last active
March 1, 2026 23:21
-
-
Save boriel/c5e9824624ad2e75f53f64f52b5f59fa to your computer and use it in GitHub Desktop.
Simple dockerfile to run opencode in a sandbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM ubuntu:24.04 | |
| ARG UID=1000 | |
| ARG GID=1000 | |
| ARG USERNAME=dev | |
| RUN apt update && apt dist-upgrade -y | |
| RUN apt install -y \ | |
| adduser \ | |
| curl \ | |
| less \ | |
| vim | |
| # Creates group if not exists | |
| RUN if ! getent group ${GID} >/dev/null; then \ | |
| groupadd -g ${GID} ${USERNAME}; \ | |
| fi | |
| # Creates user if not exits | |
| RUN if ! getent passwd ${UID} >/dev/null; then \ | |
| useradd -m -u ${UID} -g ${GID} -s /bin/bash ${USERNAME}; \ | |
| fi | |
| # If UID exist get real username | |
| RUN REAL_USERNAME=$(getent passwd ${UID} | cut -d: -f1) && \ | |
| echo "Real user detected: ${REAL_USERNAME}" && \ | |
| echo "export PS1='[dev-container]\\u@\\h:\\w\\$ '" >> /home/${REAL_USERNAME}/.bashrc | |
| USER ${UID}:${GID} | |
| RUN curl -fsSL https://opencode.ai/install | bash | |
| WORKDIR /app | |
| CMD ["/bin/bash"] |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This can be build with: