gitpod-io / dockerfreeze

Freeze your development environment as a Dockerfile
MIT License
12 stars 4 forks source link

Add some bash integrations for Gitpod #51

Closed JesterOrNot closed 4 years ago

JesterOrNot commented 4 years ago

@Kreyren what do you think?

JesterOrNot commented 4 years ago

@Kreyren take another look

Kreyren commented 4 years ago

Proposed dockerfile

FROM debian:latest

# FIXME: Outputs `gitpod@ws-ce281d58-997b-44b8-9107-3f2da7feede3:/workspace/gitpod-tests1$` in terminal

# To avoid bricked workspaces (https://github.com/gitpod-io/gitpod/issues/1171)
ARG DEBIAN_FRONTEND=noninteractive

USER root

ENV LANG=en_US.UTF-8
ENV LC_ALL=C

# Add 'gitpod' user
RUN useradd \
    --uid 33333 \
    --create-home --home-dir /home/gitpod \
    --shell /bin/bash \
    --password gitpod \
    gitpod || exit 1

# Install dependencies
RUN true \
    && : "Update repositories if needed" \
    && if ! apt-cache search shellcheck | grep -qP "^shellcheck -.*"; then apt-get update; fi \
    && : "Install dependencies if needed" \
    && if ! apt list --installed | grep -oP "^shellcheck -.*"; then apt-get install -y shellcheck; fi \
    && : "Clean repositories" \
    && apt-get autoremove -y \
    && : "Remove lists" \
    && rm -rf /var/lib/apt/lists/*

# Add custom functions
RUN if ! grep -qF 'ix()' /etc/bash.bashrc; then printf '%s\n' \
    '# Custom' \
    "ix() { curl -F 'f:1=<-' ix.io 2>/dev/null ;}" \
    >> /etc/bash.bashrc; fi

USER gitpod

# Cache npm
RUN npm i -g bash-language-server

And then adding this in .gitpod.yml

# FIXME: Change gitpod user on GITPOD_GIT_USER_NAME env value
tasks:
  # Does not accept Quotation without '|' ?
  - init: |
      printf 'FIXME: %s\n' "Get rid of me"
    command: |
      printf 'FIXME: %s\n' "This is a hotfix for https://github.com/gitpod-io/gitpod/issues/1252 manipulating PS1 env var"
      # FIXME: The color of second line does not transfer to the environment unless Ctrl+C is pressed
      export PS1="\033[1m\e[38;5;201m[ \t : \w : EXIT \$? ]\033[0m\e[38;5;011m\n\u@gitpod \\$ \[$(tput sgr0)\]"
      #           ^^^^^^^ - bolt
      #                  ^^^^^^^^^^^^ - Purple color
      #                                                    ^^^^^^ - remove bolt
      #                                                           ^^^^^^^^^^^ - Gold color
      clear

Relevant: https://github.com/gitpod-io/gitpod/issues/1252 Relevant: https://github.com/gitpod-io/gitpod/issues/1263