not-lain commited on
Commit
8d94b26
1 Parent(s): f5c1c32

switch to vscode

Browse files
Dockerfile CHANGED
@@ -6,7 +6,7 @@ ENV DEBIAN_FRONTEND=noninteractive \
6
  # Remove any third-party apt sources to avoid issues with expiring keys.
7
  # Install some basic utilities
8
  RUN rm -f /etc/apt/sources.list.d/*.list && \
9
- apt-get update && apt-get install -y --no-install-recommends \
10
  curl \
11
  ca-certificates \
12
  sudo \
@@ -22,7 +22,38 @@ RUN rm -f /etc/apt/sources.list.d/*.list && \
22
  software-properties-common \
23
  && rm -rf /var/lib/apt/lists/*
24
 
25
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  RUN add-apt-repository ppa:flexiondotorg/nvtop && \
28
  apt-get upgrade -y && \
@@ -40,13 +71,6 @@ RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
40
  && chown -R user:user /app
41
  RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
42
  USER user
43
- # RUN apt-get update && \
44
- # apt-get -y install sudo
45
-
46
- # RUN useradd -m docker && echo "docker:docker" | chpasswd && adduser docker sudo
47
-
48
- # USER docker
49
-
50
 
51
  # All users can use /home/user as their home directory
52
  ENV HOME=/home/user
@@ -80,8 +104,6 @@ RUN --mount=target=/root/packages.txt,source=packages.txt \
80
  RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
81
  bash /root/on_startup.sh
82
 
83
- RUN mkdir /data && chown user:user /data
84
-
85
  #######################################
86
  # End root user section
87
  #######################################
@@ -97,8 +119,6 @@ COPY --chown=user . $HOME/app
97
 
98
  RUN chmod +x start_server.sh
99
 
100
- COPY --chown=user login.html /home/user/miniconda/lib/python3.9/site-packages/jupyter_server/templates/login.html
101
-
102
  ENV PYTHONUNBUFFERED=1 \
103
  GRADIO_ALLOW_FLAGGING=never \
104
  GRADIO_NUM_PORTS=1 \
@@ -107,4 +127,6 @@ ENV PYTHONUNBUFFERED=1 \
107
  SYSTEM=spaces \
108
  SHELL=/bin/bash
109
 
 
 
110
  CMD ["./start_server.sh"]
 
6
  # Remove any third-party apt sources to avoid issues with expiring keys.
7
  # Install some basic utilities
8
  RUN rm -f /etc/apt/sources.list.d/*.list && \
9
+ apt-get update && apt-get install -y \
10
  curl \
11
  ca-certificates \
12
  sudo \
 
22
  software-properties-common \
23
  && rm -rf /var/lib/apt/lists/*
24
 
25
+ ARG BUILD_DATE
26
+ ARG VERSION
27
+ ARG CODE_RELEASE
28
+ RUN \
29
+ echo "**** install openvscode-server runtime dependencies ****" && \
30
+ apt-get update && \
31
+ apt-get install -y \
32
+ jq \
33
+ libatomic1 \
34
+ nano \
35
+ net-tools \
36
+ netcat && \
37
+ echo "**** install openvscode-server ****" && \
38
+ if [ -z ${CODE_RELEASE+x} ]; then \
39
+ CODE_RELEASE=$(curl -sX GET "https://api.github.com/repos/gitpod-io/openvscode-server/releases/latest" \
40
+ | awk '/tag_name/{print $4;exit}' FS='[""]' \
41
+ | sed 's|^openvscode-server-v||'); \
42
+ fi && \
43
+ mkdir -p /app/openvscode-server && \
44
+ curl -o \
45
+ /tmp/openvscode-server.tar.gz -L \
46
+ "https://github.com/gitpod-io/openvscode-server/releases/download/openvscode-server-v${CODE_RELEASE}/openvscode-server-v${CODE_RELEASE}-linux-x64.tar.gz" && \
47
+ tar xf \
48
+ /tmp/openvscode-server.tar.gz -C \
49
+ /app/openvscode-server/ --strip-components=1 && \
50
+ echo "**** clean up ****" && \
51
+ apt-get clean && \
52
+ rm -rf \
53
+ /tmp/* \
54
+ /var/lib/apt/lists/* \
55
+ /var/tmp/*
56
+ COPY root/ /
57
 
58
  RUN add-apt-repository ppa:flexiondotorg/nvtop && \
59
  apt-get upgrade -y && \
 
71
  && chown -R user:user /app
72
  RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
73
  USER user
 
 
 
 
 
 
 
74
 
75
  # All users can use /home/user as their home directory
76
  ENV HOME=/home/user
 
104
  RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
105
  bash /root/on_startup.sh
106
 
 
 
107
  #######################################
108
  # End root user section
109
  #######################################
 
119
 
120
  RUN chmod +x start_server.sh
121
 
 
 
122
  ENV PYTHONUNBUFFERED=1 \
123
  GRADIO_ALLOW_FLAGGING=never \
124
  GRADIO_NUM_PORTS=1 \
 
127
  SYSTEM=spaces \
128
  SHELL=/bin/bash
129
 
130
+ EXPOSE 7860 3000
131
+
132
  CMD ["./start_server.sh"]
Dockerfile-tmp DELETED
@@ -1,112 +0,0 @@
1
- # ARG COMPAT=0
2
- ARG PERSONAL=0
3
- # FROM nvidia/cuda:11.3.1-devel-ubuntu20.04 as base-0
4
- FROM nvcr.io/nvidia/pytorch:22.12-py3 as base
5
-
6
- ENV HOST docker
7
- ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
8
- # https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes
9
- ENV TZ America/Los_Angeles
10
- RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
11
-
12
- # git for installing dependencies
13
- # tzdata to set time zone
14
- # wget and unzip to download data
15
- # [2021-09-09] TD: zsh, stow, subversion, fasd are for setting up my personal environment.
16
- # [2021-12-07] TD: openmpi-bin for MPI (multi-node training)
17
- RUN apt-get update && apt-get install -y --no-install-recommends \
18
- build-essential \
19
- cmake \
20
- curl \
21
- ca-certificates \
22
- sudo \
23
- less \
24
- htop \
25
- git \
26
- tzdata \
27
- wget \
28
- tmux \
29
- zip \
30
- unzip \
31
- zsh stow subversion fasd \
32
- && rm -rf /var/lib/apt/lists/*
33
- # openmpi-bin \
34
-
35
- # Allow running runmpi as root
36
- # ENV OMPI_ALLOW_RUN_AS_ROOT=1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
37
-
38
- # # Create a non-root user and switch to it
39
- # RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
40
- # && echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
41
- # USER user
42
-
43
- # All users can use /home/user as their home directory
44
- ENV HOME=/home/user
45
- RUN mkdir -p /home/user && chmod 777 /home/user
46
- WORKDIR /home/user
47
-
48
- # Set up personal environment
49
- # FROM base-${COMPAT} as env-0
50
- FROM base as env-0
51
- FROM env-0 as env-1
52
- # Use ONBUILD so that the dotfiles dir doesn't need to exist unless we're building a personal image
53
- # https://stackoverflow.com/questions/31528384/conditional-copy-add-in-dockerfile
54
- ONBUILD COPY dotfiles ./dotfiles
55
- ONBUILD RUN cd ~/dotfiles && stow bash zsh tmux && sudo chsh -s /usr/bin/zsh $(whoami)
56
- # nvcr pytorch image sets SHELL=/bin/bash
57
- ONBUILD ENV SHELL=/bin/zsh
58
-
59
- FROM env-${PERSONAL} as packages
60
-
61
- # Disable pip cache: https://stackoverflow.com/questions/45594707/what-is-pips-no-cache-dir-good-for
62
- ENV PIP_NO_CACHE_DIR=1
63
-
64
- # # apex and pytorch-fast-transformers take a while to compile so we install them first
65
- # TD [2022-04-28] apex is already installed. In case we need a newer commit:
66
- # RUN pip install --upgrade --force-reinstall --global-option="--cpp_ext" --global-option="--cuda_ext" --global-option="--fast_multihead_attn" --global-option="--fmha" --global-option="--fast_layer_norm" --global-option="--xentropy" git+https://github.com/NVIDIA/apex.git#egg=apex
67
-
68
- # xgboost conflicts with deepspeed
69
- RUN pip uninstall -y xgboost && DS_BUILD_UTILS=1 DS_BUILD_FUSED_LAMB=1 pip install deepspeed==0.7.7
70
-
71
- # General packages that we don't care about the version
72
- # zstandard to extract the_pile dataset
73
- # psutil to get the number of cpu physical cores
74
- # twine to upload package to PyPI
75
- RUN pip install pytest matplotlib jupyter ipython ipdb gpustat scikit-learn spacy munch einops opt_einsum fvcore gsutil cmake pykeops zstandard psutil h5py twine gdown \
76
- && python -m spacy download en_core_web_sm
77
- # hydra
78
- RUN pip install hydra-core==1.3.1 hydra-colorlog==1.2.0 hydra-optuna-sweeper==1.2.0 pyrootutils rich
79
- # Core packages
80
- RUN pip install transformers==4.25.1 datasets==2.8.0 pytorch-lightning==1.8.6 triton==2.0.0.dev20221202 wandb==0.13.7 timm==0.6.12 torchmetrics==0.10.3
81
- # torchmetrics 0.11.0 broke hydra's instantiate
82
-
83
- # For MLPerf
84
- RUN pip install git+https://github.com/mlcommons/logging.git@2.1.0
85
-
86
- # Install FlashAttention
87
- RUN pip install flash-attn==2.5.7
88
-
89
- # Install CUDA extensions for fused dense
90
- RUN pip install git+https://github.com/HazyResearch/flash-attention@v2.5.7#subdirectory=csrc/fused_dense_lib
91
-
92
-
93
- # Python packages
94
- RUN --mount=target=requirements.txt,source=requirements.txt \
95
- pip install --no-cache-dir --upgrade -r requirements.txt
96
-
97
- # Copy the current directory contents into the container at $HOME/app setting the owner to the user
98
- COPY --chown=user . $HOME/app
99
-
100
- RUN chmod +x start_server.sh
101
-
102
- COPY --chown=user login.html /home/user/miniconda/lib/python3.9/site-packages/jupyter_server/templates/login.html
103
-
104
- ENV PYTHONUNBUFFERED=1 \
105
- GRADIO_ALLOW_FLAGGING=never \
106
- GRADIO_NUM_PORTS=1 \
107
- GRADIO_SERVER_NAME=0.0.0.0 \
108
- GRADIO_THEME=huggingface \
109
- SYSTEM=spaces \
110
- SHELL=/bin/bash
111
-
112
- CMD ["./start_server.sh"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -1,13 +1,12 @@
1
  ---
2
- title: JupyterLab
3
  emoji: 💻🐳
4
- colorFrom: gray
5
- colorTo: green
6
  sdk: docker
7
  pinned: false
8
  tags:
9
- - jupyterlab
10
- suggested_storage: small
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Visual Studio Code
3
  emoji: 💻🐳
4
+ colorFrom: red
5
+ colorTo: blue
6
  sdk: docker
7
  pinned: false
8
  tags:
9
+ - vscode
 
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
login.html DELETED
@@ -1,69 +0,0 @@
1
- {% extends "page.html" %}
2
-
3
-
4
- {% block stylesheet %}
5
- {% endblock %}
6
-
7
- {% block site %}
8
-
9
- <div id="jupyter-main-app" class="container">
10
-
11
- <img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" alt="Hugging Face Logo">
12
- <h4>You can duplicate this Space to run it private.</h4>
13
- <br>
14
- <a class="duplicate-button" style="display:inline-block" target="_blank" href="https://huggingface.co/spaces/DockerTemplates/jupyterlab?duplicate=true">
15
- <img style="margin: 0" src="https://img.shields.io/badge/-Duplicate%20Space-blue?labelColor=white&amp;style=flat&amp;logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAP5JREFUOE+lk7FqAkEURY+ltunEgFXS2sZGIbXfEPdLlnxJyDdYB62sbbUKpLbVNhyYFzbrrA74YJlh9r079973psed0cvUD4A+4HoCjsA85X0Dfn/RBLBgBDxnQPfAEJgBY+A9gALA4tcbamSzS4xq4FOQAJgCDwV2CPKV8tZAJcAjMMkUe1vX+U+SMhfAJEHasQIWmXNN3abzDwHUrgcRGmYcgKe0bxrblHEB4E/pndMazNpSZGcsZdBlYJcEL9Afo75molJyM2FxmPgmgPqlWNLGfwZGG6UiyEvLzHYDmoPkDDiNm9JR9uboiONcBXrpY1qmgs21x1QwyZcpvxt9NS09PlsPAAAAAElFTkSuQmCC&amp;logoWidth=14" alt="Duplicate Space"></a>
16
- <br>
17
- <br>
18
- <h4>The default token is <span style="color:orange;">huggingface</span></h4>
19
- <h4>Duplicate the Space to run your own instance</h4>
20
-
21
- {% if login_available %}
22
- {# login_available means password-login is allowed. Show the form. #}
23
- <div class="row">
24
- <div class="navbar col-sm-8">
25
- <div class="navbar-inner">
26
- <div class="container">
27
- <div class="center-nav">
28
- <form action="{{base_url}}login?next={{next}}" method="post" class="navbar-form pull-left">
29
- {{ xsrf_form_html() | safe }}
30
- {% if token_available %}
31
- <label for="password_input"><strong>{% trans %}Token:{% endtrans
32
- %}</strong></label>
33
- {% else %}
34
- <label for="password_input"><strong>{% trans %}Password:{% endtrans %}</strong></label>
35
- {% endif %}
36
- <input type="password" name="password" id="password_input" class="form-control">
37
- <button type="submit" class="btn btn-default" id="login_submit">{% trans %}Log in{% endtrans
38
- %}</button>
39
- </form>
40
- </div>
41
- </div>
42
- </div>
43
- </div>
44
- </div>
45
- {% else %}
46
- <p>{% trans %}No login available, you shouldn't be seeing this page.{% endtrans %}</p>
47
- {% endif %}
48
- <p>This template was created by <a href="https://twitter.com/camenduru" target="_blank" >camenduru</a> and <a href="https://huggingface.co/nateraw" target="_blank" >nateraw</a>, with contributions of <a href="https://huggingface.co/osanseviero" target="_blank" >osanseviero</a> and <a href="https://huggingface.co/azzr" target="_blank" >azzr</a> </p>
49
- {% if message %}
50
- <div class="row">
51
- {% for key in message %}
52
- <div class="message {{key}}">
53
- {{message[key]}}
54
- </div>
55
- {% endfor %}
56
- </div>
57
- {% endif %}
58
- {% if token_available %}
59
- {% block token_message %}
60
-
61
- {% endblock token_message %}
62
- {% endif %}
63
- </div>
64
-
65
- {% endblock %}
66
-
67
-
68
- {% block script %}
69
- {% endblock %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -1,4 +1 @@
1
- jupyterlab==3.6.1
2
- jupyter-server==2.3.0
3
- tornado==6.2
4
- ipywidgets
 
1
+ # jupyterlab
 
 
 
root/etc/s6-overlay/s6-rc.d/init-config-end/dependencies.d/init-openvscode-server ADDED
File without changes
root/etc/s6-overlay/s6-rc.d/init-openvscode-server/dependencies.d/init-config ADDED
File without changes
root/etc/s6-overlay/s6-rc.d/init-openvscode-server/run ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/with-contenv bash
2
+
3
+ mkdir -p /config/{workspace,.ssh}
4
+
5
+ if [ -n "${SUDO_PASSWORD}" ] || [ -n "${SUDO_PASSWORD_HASH}" ]; then
6
+ echo "setting up sudo access"
7
+ if ! grep -q 'abc' /etc/sudoers; then
8
+ echo "adding abc to sudoers"
9
+ echo "abc ALL=(ALL:ALL) ALL" >> /etc/sudoers
10
+ fi
11
+ if [ -n "${SUDO_PASSWORD_HASH}" ]; then
12
+ echo "setting sudo password using sudo password hash"
13
+ sed -i "s|^abc:\!:|abc:${SUDO_PASSWORD_HASH}:|" /etc/shadow
14
+ else
15
+ echo "setting sudo password using SUDO_PASSWORD env var"
16
+ echo -e "${SUDO_PASSWORD}\n${SUDO_PASSWORD}" | passwd abc
17
+ fi
18
+ fi
19
+
20
+ [[ ! -f /config/.bashrc ]] && \
21
+ cp /root/.bashrc /config/.bashrc
22
+ [[ ! -f /config/.profile ]] && \
23
+ cp /root/.profile /config/.profile
24
+
25
+ # fix permissions (ignore contents of /config/workspace)
26
+ echo "setting permissions::config"
27
+ find /config -path /config/workspace -prune -o -exec chown abc:abc {} +
28
+ chown abc:abc /config/workspace
29
+ echo "setting permissions::app"
30
+ chown -R abc:abc /app/openvscode-server
31
+
32
+ chmod 700 /config/.ssh
33
+ if [ -n "$(ls -A /config/.ssh)" ]; then
34
+ chmod 600 /config/.ssh/*
35
+ fi
root/etc/s6-overlay/s6-rc.d/init-openvscode-server/type ADDED
@@ -0,0 +1 @@
 
 
1
+ oneshot
root/etc/s6-overlay/s6-rc.d/init-openvscode-server/up ADDED
@@ -0,0 +1 @@
 
 
1
+ /etc/s6-overlay/s6-rc.d/init-openvscode-server/run
root/etc/s6-overlay/s6-rc.d/svc-openvscode-server/dependencies.d/init-services ADDED
File without changes
root/etc/s6-overlay/s6-rc.d/svc-openvscode-server/notification-fd ADDED
@@ -0,0 +1 @@
 
 
1
+ 3
root/etc/s6-overlay/s6-rc.d/svc-openvscode-server/run ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/with-contenv bash
2
+
3
+ if [ -n "$CONNECTION_SECRET" ]; then
4
+ CODE_ARGS="${CODE_ARGS} --connection-secret ${CONNECTION_SECRET}"
5
+ echo "Using connection secret from ${CONNECTION_SECRET}"
6
+ elif [ -n "$CONNECTION_TOKEN" ]; then
7
+ CODE_ARGS="${CODE_ARGS} --connection-token ${CONNECTION_TOKEN}"
8
+ echo "Using connection token ${CONNECTION_TOKEN}"
9
+ else
10
+ CODE_ARGS="${CODE_ARGS} --without-connection-token"
11
+ echo "**** No connection token is set ****"
12
+ fi
13
+
14
+ exec \
15
+ s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z 127.0.0.1 3000" \
16
+ cd /app/openvscode-server s6-setuidgid abc \
17
+ /app/openvscode-server/bin/openvscode-server \
18
+ --host 0.0.0.0 \
19
+ --port 3000 \
20
+ --disable-telemetry \
21
+ ${CODE_ARGS}
root/etc/s6-overlay/s6-rc.d/svc-openvscode-server/type ADDED
@@ -0,0 +1 @@
 
 
1
+ longrun
root/etc/s6-overlay/s6-rc.d/user/contents.d/init-openvscode-server ADDED
File without changes
root/etc/s6-overlay/s6-rc.d/user/contents.d/svc-openvscode-server ADDED
File without changes
root/usr/local/bin/install-extension ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/with-contenv bash
2
+ # shellcheck shell=bash
3
+
4
+ _install=(/app/openvscode-server/bin/openvscode-server "--install-extension")
5
+
6
+ if [ "$(whoami)" == "abc" ]; then
7
+ "${_install[@]}" "$@"
8
+ else
9
+ s6-setuidgid abc "${_install[@]}" "$@"
10
+ fi
start_server.sh CHANGED
@@ -1,19 +1,5 @@
1
  #!/bin/bash
2
- JUPYTER_TOKEN="${JUPYTER_TOKEN:=huggingface}"
3
 
4
- echo "Starting Jupyter Lab with token $JUPYTER_TOKEN"
5
 
6
- NOTEBOOK_DIR="/data"
7
-
8
- jupyter-lab \
9
- --ip 0.0.0.0 \
10
- --port 7860 \
11
- --no-browser \
12
- --allow-root \
13
- --ServerApp.token="$JUPYTER_TOKEN" \
14
- --ServerApp.tornado_settings="{'headers': {'Content-Security-Policy': 'frame-ancestors *'}}" \
15
- --ServerApp.cookie_options="{'SameSite': 'None', 'Secure': True}" \
16
- --ServerApp.disable_check_xsrf=True \
17
- --LabApp.news_url=None \
18
- --LabApp.check_for_updates_class="jupyterlab.NeverCheckForUpdate" \
19
- --notebook-dir=$NOTEBOOK_DIR
 
1
  #!/bin/bash
 
2
 
3
+ echo "Starting VSCode Server..."
4
 
5
+ exec /app/openvscode-server/bin/openvscode-server --host 0.0.0.0 --port 7860 --without-connection-token \"${@}\" --