Skip to content

Commit

Permalink
Rework devcontainer to use proxygen server
Browse files Browse the repository at this point in the history
This means that `hhvm` is the actual docker command; the bad news is that if
hhvm crashes, the container goes down.

I'm doing this anyway as there doesn't appear to be support in
devcontainer.json for a separate long-running command - only via docker
compose, which:

- feels like overkill
- appears not to support devcontainer variables like
  containerWorkspaceFolder; this means that it can't work with GitHub
  codespaces, as the `workspaceMount` devcontainer.json option is not
  supported on codespaces

The lack of support for `workspaceMount` is also why there's the fun
messing around with symlinking /var/www and configuration files.
  • Loading branch information
fredemmott committed Nov 5, 2021
1 parent 8dbc0a2 commit b5ca417
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
1 change: 0 additions & 1 deletion .deploy/built-site.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
FROM hhvm/hhvm:4.134-latest
ARG DOCKER_BUILD_ENV=prod
ENV TZ UTC
ENV DEBIAN_FRONTEND noninteractive
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
Expand Down
4 changes: 3 additions & 1 deletion .deploy/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ if [ ! -e /docker_build ]; then
exit 1
fi

export DEBIAN_FRONTEND=noninteractive

echo "** Installing apt dependencies"
# This is done by the dockerfile, but the intermediate issue can be cached, so do
# it again here.
apt-get clean
apt-get update -y

apt-get install -y ruby php-cli zip unzip locales
LC_ALL=C apt-get install -y ruby php-cli zip unzip locales

echo "** Updating locales"
locale-gen en_US.UTF-8
Expand Down
7 changes: 7 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM hhvm/hhvm-proxygen:4.134-latest

ARG WORKSPACE

RUN rm -rf /var/www; ln -s ${WORKSPACE} /var/www
RUN ln -sf /var/www/hhvm.dev.ini /etc/hhvm/site.ini
RUN touch /docker_build
22 changes: 13 additions & 9 deletions .devcontainer.json → .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
"runArgs": [
"--init"
],
"image": "hhvm/hhvm:4.134-latest",
"build": {
"dockerfile": "Dockerfile",
"args": {
"WORKSPACE": "${containerWorkspaceFolder}"
}
},
"runArgs": [
"--env", "LC_ALL=C"
],
"overrideCommand": false,

// Set *default* container specific settings.json values on container create.
"settings": {
Expand All @@ -19,12 +28,7 @@
"terminal.integrated.defaultProfile.linux": "bash"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"pranayagarwal.vscode-hack",
],

"postCreateCommand": "touch /docker_build; .deploy/init.sh",
"postStartCommand": "cd public; hhvm -m server -p 8080 -vServer.AllowRunAsRoot=1 -c ../hhvm.dev.ini",
"forwardPorts": [ 8080 ]
"extensions": [ "pranayagarwal.vscode-hack" ],
"forwardPorts": [ 80 ],
"postCreateCommand": ".deploy/init.sh"
}
2 changes: 1 addition & 1 deletion src/build/UpdateTagsCLI.hack
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ final class UpdateTagsCLI extends CLIBase {

await $stdout->writeAllAsync(" - updating Dockerfiles\n");
$dockerfiles = \glob(LocalConfig::ROOT.'/.deploy/*.Dockerfile');
$dockerfiles[] = LocalConfig::ROOT.'/.devcontainer.json';
$dockerfiles[] = LocalConfig::ROOT.'/.devcontainer/Dockerfile';

foreach ($dockerfiles as $path) {
\file_get_contents($path)
Expand Down

0 comments on commit b5ca417

Please sign in to comment.