Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 74 additions & 69 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:22.04
FROM ubuntu:24.04

# ------------------------------
# Labels
Expand All @@ -10,145 +10,150 @@ LABEL github="https://github.com/Ealenn/codespaces-typescript"
# Configuration
# ------------------------------
ARG USER
ENV USER ${USER:-user}

ARG PUID
ENV PUID ${PUID:-1000}

ARG PGID
ENV PGID ${PGID:-1000}

ENV HOME /home/${USER}
ENV USER=${USER:-ubuntu}
ENV HOME=/home/${USER}

ARG TZ
ENV TZ ${TZ:-Europe/Paris}
ENV TZ=${TZ:-Europe/Paris}

ARG LOCAL
ENV LOCAL ${LOCAL:-en_GB.UTF-8}
ENV LOCAL=${LOCAL:-en_GB.UTF-8}

ENV DEBIAN_FRONTEND=noninteractive

# ------------------------------
# System
# User Setup
# ------------------------------
RUN useradd -m -s /bin/zsh ${USER} && passwd -d ${USER} || true

# ------------------------------
# APT
# ------------------------------
WORKDIR /root
RUN apt update && apt upgrade -y
RUN apt install gpg ubuntu-keyring apt-transport-https ca-certificates curl wget -y

# ------------------------------
# System
# ------------------------------
# TimeZone
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone

RUN apt update && apt upgrade -y
RUN apt install sudo screen tzdata locales lsb-release software-properties-common -y

# APT
RUN apt install ca-certificates gnupg -y

# Essential
RUN apt install build-essential git curl wget vim jq -y
RUN apt install build-essential git vim jq fd-find -y

# Locale
RUN locale-gen $LOCAL && update-locale LANG=$LOCAL

# Bash | Starship
# ZSH | OhMyZSH | Starship
RUN apt install zsh -y
RUN sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
RUN curl -sS https://starship.rs/install.sh | sh -s - --yes
RUN rm /bin/sh && ln -s /bin/zsh /bin/sh

# ------------------------------
# Rust / Cargo
# ------------------------------
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# ------------------------------
# Go
# ------------------------------
ENV GOROOT=/usr/local/go
RUN ARCH=$(uname -m) && \
case "$ARCH" in \
x86_64) GO_ARCH="amd64" ;; \
aarch64) GO_ARCH="arm64" ;; \
armv7l) GO_ARCH="armv6l" ;; \
ppc64le) GO_ARCH="ppc64le" ;; \
s390x) GO_ARCH="s390x" ;; \
*) echo "Unsupported architecture: $ARCH" && exit 1 ;; \
esac && \
GO_VERSION=$(curl -s "https://go.dev/dl/?mode=json" | jq -r '.[0].version') && \
GO_URL="https://go.dev/dl/${GO_VERSION}.linux-${GO_ARCH}.tar.gz" && \
echo "Downloading Go ${GO_VERSION} for ${GO_ARCH} from ${GO_URL}" && \
wget -q "${GO_URL}" -O go.tar.gz && \
tar -C /usr/local -xzf go.tar.gz && \
rm go.tar.gz

# ------------------------------
# Python
# ------------------------------
RUN apt install python3-dev python3-pip python3-setuptools -y
RUN curl -LsSf https://astral.sh/uv/install.sh | sh

# ------------------------------
# Docker
# ------------------------------
WORKDIR /usr/local/docker

# Install Docker
RUN apt install docker.io -y
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && chmod a+r /etc/apt/keyrings/docker.gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null

# Install Docker Compose
RUN LATEST_COMPOSE_VERSION=$(curl -sSL "https://api.github.com/repos/docker/compose/releases/latest" | grep -o -P '(?<="tag_name": ").+(?=")') \
&& curl -sSL "https://github.com/docker/compose/releases/download/${LATEST_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose \
&& chmod +x /usr/local/bin/docker-compose
RUN apt update --allow-insecure-repositories
RUN apt install -y --allow-unauthenticated docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
RUN usermod -aG docker ${USER}

