Skip to content

Commit

Permalink
Merge pull request #1001 from rsteube/docker-user
Browse files Browse the repository at this point in the history
docker: added user
  • Loading branch information
rsteube committed Mar 11, 2024
2 parents b29b47f + 3d1fbb7 commit 84fbbc3
Show file tree
Hide file tree
Showing 15 changed files with 209 additions and 95 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
# Nushell Environment Config File
#
# version = "0.85.0"
# version = "0.91.0"

def create_left_prompt [] {
let home = $nu.home-path

let dir = ([
($env.PWD | str substring 0..($home | str length) | str replace $home "~"),
($env.PWD | str substring ($home | str length)..)
] | str join)
let dir = match (do --ignore-shell-errors { $env.PWD | path relative-to $nu.home-path }) {
null => $env.PWD
'' => '~'
$relative_pwd => ([~ $relative_pwd] | path join)
}

let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold })
let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold })
let path_segment = $"($path_color)($dir)"

$path_segment | str replace --all (char path_sep) $"($separator_color)/($path_color)"
$path_segment | str replace --all (char path_sep) $"($separator_color)(char path_sep)($path_color)"
}

def create_right_prompt [] {
# create a right prompt in magenta with green separators and am/pm underlined
let time_segment = ([
(ansi reset)
(ansi magenta)
(date now | format date '%x %X %p') # try to respect user's locale
(date now | format date '%x %X') # try to respect user's locale
] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" |
str replace --regex --all "([AP]M)" $"(ansi magenta_underline)${1}")

Expand All @@ -47,6 +46,18 @@ $env.PROMPT_INDICATOR_VI_INSERT = {|| ": " }
$env.PROMPT_INDICATOR_VI_NORMAL = {|| "> " }
$env.PROMPT_MULTILINE_INDICATOR = {|| "::: " }

# If you want previously entered commands to have a different prompt from the usual one,
# you can uncomment one or more of the following lines.
# This can be useful if you have a 2-line prompt and it's taking up a lot of space
# because every command entered takes up 2 lines instead of 1. You can then uncomment
# the line below so that previously entered commands show with a single `🚀`.
# $env.TRANSIENT_PROMPT_COMMAND = {|| "🚀 " }
# $env.TRANSIENT_PROMPT_INDICATOR = {|| "" }
# $env.TRANSIENT_PROMPT_INDICATOR_VI_INSERT = {|| "" }
# $env.TRANSIENT_PROMPT_INDICATOR_VI_NORMAL = {|| "" }
# $env.TRANSIENT_PROMPT_MULTILINE_INDICATOR = {|| "" }
# $env.TRANSIENT_PROMPT_COMMAND_RIGHT = {|| "" }

# Specifies how environment variables are:
# - converted from a string to a value on Nushell startup (from_string)
# - converted from a value back to a string when running external commands (to_string)
Expand All @@ -63,16 +74,27 @@ $env.ENV_CONVERSIONS = {
}

# Directories to search for scripts when calling source or use
# The default for this is $nu.default-config-dir/scripts
$env.NU_LIB_DIRS = [
# FIXME: This default is not implemented in rust code as of 2023-09-06.
($nu.default-config-dir | path join 'scripts') # add <nushell-config-dir>/scripts
]

# Directories to search for plugin binaries when calling register
# The default for this is $nu.default-config-dir/plugins
$env.NU_PLUGIN_DIRS = [
# FIXME: This default is not implemented in rust code as of 2023-09-06.
($nu.default-config-dir | path join 'plugins') # add <nushell-config-dir>/plugins
]

# To add entries to PATH (on Windows you might use Path), you can use the following pattern:
# $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path')
# An alternate way to add entries to $env.PATH is to use the custom command `path add`
# which is built into the nushell stdlib:
# use std "path add"
# $env.PATH = ($env.PATH | split row (char esep))
# path add /some/path
# path add ($env.CARGO_HOME | path join "bin")
# path add ($env.HOME | path join ".local" "bin")
# $env.PATH = ($env.PATH | uniq)

# To load from a custom file you can use:
# source ($nu.default-config-dir | path join 'custom.nu')
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
$env:SHELL = 'powershell'
$env:STARSHIP_SHELL = 'powershell'
$env:LS_COLORS = (&vivid generate dracula)

Invoke-Expression (&starship init powershell)


Set-PSReadLineOption -Colors @{ "Selection" = "`e[7m" }
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

if ($Env:TARGET){
& $Env:TARGET _carapace | out-string | Invoke-Expression
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ $SHELL="xonsh"
$STARSHIP_SHELL="xonsh"
$LS_COLORS=$(vivid generate dracula)
$PROMPT=lambda: $(starship prompt)

$COMPLETIONS_CONFIRM=True
$COMPLETION_QUERY_LIMIT = 500

'TARGET' in ${...} && exec($($TARGET _carapace xonsh))
File renamed without changes.
File renamed without changes.
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ RUN apt-get update \
elvish \
expect \
shellcheck \
sudo \
tcsh \
xonsh \
zsh
Expand All @@ -96,8 +97,15 @@ COPY --from=oil /usr/local/bin/* /usr/local/bin/
COPY --from=starship /usr/local/bin/* /usr/local/bin/
COPY --from=vivid /usr/local/bin/* /usr/local/bin/

ADD .dockerfile/root /root
ADD .dockerfile/usr/local/bin/* /usr/local/bin/
RUN groupadd --gid 1000 carapace \
&& useradd --uid 1000 --gid 1000 --create-home carapace \
&& mkdir /.cache \
&& chmod -R a+rwx /.cache /go /opt \
&& echo " carapace ALL = NOPASSWD: ALL" >> /etc/sudoers

COPY .dockerfile/home /root/
COPY --chown=1000:1000 .dockerfile/home /home/carapace/
COPY .dockerfile/usr/local/bin/* /usr/local/bin/

ENV TERM xterm
ENTRYPOINT [ "entrypoint.sh" ]
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
build: .
image: ghcr.io/rsteube/carapace
command: sh -c 'cd /carapace/example && go build -buildvcs=false .'
user: 1000:1000
environment:
TARGET: /carapace/example/example
volumes:
Expand Down

0 comments on commit 84fbbc3

Please sign in to comment.