File size: 4,502 Bytes
13e45be
 
ea82ba2
 
13e45be
 
 
 
 
 
 
 
 
 
 
 
c469205
 
 
13e45be
 
 
 
 
 
 
 
ea82ba2
 
 
 
 
 
 
 
 
 
 
 
 
13e45be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21c5ce7
 
 
 
 
 
2f54c4a
21c5ce7
 
 
 
2f54c4a
 
21c5ce7
 
3c92d46
13e45be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
FROM nvidia/cuda:12.2.0-devel-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && \
    apt install -y --no-install-recommends \
        curl \
        git \
        git-lfs \
        libatomic1 \
        locales \
        man \
        nano \
        net-tools \
        netcat \
        openssh-client \
        python3 \
        python3-pip \
        python3-venv \
        sudo \
        vim \
        wget \
        zsh \
        zip \
        unzip \
        ffmpeg \
        imagemagick \
        build-essential \
        libssl-dev \
        libffi-dev \
        python3-dev \
        libblas-dev \
        liblapack-dev \
        gfortran \
        libsndfile1 \
        libespeak-ng1 \
        libportaudio2 \
        libportaudiocpp0 \
        portaudio19-dev \
        libsndfile1-dev \
    && git lfs install \
    && rm -rf /var/lib/apt/lists/*

# Fix ImageMagick policy
RUN sed -i '/<policy domain="path" rights="none" pattern="@\*"/d' /etc/ImageMagick-6/policy.xml

WORKDIR /home/

ENV USERNAME=user \
    USER_UID=1000 \
    USER_GID=1000 \
    LANG=C.UTF-8 \
    LC_ALL=C.UTF-8 \
    NVIDIA_VISIBLE_DEVICES=all \
    NVIDIA_DRIVER_CAPABILITIES=all \
    EDITOR=code \
    VISUAL=code \
    GIT_EDITOR="code --wait" \
    OPENVSCODE_SERVER_ROOT=/home/.vscode \
    OPENVSCODE=/home/.vscode/bin/openvscode-server \
    PATH=/home/user/.local/bin:$PATH

# Downloading the latest VSC Server release and extracting the release archive
# Rename `openvscode-server` cli tool to `code` for convenience
RUN RELEASE_TAG=$(curl -sX GET "https://api.github.com/repos/gitpod-io/openvscode-server/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]') && \
    arch=$(uname -m) && \
    if [ "${arch}" = "x86_64" ]; then \
        arch="x64"; \
    elif [ "${arch}" = "aarch64" ]; then \
        arch="arm64"; \
    elif [ "${arch}" = "armv7l" ]; then \
        arch="armhf"; \
    fi && \
    wget https://github.com/gitpod-io/openvscode-server/releases/download/${RELEASE_TAG}/${RELEASE_TAG}-linux-${arch}.tar.gz && \
    tar -xzf ${RELEASE_TAG}-linux-${arch}.tar.gz && \
    mv ${RELEASE_TAG}-linux-${arch} ${OPENVSCODE_SERVER_ROOT} && \
    cp ${OPENVSCODE_SERVER_ROOT}/bin/remote-cli/openvscode-server ${OPENVSCODE_SERVER_ROOT}/bin/remote-cli/code && \
    rm -f ${RELEASE_TAG}-linux-${arch}.tar.gz

# Install latest Firefox
RUN sudo install -d -m 0755 /etc/apt/keyrings && \
    wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | sudo tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null && \
    echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | sudo tee -a /etc/apt/sources.list.d/mozilla.list > /dev/null && \
    echo 'Package: *\nPin: origin packages.mozilla.org\nPin-Priority: 1000' | sudo tee /etc/apt/preferences.d/mozilla && \
    sudo apt-get update && sudo apt-get install -y firefox

# Download and install latest GeckoDriver
RUN GECKO_LATEST=$(curl -sL https://api.github.com/repos/mozilla/geckodriver/releases/latest | grep tag_name | cut -d '"' -f 4) && \
    wget https://github.com/mozilla/geckodriver/releases/download/${GECKO_LATEST}/geckodriver-${GECKO_LATEST}-linux64.tar.gz && \
    tar -xvzf geckodriver-${GECKO_LATEST}-linux64.tar.gz && \
    sudo mv geckodriver /usr/local/bin/ && \
    sudo chmod +x /usr/local/bin/geckodriver && \
    rm geckodriver-${GECKO_LATEST}-linux64.tar.gz && \
    geckodriver --version  

WORKDIR /home/user/

# Creating the user and usergroup
RUN groupadd --gid ${USER_GID} ${USERNAME} \
    && useradd --uid ${USER_UID} --gid ${USERNAME} -m -s /bin/bash ${USERNAME} \
    && echo ${USERNAME} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USERNAME} \
    && chmod 0440 /etc/sudoers.d/${USERNAME}

RUN chmod g+rw /home && \
    chown -R ${USERNAME}:${USERNAME} ${OPENVSCODE_SERVER_ROOT} && \
    chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}

USER $USERNAME

# Install oh-my-zsh & Init
RUN yes | sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# Install VSCode Extensions
RUN ${OPENVSCODE} --install-extension ms-python.python && \
    ${OPENVSCODE} --install-extension monokai.theme-monokai-pro-vscode

# Install python packages
COPY requirements.txt .
RUN pip install --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt && \
    rm -rf requirements.txt

ENTRYPOINT ["/bin/sh", "-c", "exec $OPENVSCODE --host 0.0.0.0 --port 7860 --without-connection-token"]