Skip to content

Instantly share code, notes, and snippets.

@eramax
Created September 10, 2023 10:15
Show Gist options
  • Save eramax/e083a250302306a6263bd869f5073b1b to your computer and use it in GitHub Desktop.
Save eramax/e083a250302306a6263bd869f5073b1b to your computer and use it in GitHub Desktop.
coder.Dockerfile
FROM ubuntu as base
LABEL maintainer="Ahmed Morsi"
ENV TZ Europe/Stockholm
ENV DEBIAN_FRONTEND noninteractive
# apps
RUN apt-get update && apt-get install -y curl tzdata nano htop cargo nodejs npm yarn build-essential git cmake locales zsh btop sudo iputils-ping wget tree jq python3 python3-pip
RUN apt-get -y autoremove
RUN apt-get -y clean
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
RUN locale-gen
RUN update-locale LANG=en_US.UTF-8
RUN useradd -m coder -s /bin/zsh -g root -G sudo -u 1001
RUN echo 'coder ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
RUN curl -fsSL https://code-server.dev/install.sh | sh
FROM base
LABEL maintainer="Ahmed Morsi"
USER coder
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
RUN sh -c "git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting"
RUN sh -c "git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions"
RUN sed -i 's/plugins=(git)/plugins=(git zsh-syntax-highlighting zsh-autosuggestions)/' ~/.zshrc
RUN git config --global --add oh-my-zsh.hide-dirty 1
# entrypoint
RUN { \
echo '#!/bin/bash -eu'; \
#echo 'ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime'; \
echo 'echo "coder:${CODER_PASSWORD}" | sudo chpasswd'; \
echo 'exec code-server --bind-addr 0.0.0.0:80 --auth none "$@"'; \
} > /home/coder/entry_point.sh
RUN chmod +x /home/coder/entry_point.sh
EXPOSE 22
ENV CODER_PASSWORD P@sswrd
ENTRYPOINT ["/home/coder/entry_point.sh"]
#ENTRYPOINT ["tail", "-f", "/dev/null"]
#CMD ["/usr/sbin/sshd", "-D", "-e"]
@eramax
Copy link
Author

eramax commented Sep 10, 2023

deployment.yml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: ssh4
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ssh4
  template:
    metadata:
      labels:
        app: ssh4
    spec:
      containers:
      - image: eramax/sshd:coder5
        imagePullPolicy: Always
        name: ssh4
        ports:
        - containerPort: 80
        env:
        - name: CODER_PASSWORD
          value: "P@ssword"
---
apiVersion: v1
kind: Service
metadata:
  name: ssh4
spec:
  ports:
  - name: web
    port: 80
    targetPort: 80
  selector:
    app: ssh4
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: ssh4-ingress
spec:
  entryPoints:
  - web
  routes:
  - kind: Rule
    match: Host(`ssh4.xxx.emolike.net`)
    services:
    - name: ssh4
      port: 80

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