Unsterile commited on
Commit
719c2e7
·
1 Parent(s): b527ed7

Upload Dockerfile with huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +129 -0
Dockerfile ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM ubuntu
2
+
3
+ ENV DEBIAN_FRONTEND=noninteractive \
4
+ TZ=Asia/Jakarta \
5
+ SHELL=/bin/bash
6
+
7
+ # Remove any third-party apt sources to avoid issues with expiring keys.
8
+ # Install some basic utilities
9
+ RUN rm -f /etc/apt/sources.list.d/*.list && \
10
+ apt-get update && apt-get install -y \
11
+ curl \
12
+ wget \
13
+ ca-certificates \
14
+ sudo \
15
+ git \
16
+ git-lfs \
17
+ zip \
18
+ unzip \
19
+ htop \
20
+ bzip2 \
21
+ libx11-6 \
22
+ build-essential \
23
+ libsndfile-dev \
24
+ software-properties-common \
25
+ && rm -rf /var/lib/apt/lists/*
26
+
27
+ # Install openvscode-server runtime dependencies
28
+ RUN apt-get update && \
29
+ apt-get install -y \
30
+ jq \
31
+ libatomic1 \
32
+ nano \
33
+ net-tools \
34
+ netcat
35
+
36
+ # Setup tailscale
37
+ RUN curl -fsSL https://tailscale.com/install.sh | sh
38
+ RUN mkdir -p /var/run && ln -s /tmp/tailscale /var/run/tailscale && \
39
+ mkdir -p /var/cache && ln -s /tmp/tailscale /var/cache/tailscale && \
40
+ mkdir -p /var/lib && ln -s /tmp/tailscale /var/lib/tailscale && \
41
+ mkdir -p /var/task && ln -s /tmp/tailscale /var/task/tailscale
42
+
43
+ # Create a working directory
44
+ WORKDIR /app
45
+
46
+ # Create a non-root user and switch to it
47
+ RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
48
+ && chown -R user:user /app
49
+ RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
50
+
51
+ # Fetch the latest version of Code Server
52
+ RUN curl -s "https://api.github.com/repos/coder/code-server/releases/latest" \
53
+ | grep "browser_download_url.*linux-amd64.tar.gz" \
54
+ | cut -d : -f 2,3 \
55
+ | tr -d \" \
56
+ | wget -qi - -O /tmp/code-server.tar.gz && \
57
+ mkdir -p /app/code-server && \
58
+ tar -xzf /tmp/code-server.tar.gz -C /app/code-server --strip-components=1
59
+
60
+ # Install NVM and set 16 as default
61
+ RUN mkdir /app/.nvm
62
+ ENV NVM_DIR /app/.nvm
63
+
64
+ USER user
65
+
66
+ # All users can use /home/user as their home directory
67
+ ENV HOME=/home/user \
68
+ PATH=/home/user/.local/bin:$PATH
69
+ RUN mkdir $HOME/.cache $HOME/.config \
70
+ && chmod 700 $HOME/.cache $HOME/.config
71
+
72
+ # Set brew env
73
+ ENV MANPATH="$MANPATH:/home/linuxbrew/.linuxbrew/share/man" \
74
+ INFOPATH="$INFOPATH:/home/linuxbrew/.linuxbrew/share/info"
75
+
76
+ # Set up the Conda environment
77
+ ENV CONDA_AUTO_UPDATE_CONDA=false \
78
+ PATH=$HOME/miniconda/bin:$PATH
79
+ RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh \
80
+ && chmod +x ~/miniconda.sh \
81
+ && ~/miniconda.sh -b -p ~/miniconda \
82
+ && rm ~/miniconda.sh \
83
+ && conda clean -ya
84
+
85
+ WORKDIR $HOME/app
86
+
87
+ #######################################
88
+ # Start root user section
89
+ #######################################
90
+
91
+ USER root
92
+
93
+ # User Debian packages
94
+ ## Security warning : Potential user code executed as root (build time)
95
+ RUN --mount=target=/root/packages.txt,source=packages.txt \
96
+ apt-get update && \
97
+ xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
98
+ && rm -rf /var/lib/apt/lists/* \
99
+ && rm -rf /var/cache/apt/* \
100
+ && rm -rf /var/lib/apt/lists/* \
101
+ && rm -rf /var/tmp/* \
102
+ && rm -rf /tmp/*
103
+
104
+ RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
105
+ bash /root/on_startup.sh
106
+
107
+ # NPM Global
108
+ RUN --mount=target=/root/npm_packages.txt,source=npm_packages.txt \
109
+ . "$NVM_DIR/nvm.sh" ; nvm use 16 && cat /root/npm_packages.txt | xargs npm install -g
110
+
111
+ RUN chown -R user:user /home/*
112
+
113
+ #######################################
114
+ # End root user section
115
+ #######################################
116
+
117
+ USER user
118
+
119
+ # Python packages
120
+ RUN --mount=target=requirements.txt,source=requirements.txt \
121
+ pip install --no-cache-dir --upgrade -r requirements.txt
122
+
123
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
124
+ RUN mkdir -p /tmp/tailscale
125
+ COPY --chown=user . $HOME/app
126
+ COPY --chown=user --from=caddy:2-alpine /usr/bin/caddy /usr/bin/caddy
127
+ RUN chmod +x start.sh
128
+
129
+ ENTRYPOINT ["./start.sh"]