-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
75 lines (56 loc) · 3.06 KB
/
Dockerfile
File metadata and controls
75 lines (56 loc) · 3.06 KB
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
# Use the official code-server image as the base
FROM codercom/code-server:latest
# Set the working directory
WORKDIR /home/coder
# Install Node.js, yarn, and Python (required for VS Code extension builds and testing)
USER root
RUN apt-get update && apt-get install -y \
curl \
python3 \
python3-pip \
python3-venv \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g yarn \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Create symlink for python command
RUN ln -s /usr/bin/python3 /usr/bin/python
# Switch back to coder user
USER coder
# Create workspace directory
RUN mkdir -p /home/coder/workspace
# Copy the entire project context (will be filtered by .dockerignore)
COPY --chown=coder:coder . /home/coder/project/
# Build the VS Code extension
WORKDIR /home/coder/project
RUN yarn install && yarn compile
# Install vsce for packaging the extension (as root, then switch back)
USER root
RUN yarn global add @vscode/vsce
USER coder
# Package the extension as .vsix
RUN vsce package --out extension.vsix
# Install the extension in code-server
RUN code-server --install-extension ./extension.vsix
# Install Python extension for code-server
RUN code-server --install-extension ms-python.python
# Copy workspace files to the workspace directory
RUN cp -r workspace/* /home/coder/workspace/
# Create VS Code settings to use virtual environment Python
RUN mkdir -p /home/coder/workspace/.vscode && \
echo '{\n "python.defaultInterpreterPath": "/home/coder/workspace/tests/venv/bin/python"\n}' > /home/coder/workspace/.vscode/settings.json
# Create and activate virtual environment, then install Python test requirements
RUN cd /home/coder/workspace/tests && \
python3 -m venv venv && \
venv/bin/pip install -r requirements.txt
# Create a simple README for the workspace
RUN echo "# Debrief Extension Preview\n\nThis is a preview environment for the Debrief VS Code extension.\n\n## Sample Files\n\n- \`*.rep\` files: Debrief replay files\n- \`*.plot.json\` files: Plot data visualization files\n\n## Usage\n\n1. Open any .plot.json file to see the custom Plot JSON editor\n2. Use Ctrl+Shift+P to access the 'Hello World' command\n3. Check the 'Hello World' view in the Explorer panel\n\n## Python Scripts\n\nPython scripts can be run directly with F5 or using the Run button in VS Code. The environment is pre-configured to use the virtual environment automatically.\n\nAlternatively, you can run scripts manually:\n\n\`\`\`bash\ncd tests\n./venv/bin/python move_point_north_simple.py\n\`\`\`\n\nThis environment includes sample data files for testing the extension features." > /home/coder/workspace/README.md
# Set workspace as the default directory
WORKDIR /home/coder/workspace
# Expose the code-server port
EXPOSE 8080
# Start code-server with no password authentication
# (PASSWORD and SUDO_PASSWORD are not set to avoid security warnings)
# Start code-server with the workspace
CMD ["code-server", "--bind-addr", "0.0.0.0:8080", "--auth", "none", "--disable-telemetry", "/home/coder/workspace"]