File size: 1,945 Bytes
70cf9fa
 
b7b6a5d
70cf9fa
 
b7b6a5d
70cf9fa
 
 
67da0ba
 
70cf9fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a112181
70cf9fa
 
 
 
 
 
 
 
 
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
# Use Python 3.9 as the base image
FROM python:3.9

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive

# Install necessary packages
RUN apt-get update && \
    apt-get install -y \
    curl \
    sudo \
    build-essential \
    default-jdk \
    default-jre \
    g++ \
    gcc

# Install code-server
RUN curl -fsSL https://code-server.dev/install.sh | sh

# Create a user to run code-server
RUN useradd -m -s /bin/bash coder && \
    echo 'coder ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# Create and set the working directory
RUN mkdir -p /home/coder/genz
WORKDIR /home/coder/genz

# Change ownership of the working directory
RUN chown -R coder:coder /home/coder/genz

# Create code-server configuration directory
RUN mkdir -p /home/coder/.config/code-server

# Add settings.json to enable dark mode and disable telemetry
RUN echo '{ \
    "workbench.colorTheme": "Default Dark+", \
    "telemetry.enableTelemetry": false, \
    "telemetry.enableCrashReporter": false \
}' > /home/coder/.config/code-server/settings.json

# Install Python extension for code-server
RUN mkdir -p /home/coder/.local/share/code-server/extensions && \
    curl -L -o /home/coder/.local/share/code-server/extensions/ms-python.python-2022.2.1924087327.vsix https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-python/vsextensions/python/2022.2.1924087327/vspackage && \
    code-server --install-extension /home/coder/.local/share/code-server/extensions/ms-python.python-2022.2.1924087327.vsix

# Change ownership of the configuration and extension directories
RUN chown -R coder:coder /home/coder/.config && \
    chown -R coder:coder /home/coder/.local

# Expose the default code-server port
EXPOSE 8080

# Define a volume for the genz folder
VOLUME /home/coder/genz

# Switch to the coder user for running code-server
USER coder
WORKDIR genz
# Start code-server
CMD ["code-server", "--bind-addr", "0.0.0.0:8080", "--auth", "none"]