nateraw commited on
Commit
f3ec5f5
1 Parent(s): e3ee5a6

Synced repo using 'sync_with_huggingface' Github Action

Browse files
Dockerfile ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:11.3.1-base-ubuntu20.04
2
+
3
+ # Remove any third-party apt sources to avoid issues with expiring keys.
4
+ RUN rm -f /etc/apt/sources.list.d/*.list
5
+
6
+ ENV DEBIAN_FRONTEND=noninteractive \
7
+ TZ=Europe/Paris
8
+
9
+ # Install some basic utilities
10
+ RUN apt-get update && apt-get install -y \
11
+ curl \
12
+ ca-certificates \
13
+ sudo \
14
+ git \
15
+ git-lfs \
16
+ zip \
17
+ unzip \
18
+ htop \
19
+ bzip2 \
20
+ libx11-6 \
21
+ build-essential \
22
+ libsndfile-dev \
23
+ software-properties-common \
24
+ && rm -rf /var/lib/apt/lists/*
25
+
26
+ ARG BUILD_DATE
27
+ ARG VERSION
28
+ ARG CODE_RELEASE
29
+ RUN \
30
+ echo "**** install openvscode-server runtime dependencies ****" && \
31
+ apt-get update && \
32
+ apt-get install -y \
33
+ jq \
34
+ libatomic1 \
35
+ nano \
36
+ net-tools \
37
+ netcat && \
38
+ echo "**** install openvscode-server ****" && \
39
+ if [ -z ${CODE_RELEASE+x} ]; then \
40
+ CODE_RELEASE=$(curl -sX GET "https://api.github.com/repos/gitpod-io/openvscode-server/releases/latest" \
41
+ | awk '/tag_name/{print $4;exit}' FS='[""]' \
42
+ | sed 's|^openvscode-server-v||'); \
43
+ fi && \
44
+ mkdir -p /app/openvscode-server && \
45
+ curl -o \
46
+ /tmp/openvscode-server.tar.gz -L \
47
+ "https://github.com/gitpod-io/openvscode-server/releases/download/openvscode-server-v${CODE_RELEASE}/openvscode-server-v${CODE_RELEASE}-linux-x64.tar.gz" && \
48
+ tar xf \
49
+ /tmp/openvscode-server.tar.gz -C \
50
+ /app/openvscode-server/ --strip-components=1 && \
51
+ echo "**** clean up ****" && \
52
+ apt-get clean && \
53
+ rm -rf \
54
+ /tmp/* \
55
+ /var/lib/apt/lists/* \
56
+ /var/tmp/*
57
+ COPY root/ /
58
+
59
+ RUN add-apt-repository ppa:flexiondotorg/nvtop
60
+ RUN apt-get upgrade -y
61
+ RUN apt-get install -y nvtop
62
+
63
+ RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
64
+ RUN apt-get install -y nodejs
65
+ RUN npm install -g configurable-http-proxy
66
+
67
+ # Create a working directory
68
+ RUN mkdir -p /app
69
+ WORKDIR /app
70
+
71
+ # Create a non-root user and switch to it
72
+ RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
73
+ && chown -R user:user /app
74
+ RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
75
+ USER user
76
+
77
+ # All users can use /home/user as their home directory
78
+ ENV HOME=/home/user
79
+ RUN mkdir $HOME/.cache $HOME/.config \
80
+ && chmod -R 777 $HOME
81
+
82
+ # Set up the Conda environment
83
+ ENV CONDA_AUTO_UPDATE_CONDA=false \
84
+ PATH=$HOME/miniconda/bin:$PATH
85
+ RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh \
86
+ && chmod +x ~/miniconda.sh \
87
+ && ~/miniconda.sh -b -p ~/miniconda \
88
+ && rm ~/miniconda.sh \
89
+ && conda clean -ya
90
+
91
+ WORKDIR $HOME/app
92
+
93
+ #######################################
94
+ # Start root user section
95
+ #######################################
96
+
97
+ USER root
98
+
99
+ # User Debian packages
100
+ ## Security warning : Potential user code executed as root (build time)
101
+ COPY --chown=root packages.txt /root/packages.txt
102
+ RUN apt-get update && xargs -r -a /root/packages.txt apt-get install -y && rm -rf /var/lib/apt/lists/*
103
+
104
+ COPY --chown=root on_startup.sh /root/on_startup.sh
105
+ RUN chmod +x /root/on_startup.sh
106
+ RUN /root/on_startup.sh
107
+
108
+ # Rerun chmod on home dir in case any new files need permisisons
109
+ RUN chmod -R 777 $HOME
110
+
111
+ #######################################
112
+ # End root user section
113
+ #######################################
114
+
115
+ USER user
116
+
117
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
118
+ COPY --chown=user . $HOME/app
119
+
120
+ RUN chmod +x start_server.sh
121
+
122
+ RUN pip install --no-cache-dir --upgrade -r $HOME/app/requirements.txt
123
+
124
+ ENV PYTHONUNBUFFERED=1 \
125
+ GRADIO_ALLOW_FLAGGING=never \
126
+ GRADIO_NUM_PORTS=1 \
127
+ GRADIO_SERVER_NAME=0.0.0.0 \
128
+ GRADIO_THEME=huggingface \
129
+ SYSTEM=spaces \
130
+ SHELL=/bin/bash
131
+
132
+ EXPOSE 7860 3000
133
+
134
+ CMD ["./start_server.sh"]
on_startup.sh ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Write some commands here that will run on root user before startup.
3
+ # For example, to clone transformers and install it in dev mode:
4
+ # git clone https://github.com/huggingface/transformers.git
5
+ # cd transformers && pip install -e ".[dev]"
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ tree
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
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 ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
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 \"${@}\" --