Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,20 @@ Use Docker Compose to start the VS Code server:

## Environment Variables

- `PORT`: The port on which the VS Code Server will listen (default is `8586`).
- `TOKEN`: A token for authentication. If not provided, a default token will be generated.
- `SERVER_DATA_DIR`: The directory where the server data is stored.
- `USER_DATA_DIR`: The directory where user data is stored.
- `EXTENSIONS_DIR`: The directory where extensions are stored.
The following environment variables can be configured:

| Variable | Description | Default |
|----------|-------------|---------|
| `PORT` | The port on which VS Code Server will listen | `8585` |
| `HOST` | The host interface to listen on | `0.0.0.0` |
| `TOKEN` | A connection token for authentication | No token if not provided |
| `TOKEN_FILE` | Path to a file containing a connection token | - |
| `SERVER_DATA_DIR` | Directory where server data is stored | - |
| `SERVER_BASE_PATH` | Path under which the web UI and code server is provided | - |
| `SOCKET_PATH` | Socket path for the server to use | - |
| `VERBOSE` | Enable verbose output | `false` |
| `LOG_LEVEL` | Log level (trace, debug, info, warn, error, critical, off) | - |
| `CLI_DATA_DIR` | Directory where CLI metadata should be stored | - |

## Setup: Nginx Reverse Proxy Configuration

Expand Down
71 changes: 49 additions & 22 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,54 +1,81 @@
#!/bin/bash
# This script starts Visual Studio Code server accessible from anywhere

echo "my-code-server debian container"

# Check if PORT environment variable is set, default to 8585 if not
if [ -z "$PORT" ]; then
echo "No PORT provided, using default port: 8585"
PORT=8585
echo "No PORT provided, using default port: 8585"
PORT=8585
else
echo "Using provided port: $PORT"
echo "Using provided port: $PORT"
fi

# Check if HOST environment variable is set, default to 0.0.0.0 if not
if [ -z "$HOST" ]; then
echo "No HOST provided, using default host: 0.0.0.0"
HOST=0.0.0.0
echo "No HOST provided, using default host: 0.0.0.0"
HOST=0.0.0.0
else
echo "Using provided host: $HOST"
echo "Using provided host: $HOST"
fi

# Initialize the base command
CMD="code serve-web --host $HOST --port $PORT"

# Check for SERVER_DATA_DIR and add to command if set
if [ -n "$SERVER_DATA_DIR" ]; then
echo "Using server data directory: $SERVER_DATA_DIR"
CMD="$CMD --server-data-dir $SERVER_DATA_DIR"
echo "Using server data directory: $SERVER_DATA_DIR"
CMD="$CMD --server-data-dir $SERVER_DATA_DIR"
fi

# Check for USER_DATA_DIR and add to command if set
if [ -n "$USER_DATA_DIR" ]; then
echo "Using user data directory: $USER_DATA_DIR"
CMD="$CMD --user-data-dir $USER_DATA_DIR"
# Check for SERVER_BASE_PATH and add to command if set
if [ -n "$SERVER_BASE_PATH" ]; then
echo "Using server base path: $SERVER_BASE_PATH"
CMD="$CMD --server-base-path $SERVER_BASE_PATH"
fi

# Check for EXTENSIONS_DIR and add to command if set
if [ -n "$EXTENSIONS_DIR" ]; then
echo "Using extensions directory: $EXTENSIONS_DIR"
CMD="$CMD --extensions-dir $EXTENSIONS_DIR"
# Check if SOCKET_PATH environment variable is set
if [ -n "$SOCKET_PATH" ]; then
echo "Using socket path: $SOCKET_PATH"
CMD="$CMD --socket-path $SOCKET_PATH"
fi

# Check if TOKEN environment variable is set
if [ -z "$TOKEN" ]; then
echo "No TOKEN provided, starting without token"
CMD="$CMD --without-connection-token"
echo "No TOKEN provided, starting without token"
CMD="$CMD --without-connection-token"
else
echo "Starting with token: $TOKEN"
CMD="$CMD --connection-token $TOKEN"
echo "Starting with token: $TOKEN"
CMD="$CMD --connection-token $TOKEN"
fi

# Check if TOKEN_FILE environment variable is set
if [ -n "$TOKEN_FILE" ]; then
echo "Using token file: $TOKEN_FILE"
CMD="$CMD --connection-token-file $TOKEN_FILE"
fi

# Always accept the server license terms
echo "Server license terms accepted"
CMD="$CMD --accept-server-license-terms"

# Add verbosity options if set
if [ -n "$VERBOSE" ] && [ "$VERBOSE" = "true" ]; then
echo "Running in verbose mode"
CMD="$CMD --verbose"
fi

# Add log level if set
if [ -n "$LOG_LEVEL" ]; then
echo "Using log level: $LOG_LEVEL"
CMD="$CMD --log $LOG_LEVEL"
fi

# Add CLI data directory if set
if [ -n "$CLI_DATA_DIR" ]; then
echo "Using CLI data directory: $CLI_DATA_DIR"
CMD="$CMD --cli-data-dir $CLI_DATA_DIR"
fi

# Execute the final command
echo "Executing: $CMD"
exec $CMD
exec $CMD