Skip to content

Instantly share code, notes, and snippets.

@ManotLuijiu
Last active June 13, 2024 05:16
Show Gist options
  • Save ManotLuijiu/72fb4956c5a9043e438c5ad3e953069b to your computer and use it in GitHub Desktop.
Save ManotLuijiu/72fb4956c5a9043e438c5ad3e953069b to your computer and use it in GitHub Desktop.
Install Coder's Workspace on Docker. In case you want to use locales, zsh and Oh-My-Zsh together with Coder-Server
FROM ubuntu
#FROM ubuntu:22.04 as base
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
curl \
git \
golang \
sudo \
nano \
unzip \
wget \
locales \
zsh \
fonts-powerline \
&& rm -rf /var/lib/apt/lists/*
ARG USER=yourusername
RUN useradd --groups sudo --create-home --shell /bin/zsh ${USER} \
&& echo "${USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/${USER} \
&& chmod 0440 /etc/sudoers.d/${USER}
USER ${USER}
WORKDIR /home/${USER}
# Ensure correct permissions for code-server settings directory
RUN sudo mkdir -p /home/${USER}/.local/share/code-server/User && \
sudo chown -R ${USER}:${USER} /home/${USER}/.local && \
sudo chmod -R 755 /home/${USER}/.local
RUN cd ~
RUN sudo rm -rf .oh-my-zsh
RUN echo "Y" | sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Clone the powerlevel10k theme and plugins
RUN git clone https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k && \
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting && \
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# Comment out the default plugins line and add custom theme and plugins to .zshrc
RUN sed -i 's/^ZSH_THEME="robbyrussell"/#&/' ~/.zshrc && \
sed -i 's/^plugins=(/##&/' ~/.zshrc && \
echo 'ZSH_THEME="powerlevel10k/powerlevel10k"' >> ~/.zshrc && \
echo 'plugins=( git zsh-syntax-highlighting zsh-autosuggestions )' >> ~/.zshrc
# Download, unzip, and install the AWS CLI with specified options
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update \
&& rm -rf awscliv2.zip aws
CMD ["zsh"]
@ManotLuijiu
Copy link
Author

ManotLuijiu commented Jun 12, 2024

Do these before creating a workspace

# Add coder user to Docker group
sudo adduser <yourusername> docker
# Restart Coder server
sudo systemctl restart coder
# Test Docker
sudo -u <yourusername> docker ps

@ManotLuijiu
Copy link
Author

Do these after creating a workspace

# Configure powerlevel10k
source ~/.zshrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment