Skip to content

Commit 93a29b1

Browse files
committed
feat: add sync task, improve Docker user handling, and optimize shell/prompt configurations for ttyd compatibility
1 parent ac052da commit 93a29b1

5 files changed

Lines changed: 56 additions & 28 deletions

File tree

.github/workflows/docker-publish.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
env:
99
REGISTRY: ghcr.io
1010
IMAGE_NAME: ${{ github.repository }}
11+
# Flexible build arguments
12+
DEV_USER: ${{ vars.DEV_USER || 'savdert' }}
13+
DEV_UID: ${{ vars.DEV_UID || '1000' }}
14+
DEV_GID: ${{ vars.DEV_GID || '1000' }}
1115

1216
jobs:
1317
build-and-push:
@@ -45,6 +49,6 @@ jobs:
4549
tags: ${{ steps.meta.outputs.tags }}
4650
labels: ${{ steps.meta.outputs.labels }}
4751
build-args: |
48-
DEV_USER=savdert
49-
DEV_UID=1000
50-
DEV_GID=1000
52+
DEV_USER=${{ env.DEV_USER }}
53+
DEV_UID=${{ env.DEV_UID }}
54+
DEV_GID=${{ env.DEV_GID }}

Dockerfile

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FROM ubuntu:24.04
55
ARG DEV_USER=savdert
66
ARG DEV_UID=1000
77
ARG DEV_GID=1000
8-
ARG TZ=Europe/Istanbul
8+
ARG TZ=America/New_York
99

1010
# Environment variables
1111
ENV DEBIAN_FRONTEND=noninteractive \
@@ -34,34 +34,40 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
3434
RUN locale-gen en_US.UTF-8 && \
3535
ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone
3636

37-
# Create the user with sudo privileges
38-
RUN groupadd -g ${DEV_GID} ${DEV_USER} && \
39-
useradd -m -u ${DEV_UID} -g ${DEV_GID} -s /usr/bin/zsh ${DEV_USER} && \
37+
# Create the user with sudo privileges - Handle case where UID/GID 1000 already exists
38+
RUN if getent passwd ${DEV_UID} > /dev/null; then \
39+
EXISTING_USER=$(getent passwd ${DEV_UID} | cut -d: -f1); \
40+
usermod -l ${DEV_USER} -d /home/${DEV_USER} -m ${EXISTING_USER}; \
41+
groupmod -n ${DEV_USER} $(getent group ${DEV_GID} | cut -d: -f1); \
42+
else \
43+
groupadd -g ${DEV_GID} ${DEV_USER} && \
44+
useradd -m -u ${DEV_UID} -g ${DEV_GID} -s /usr/bin/zsh ${DEV_USER}; \
45+
fi && \
4046
echo "${DEV_USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
4147

42-
# Install mise globally
43-
RUN curl https://mise.run | sh && \
44-
mv /root/.local/bin/mise /usr/local/bin/mise
45-
4648
# Setup project directory
4749
WORKDIR /workspace
4850
COPY . /workspace
49-
RUN chown -R ${DEV_USER}:${DEV_USER} /workspace /home/${DEV_USER}
51+
RUN chown -R ${DEV_USER}:${DEV_USER} /workspace
5052

5153
USER ${DEV_USER}
5254

55+
# Install mise for the local user
56+
RUN curl https://mise.run | sh
57+
5358
# Install tools via mise during the build (caching tools in the image)
5459
RUN mise trust --quiet && \
5560
mise install --yes
5661

5762
# Symlink configurations to the user's home directory
58-
RUN mkdir -p ${HOME}/.config/zellij ${HOME}/.config/nvim && \
63+
RUN mkdir -p ${HOME}/.config/zellij ${HOME}/.config/nvim ${HOME}/.config/mise && \
5964
ln -sf /workspace/configs/.zshrc ${HOME}/.zshrc && \
6065
ln -sf /workspace/configs/starship.toml ${HOME}/.config/starship.toml && \
61-
ln -sf /workspace/configs/zellij/config.kdl ${HOME}/.config/zellij/config.kdl
66+
ln -sf /workspace/configs/zellij/config.kdl ${HOME}/.config/zellij/config.kdl && \
67+
ln -sf /workspace/mise.toml ${HOME}/.config/mise/config.toml
6268

6369
# Expose the ttyd port
6470
EXPOSE 7681
6571

66-
# Command to launch ttyd with zsh
67-
ENTRYPOINT ["ttyd", "-W", "-p", "7681", "/usr/bin/zsh"]
72+
# Command to launch ttyd with zsh (as login shell)
73+
ENTRYPOINT ["ttyd", "-W", "-p", "7681", "/usr/bin/zsh", "-l"]

configs/.zshrc

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
# --- Mise-en-place ---
2-
if [ -f "$HOME/.local/bin/mise" ]; then
3-
export PATH="$HOME/.local/bin:$PATH"
4-
eval "$($HOME/.local/bin/mise activate zsh)"
5-
elif command -v mise &>/dev/null; then
1+
# --- Language & Locale ---
2+
export LANG=en_US.UTF-8
3+
export LC_ALL=en_US.UTF-8
4+
5+
# --- PATH Setup ---
6+
# Ensure mise binaries and shims are always in PATH
7+
export PATH="$HOME/.local/bin:$HOME/.local/share/mise/shims:$PATH"
8+
9+
# --- Mise Activation ---
10+
if command -v mise &>/dev/null; then
611
eval "$(mise activate zsh)"
712
fi
813

9-
# --- Starship Prompt ---
14+
# --- Tools Initialization ---
15+
# Initialize tools after mise shims are in PATH
1016
if command -v starship &>/dev/null; then
1117
eval "$(starship init zsh)"
1218
fi
1319

14-
# --- Zoxide (Smart cd) ---
1520
if command -v zoxide &>/dev/null; then
1621
eval "$(zoxide init zsh)"
1722
fi

configs/starship.toml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Starship configuration
1+
# Starship configuration (Browser/ttyd Compatible)
22
format = """
33
$username\
44
$hostname\
@@ -12,15 +12,21 @@ $character"""
1212

1313
[directory]
1414
style = "blue"
15-
read_only = " 󰌾"
15+
read_only = " (read-only)"
1616

1717
[character]
18-
success_symbol = "[➜](bold green)"
19-
error_symbol = "[➜](bold red)"
18+
# Using standard characters that work in every browser font
19+
success_symbol = "[>](bold green)"
20+
error_symbol = "[>](bold red)"
2021

2122
[git_branch]
22-
symbol = " "
23+
symbol = "git: "
2324
style = "bold purple"
2425

2526
[git_status]
2627
style = "red"
28+
format = "([\\[$all_status$ahead_behind\\]]($style) )"
29+
30+
[cmd_duration]
31+
min_time = 500
32+
format = "took [$duration]($style) "

mise.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,12 @@ bat = "latest"
1111
lazygit = "latest"
1212
"1password-cli" = "latest"
1313

14+
[tasks.sync]
15+
description = "Sync dotfiles from GitHub and update tools"
16+
run = """
17+
git pull
18+
mise install
19+
"""
20+
1421
[settings]
1522
task.source_freshness_hash_contents = true

0 commit comments

Comments
 (0)