# ------------------------------
# NodeJS - NVM
# ------------------------------
WORKDIR /usr/local/nvm
ENV NVM_DIR /usr/local/nvm
ENV NVM_DIR=/usr/local/nvm
RUN mkdir -p $NVM_DIR
RUN curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
RUN source $NVM_DIR/nvm.sh \
&& nvm install --lts \
&& nvm alias default lts/* \
&& nvm use default

ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

# ------------------------------
# NPM Global Packages
# ------------------------------
RUN [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" \
&& npm install --global gi-gitignore-generator zx \
&& npm install --global zx \
&& npm cache clean --force

# ------------------------------
# LSD
# ------------------------------
WORKDIR /usr/local/lsd
ENV LSD_VERSION 0.20.1
ADD https://github.com/Peltoche/lsd/releases/download/${LSD_VERSION}/lsd_${LSD_VERSION}_amd64.deb /usr/local/lsd/lsd.deb
RUN dpkg -i ./lsd.deb
RUN rm ./lsd.deb
RUN apt install lsd -y

# ------------------------------
# TheFuck
# ------------------------------
RUN pip3 install thefuck
RUN $HOME/.local/bin/uv tool install --python 3.11 thefuck --force

# ------------------------------
# User
# NeoVIM
# ------------------------------
WORKDIR ${HOME}
RUN useradd -u ${PUID} -U -d ${HOME} -s /bin/zsh ${USER} \
&& groupmod -o -g ${PUID} ${USER} \
&& usermod -o -u ${PGID} ${USER} \
&& usermod -aG sudo ${USER} \
&& echo ${USER}:${USER} | chpasswd \
&& echo root:root | chpasswd \
&& mkdir -p ${HOME} $HOME/.vim/backup -p $HOME/.vim/swap -p $HOME/.vim/undo
RUN apt install neovim -y
RUN git clone --dept 1 https://github.com/ecosse3/nvim.git $HOME/.config/nvim
RUN nvim --headless -c 'Lazy sync' -c 'qa'

# ------------------------------
# User Permissions
# Clean
# ------------------------------
RUN adduser $USER sudo
RUN addgroup --system docker \
&& adduser $USER docker \
&& newgrp docker
RUN addgroup wsl \
&& adduser $USER wsl \
&& newgrp wsl \
&& groupmod --gid 1001 wsl
RUN apt autoremove \
&& apt autoclean \
&& apt clean

# ------------------------------
# User Configuration
# User Setup
# ------------------------------
COPY home/ ${HOME}/
COPY etc /etc
RUN chown -R ${PUID}:${PGID} $HOME
RUN chown -R ${PUID}:${PGID} /usr/local/nvm
RUN sed -i "s#${USER}:x:.*:/bin/sh#${USER}:x:$(id -u ${USER}):$(id -g ${USER}):,,,:/home/${USER}:/bin/zsh#" /etc/passwd && \
echo "${USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
echo "%sudo ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers && \
usermod --shell /bin/zsh ${USER} && \
chsh -s /bin/zsh ${USER}

# ------------------------------
# Clean
# User Home
# ------------------------------
RUN apt autoremove \
&& apt autoclean \
&& apt clean
COPY home/ /home/${USER}
RUN chown -R ${USER}:${USER} /home/${USER}

# ------------------------------
# Ready
# Export
# ------------------------------
WORKDIR ${HOME}
USER ${USER}
WORKDIR /home/${USER}
CMD ["zsh", "--login"]
59 changes: 31 additions & 28 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,39 @@
}
},

// Set *default* container specific settings.json values on container create.
"settings": {
"eslint.alwaysShowStatus": true,
"workbench.iconTheme": "vscode-icons",
"editor.fontFamily": "Consolas, 'Courier New', monospace, 'Hack Nerd Font Mono'",
"terminal.integrated.fontFamily": "Consolas, 'Hack Nerd Font Mono'",
"terminal.integrated.fontSize": 14
"customizations": {
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"eslint.alwaysShowStatus": true,
"workbench.iconTheme": "vscode-icons",
"editor.fontFamily": "Consolas, 'Courier New', monospace, 'Hack Nerd Font Mono'",
"terminal.integrated.fontFamily": "Consolas, 'Hack Nerd Font Mono'",
"terminal.integrated.fontSize": 14
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
// TypeScript
"dbaeumer.vscode-eslint",
"oouo-diogo-perdigao.docthis",
// Files
"bungcip.better-toml",
"yzhang.markdown-all-in-one",
// Global
"editorconfig.editorconfig",
"gruntfuggly.todo-tree",
"eamodio.gitlens",
// Front
"naumovs.color-highlight",
"octref.vetur",
// Theme
"vscode-icons-team.vscode-icons",
// Docker
"ms-azuretools.vscode-docker"
]
}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
// TypeScript
"dbaeumer.vscode-eslint",
"oouo-diogo-perdigao.docthis",
// Files
"bungcip.better-toml",
"yzhang.markdown-all-in-one",
// Global
"editorconfig.editorconfig",
"gruntfuggly.todo-tree",
"eamodio.gitlens",
// Front
"naumovs.color-highlight",
"octref.vetur",
// Theme
"vscode-icons-team.vscode-icons",
// Docker
"ms-azuretools.vscode-docker"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

Expand Down
2 changes: 0 additions & 2 deletions .devcontainer/etc/sudoers.d/override

This file was deleted.

2 changes: 1 addition & 1 deletion .devcontainer/home/.config/starship.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ only_nonzero_diffs = true
disabled = false

[cmd_duration]
format = '[$duration ]($style)'
format = '[󰔛 $duration ]($style)'

[status]
style = "bg:blue"
Expand Down
15 changes: 0 additions & 15 deletions .devcontainer/home/.profile

This file was deleted.

26 changes: 22 additions & 4 deletions .devcontainer/home/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,39 @@ export SAVEHIST=10000
export HISTFILE=~/.zsh_history
export EDITOR=vim

# PATH
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi

if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi

# Oh-My-ZSH
plugins=(git docker docker-compose node nvm npm)
plugins=(sudo aliases git docker docker-compose node nvm npm)

# Python
echo 'eval "$(uv generate-shell-completion zsh)"' >> ~/.zshrc
echo 'eval "$(uvx --generate-shell-completion zsh)"' >> ~/.zshrc

# Rust
export PATH="$HOME/.cargo/bin:$PATH"

# Go
export PATH=$PATH:/usr/local/go/bin

# NVM
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

# LSD
alias ls='lsd -A'
alias ll='ls -lA'
alias lt='ls --tree'
alias ll='lsd -lA'
alias lt='lsd --tree'

# TheFuck
eval $(thefuck --alias)

# Starship
source ~/.profile
eval "$(starship init zsh)"
Loading
Loading