Skip to content

Commit

Permalink
Merge pull request #248 from docksal/feature/code-server-fixes
Browse files Browse the repository at this point in the history
VS Code Server setup overhaul
  • Loading branch information
lmakarov authored Jul 26, 2021
2 parents b567031 + fd06190 commit d05bac0
Show file tree
Hide file tree
Showing 21 changed files with 91 additions and 112 deletions.
21 changes: 9 additions & 12 deletions 7.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -502,27 +502,24 @@ ARG HOME=/home/docker

ENV \
CODE_SERVER_VERSION=3.11.0 \
VSCODE_HOME="${HOME}/code-server" \
VSCODE_EXT_DIRECTORY="${HOME}/code-server/extensions" \
VSCODE_XDEBUG_VERSION=1.16.1 \
VSCODE_GITLENS_VERSION=11.6.0
VSCODE_GITLENS_VERSION=11.6.0 \
VSCODE_HOME="${HOME}/code-server"

# Install code-server
RUN \
set -xe; \
RUN set -xe; \
curl -fsSL "https://github.com/cdr/code-server/releases/download/v${CODE_SERVER_VERSION}/code-server_${CODE_SERVER_VERSION}_${TARGETARCH}.deb" -o /tmp/code-server_${TARGETARCH}.deb; \
sudo dpkg -i /tmp/code-server_${TARGETARCH}.deb; \
rm -rf /tmp/*.*

# Settings and scripts
COPY --chown=docker:docker opt/code-server /opt/code-server
# Settings
COPY --chown=docker:docker config/code-server ${VSCODE_HOME}

# Install extensions
RUN \
set -xe; \
mkdir -p ${VSCODE_EXT_DIRECTORY}; \
/opt/code-server/install-vscode-extension https://github.com/felixfbecker/vscode-php-debug/releases/download/v${VSCODE_XDEBUG_VERSION}/php-debug.vsix felixfbecker.php-debug-${VSCODE_XDEBUG_VERSION}; \
/opt/code-server/install-vscode-extension https://github.com/eamodio/vscode-gitlens/releases/download/v${VSCODE_GITLENS_VERSION}/gitlens-${VSCODE_GITLENS_VERSION}.vsix eamodio.gitlens-${VSCODE_GITLENS_VERSION}
# Note: Have to use --user-data-dir with --install-extension instead of --config
RUN set -xe; \
code-server --user-data-dir=${VSCODE_HOME} --install-extension eamodio.gitlens@11.6.0; \
code-server --user-data-dir=${VSCODE_HOME} --install-extension felixfbecker.php-debug@1.16.1

# Switch back to root (IMPORTANT!)
USER root
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
"*.tpl.php": "php",
"*.test": "php",
"*.php": "php"
}
},
"workbench.colorTheme": "Default Dark+"
}
9 changes: 9 additions & 0 deletions 7.3/config/code-server/config.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
user-data-dir: {{ getenv "VSCODE_HOME" }}
bind-addr: 0.0.0.0:8080
cert: false
{{ if (getenv "IDE_PASSWORD") }}
auth: password
password: {{ getenv "IDE_PASSWORD" }}
{{ else }}
auth: none
{{ end }}
2 changes: 1 addition & 1 deletion 7.3/config/supervisor/supervisord-code-server.conf.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# VS Code Server web IDE
[program:code-server]
# Using bash -lc here to load docker user profile (necessary for nvn/node to initialize)
command = gosu docker bash -lc '/usr/bin/code-server --user-data-dir=/home/docker/code-server --disable-telemetry --bind-addr 0.0.0.0:8080 {{ if not (getenv "PASSWORD") }}--auth none{{ end }} /var/www'
command = gosu docker bash -lc '/usr/bin/code-server --config=${VSCODE_HOME}/config.yaml /var/www'
stdout_logfile = /var/log/supervisor/code-server-stdout
stderr_logfile = /var/log/supervisor/code-server-stderr
11 changes: 4 additions & 7 deletions 7.3/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
#!/usr/bin/env bash

set -e # Exit on errors

# Initialization phase in startup.sh is complete
# Need to do "|| exit 1" here since "set -e" apparently does not care about tests.
[[ -f /var/run/cli ]] || exit 1

# supervisor services are running
if [[ -f /run/supervisord.pid ]]; then
if [[ "${IDE_ENABLED}" != "1" ]]; then
if [[ "${IDE_ENABLED}" == "1" ]]; then
# IDE mode
ps aux | grep code-server >/dev/null || exit 1
else
# php-fpm/cli mode
[[ -f /run/php-fpm.pid ]] || exit 1
[[ -f /run/sshd.pid ]] || exit 1
else
# IDE mode
ps aux | grep code-server >/dev/null
fi
fi
9 changes: 0 additions & 9 deletions 7.3/opt/code-server/install-vscode-extension

This file was deleted.

14 changes: 8 additions & 6 deletions 7.3/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,20 @@ xhprof_enable ()
chown docker:docker ${XHPROF_OUTPUT_DIR}
}

opcache_preload_enable()
{
echo-debug "Enabling opcache preload..."
ln -s /opt/docker-php-ext-opcache.ini /usr/local/etc/php/conf.d/
}

ide_mode_enable ()
{
echo-debug "Enabling web IDE..."
# Enabled only code-server service (disabled all other services)
# TODO: [v3] split IDE/cli and php-fpm entirely
# TODO: split IDE/cli and php-fpm entirely
rm -f /etc/supervisor/conf.d/supervisord-*.conf
if [[ "$IDE_PASSWORD" != "" ]]; then
export PASSWORD="${IDE_PASSWORD}"
fi
render_tmpl "/etc/supervisor/conf.d/supervisord-code-server.conf"
mkdir -p ${VSCODE_HOME}/User
ln -s /opt/code-server/settings.json ${VSCODE_HOME}/User/
render_tmpl "${VSCODE_HOME}/config.yaml"
}

# Creates symlinks to project level overrides if they exist
Expand Down
21 changes: 9 additions & 12 deletions 7.4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -503,27 +503,24 @@ ARG HOME=/home/docker

ENV \
CODE_SERVER_VERSION=3.11.0 \
VSCODE_HOME="${HOME}/code-server" \
VSCODE_EXT_DIRECTORY="${HOME}/code-server/extensions" \
VSCODE_XDEBUG_VERSION=1.16.1 \
VSCODE_GITLENS_VERSION=11.6.0
VSCODE_GITLENS_VERSION=11.6.0 \
VSCODE_HOME="${HOME}/code-server"

# Install code-server
RUN \
set -xe; \
RUN set -xe; \
curl -fsSL "https://github.com/cdr/code-server/releases/download/v${CODE_SERVER_VERSION}/code-server_${CODE_SERVER_VERSION}_${TARGETARCH}.deb" -o /tmp/code-server_${TARGETARCH}.deb; \
sudo dpkg -i /tmp/code-server_${TARGETARCH}.deb; \
rm -rf /tmp/*.*

# Settings and scripts
COPY --chown=docker:docker opt/code-server /opt/code-server
# Settings
COPY --chown=docker:docker config/code-server ${VSCODE_HOME}

# Install extensions
RUN \
set -xe; \
mkdir -p ${VSCODE_EXT_DIRECTORY}; \
/opt/code-server/install-vscode-extension https://github.com/felixfbecker/vscode-php-debug/releases/download/v${VSCODE_XDEBUG_VERSION}/php-debug.vsix felixfbecker.php-debug-${VSCODE_XDEBUG_VERSION}; \
/opt/code-server/install-vscode-extension https://github.com/eamodio/vscode-gitlens/releases/download/v${VSCODE_GITLENS_VERSION}/gitlens-${VSCODE_GITLENS_VERSION}.vsix eamodio.gitlens-${VSCODE_GITLENS_VERSION}
# Note: Have to use --user-data-dir with --install-extension instead of --config
RUN set -xe; \
code-server --user-data-dir=${VSCODE_HOME} --install-extension eamodio.gitlens@11.6.0; \
code-server --user-data-dir=${VSCODE_HOME} --install-extension felixfbecker.php-debug@1.16.1

# Switch back to root (IMPORTANT!)
USER root
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
"*.tpl.php": "php",
"*.test": "php",
"*.php": "php"
}
},
"workbench.colorTheme": "Default Dark+"
}
9 changes: 9 additions & 0 deletions 7.4/config/code-server/config.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
user-data-dir: {{ getenv "VSCODE_HOME" }}
bind-addr: 0.0.0.0:8080
cert: false
{{ if (getenv "IDE_PASSWORD") }}
auth: password
password: {{ getenv "IDE_PASSWORD" }}
{{ else }}
auth: none
{{ end }}
2 changes: 1 addition & 1 deletion 7.4/config/supervisor/supervisord-code-server.conf.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# VS Code Server web IDE
[program:code-server]
# Using bash -lc here to load docker user profile (necessary for nvn/node to initialize)
command = gosu docker bash -lc '/usr/bin/code-server --user-data-dir=/home/docker/code-server --disable-telemetry --bind-addr 0.0.0.0:8080 {{ if not (getenv "PASSWORD") }}--auth none{{ end }} /var/www'
command = gosu docker bash -lc '/usr/bin/code-server --config=${VSCODE_HOME}/config.yaml /var/www'
stdout_logfile = /var/log/supervisor/code-server-stdout
stderr_logfile = /var/log/supervisor/code-server-stderr
11 changes: 4 additions & 7 deletions 7.4/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
#!/usr/bin/env bash

set -e # Exit on errors

# Initialization phase in startup.sh is complete
# Need to do "|| exit 1" here since "set -e" apparently does not care about tests.
[[ -f /var/run/cli ]] || exit 1

# supervisor services are running
if [[ -f /run/supervisord.pid ]]; then
if [[ "${IDE_ENABLED}" != "1" ]]; then
if [[ "${IDE_ENABLED}" == "1" ]]; then
# IDE mode
ps aux | grep code-server >/dev/null || exit 1
else
# php-fpm/cli mode
[[ -f /run/php-fpm.pid ]] || exit 1
[[ -f /run/sshd.pid ]] || exit 1
else
# IDE mode
ps aux | grep code-server >/dev/null
fi
fi
9 changes: 0 additions & 9 deletions 7.4/opt/code-server/install-vscode-extension

This file was deleted.

12 changes: 4 additions & 8 deletions 7.4/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,18 @@ xhprof_enable ()

opcache_preload_enable()
{
echo-debug "Enabling opcache preload..."
ln -s /opt/docker-php-ext-opcache.ini /usr/local/etc/php/conf.d/
echo-debug "Enabling opcache preload..."
ln -s /opt/docker-php-ext-opcache.ini /usr/local/etc/php/conf.d/
}

ide_mode_enable ()
{
echo-debug "Enabling web IDE..."
# Enabled only code-server service (disabled all other services)
# TODO: [v3] split IDE/cli and php-fpm entirely
# TODO: split IDE/cli and php-fpm entirely
rm -f /etc/supervisor/conf.d/supervisord-*.conf
if [[ "$IDE_PASSWORD" != "" ]]; then
export PASSWORD="${IDE_PASSWORD}"
fi
render_tmpl "/etc/supervisor/conf.d/supervisord-code-server.conf"
mkdir -p ${VSCODE_HOME}/User
ln -s /opt/code-server/settings.json ${VSCODE_HOME}/User/
render_tmpl "${VSCODE_HOME}/config.yaml"
}

# Creates symlinks to project level overrides if they exist
Expand Down
21 changes: 9 additions & 12 deletions 8.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -501,27 +501,24 @@ ARG HOME=/home/docker

ENV \
CODE_SERVER_VERSION=3.11.0 \
VSCODE_HOME="${HOME}/code-server" \
VSCODE_EXT_DIRECTORY="${HOME}/code-server/extensions" \
VSCODE_XDEBUG_VERSION=1.16.1 \
VSCODE_GITLENS_VERSION=11.6.0
VSCODE_GITLENS_VERSION=11.6.0 \
VSCODE_HOME="${HOME}/code-server"

# Install code-server
RUN \
set -xe; \
RUN set -xe; \
curl -fsSL "https://github.com/cdr/code-server/releases/download/v${CODE_SERVER_VERSION}/code-server_${CODE_SERVER_VERSION}_${TARGETARCH}.deb" -o /tmp/code-server_${TARGETARCH}.deb; \
sudo dpkg -i /tmp/code-server_${TARGETARCH}.deb; \
rm -rf /tmp/*.*

# Settings and scripts
COPY --chown=docker:docker opt/code-server /opt/code-server
# Settings
COPY --chown=docker:docker config/code-server ${VSCODE_HOME}

# Install extensions
RUN \
set -xe; \
mkdir -p ${VSCODE_EXT_DIRECTORY}; \
/opt/code-server/install-vscode-extension https://github.com/felixfbecker/vscode-php-debug/releases/download/v${VSCODE_XDEBUG_VERSION}/php-debug.vsix felixfbecker.php-debug-${VSCODE_XDEBUG_VERSION}; \
/opt/code-server/install-vscode-extension https://github.com/eamodio/vscode-gitlens/releases/download/v${VSCODE_GITLENS_VERSION}/gitlens-${VSCODE_GITLENS_VERSION}.vsix eamodio.gitlens-${VSCODE_GITLENS_VERSION}
# Note: Have to use --user-data-dir with --install-extension instead of --config
RUN set -xe; \
code-server --user-data-dir=${VSCODE_HOME} --install-extension eamodio.gitlens@11.6.0; \
code-server --user-data-dir=${VSCODE_HOME} --install-extension felixfbecker.php-debug@1.16.1

# Switch back to root (IMPORTANT!)
USER root
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
"*.tpl.php": "php",
"*.test": "php",
"*.php": "php"
}
},
"workbench.colorTheme": "Default Dark+"
}
9 changes: 9 additions & 0 deletions 8.0/config/code-server/config.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
user-data-dir: {{ getenv "VSCODE_HOME" }}
bind-addr: 0.0.0.0:8080
cert: false
{{ if (getenv "IDE_PASSWORD") }}
auth: password
password: {{ getenv "IDE_PASSWORD" }}
{{ else }}
auth: none
{{ end }}
2 changes: 1 addition & 1 deletion 8.0/config/supervisor/supervisord-code-server.conf.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# VS Code Server web IDE
[program:code-server]
# Using bash -lc here to load docker user profile (necessary for nvn/node to initialize)
command = gosu docker bash -lc '/usr/bin/code-server --user-data-dir=/home/docker/code-server --disable-telemetry --bind-addr 0.0.0.0:8080 {{ if not (getenv "PASSWORD") }}--auth none{{ end }} /var/www'
command = gosu docker bash -lc '/usr/bin/code-server --config=${VSCODE_HOME}/config.yaml /var/www'
stdout_logfile = /var/log/supervisor/code-server-stdout
stderr_logfile = /var/log/supervisor/code-server-stderr
11 changes: 4 additions & 7 deletions 8.0/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
#!/usr/bin/env bash

set -e # Exit on errors

# Initialization phase in startup.sh is complete
# Need to do "|| exit 1" here since "set -e" apparently does not care about tests.
[[ -f /var/run/cli ]] || exit 1

# supervisor services are running
if [[ -f /run/supervisord.pid ]]; then
if [[ "${IDE_ENABLED}" != "1" ]]; then
if [[ "${IDE_ENABLED}" == "1" ]]; then
# IDE mode
ps aux | grep code-server >/dev/null || exit 1
else
# php-fpm/cli mode
[[ -f /run/php-fpm.pid ]] || exit 1
[[ -f /run/sshd.pid ]] || exit 1
else
# IDE mode
ps aux | grep code-server >/dev/null
fi
fi
9 changes: 0 additions & 9 deletions 8.0/opt/code-server/install-vscode-extension

This file was deleted.

12 changes: 4 additions & 8 deletions 8.0/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,18 @@ xhprof_enable ()

opcache_preload_enable()
{
echo-debug "Enabling opcache preload..."
ln -s /opt/docker-php-ext-opcache.ini /usr/local/etc/php/conf.d/
echo-debug "Enabling opcache preload..."
ln -s /opt/docker-php-ext-opcache.ini /usr/local/etc/php/conf.d/
}

ide_mode_enable ()
{
echo-debug "Enabling web IDE..."
# Enabled only code-server service (disabled all other services)
# TODO: [v3] split IDE/cli and php-fpm entirely
# TODO: split IDE/cli and php-fpm entirely
rm -f /etc/supervisor/conf.d/supervisord-*.conf
if [[ "$IDE_PASSWORD" != "" ]]; then
export PASSWORD="${IDE_PASSWORD}"
fi
render_tmpl "/etc/supervisor/conf.d/supervisord-code-server.conf"
mkdir -p ${VSCODE_HOME}/User
ln -s /opt/code-server/settings.json ${VSCODE_HOME}/User/
render_tmpl "${VSCODE_HOME}/config.yaml"
}

# Creates symlinks to project level overrides if they exist
Expand Down

0 comments on commit d05bac0

Please sign in to comment.