From b5ca4179cd7c739b357c4d1045272dff57f72aa9 Mon Sep 17 00:00:00 2001 From: Fred Emmott Date: Fri, 5 Nov 2021 13:58:20 -0500 Subject: [PATCH] Rework devcontainer to use proxygen server 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. --- .deploy/built-site.Dockerfile | 1 - .deploy/init.sh | 4 +++- .devcontainer/Dockerfile | 7 ++++++ .../devcontainer.json | 22 +++++++++++-------- src/build/UpdateTagsCLI.hack | 2 +- 5 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 .devcontainer/Dockerfile rename .devcontainer.json => .devcontainer/devcontainer.json (52%) diff --git a/.deploy/built-site.Dockerfile b/.deploy/built-site.Dockerfile index 433385ac6..797bb02fa 100644 --- a/.deploy/built-site.Dockerfile +++ b/.deploy/built-site.Dockerfile @@ -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 diff --git a/.deploy/init.sh b/.deploy/init.sh index 7aed0099c..dd44bef61 100755 --- a/.deploy/init.sh +++ b/.deploy/init.sh @@ -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 diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..ddc0a785b --- /dev/null +++ b/.devcontainer/Dockerfile @@ -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 diff --git a/.devcontainer.json b/.devcontainer/devcontainer.json similarity index 52% rename from .devcontainer.json rename to .devcontainer/devcontainer.json index 83088b123..755087f9b 100644 --- a/.devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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": { @@ -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" } diff --git a/src/build/UpdateTagsCLI.hack b/src/build/UpdateTagsCLI.hack index 95ab9c596..0452869c8 100644 --- a/src/build/UpdateTagsCLI.hack +++ b/src/build/UpdateTagsCLI.hack @@ -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)