diff --git a/.deploy/built-site.Dockerfile b/.deploy/built-site.Dockerfile index 433385ac6..967f57936 100644 --- a/.deploy/built-site.Dockerfile +++ b/.deploy/built-site.Dockerfile @@ -1,9 +1,7 @@ # Creates a docker image with a built copy of the site. Not repo-auth. # Useful as a scratch/testing area. 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 @@ -11,4 +9,4 @@ ENV LC_ALL en_US.UTF-8 RUN rm -rf /var/www ADD . /var/www -RUN touch /docker_build && cd /var/www && .deploy/init.sh +RUN cd /var/www && touch /.docker_build && .deploy/init.sh diff --git a/.deploy/init.sh b/.deploy/init.sh index 7aed0099c..144474324 100755 --- a/.deploy/init.sh +++ b/.deploy/init.sh @@ -2,30 +2,18 @@ set -ex -if [ ! -e /docker_build ]; then +if ! [ -e /.docker_build ]; then echo "This script should only be ran from a Dockerfile" exit 1 fi -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 - -echo "** Updating locales" -locale-gen en_US.UTF-8 - -echo "** Installing composer" -mkdir /opt/composer -wget -qO /dev/stdout https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer -if [ ! -x /usr/local/bin/composer ]; then - echo "Failed to install composer" +if ! [ -x .deploy/system-init.sh ]; then + echo "Run from the root directory of the source tree." exit 1 fi +.deploy/system-init.sh + echo "** Installing Hack dependencies" composer install diff --git a/.deploy/system-init.sh b/.deploy/system-init.sh new file mode 100755 index 000000000..793f0f15c --- /dev/null +++ b/.deploy/system-init.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +set -ex + +if ! [ -e /.docker_build ]; then + echo "This script should only be ran from a Dockerfile" + exit 1 +fi + +STAMP_FILE=/.hack_docs_system_init.stamp +if [ -e "$STAMP_FILE" ]; then + exit +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 + +# Some environments (e.g. VSCode containers) will copy the exterior locale +# settings, which can break things if the current locale isn't usable in the +# container; using the `C` locale makes sure that the `locales` package +# post-install succeeds. +LC_ALL=C apt-get install -y ruby php-cli zip unzip locales + +echo "** Updating locales" +locale-gen en_US.UTF-8 + +echo "** Installing composer" +wget -qO /dev/stdout https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +if [ ! -x /usr/local/bin/composer ]; then + echo "Failed to install composer" + exit 1 +fi + +touch "$STAMP_FILE" diff --git a/.devcontainer.json b/.devcontainer.json deleted file mode 100644 index 83088b123..000000000 --- a/.devcontainer.json +++ /dev/null @@ -1,30 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. -{ - "name": "docs.hhvm.com", - "runArgs": [ - "--init" - ], - "image": "hhvm/hhvm:4.134-latest", - - // Set *default* container specific settings.json values on container create. - "settings": { - "terminal.integrated.profiles.linux": { - "bash": { - "path": "/bin/bash", - "args": [ - "--login" - ] - } - }, - "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 ] -} diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..f690fd1a3 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,9 @@ +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 + +ADD .deploy/system-init.sh /var/tmp/system-init.sh +RUN touch /.docker_build && /var/tmp/system-init.sh && rm /var/tmp/system-init.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..12ac394ce --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,34 @@ +{ + "name": "docs.hhvm.com", + "runArgs": [ + "--init" + ], + "build": { + "dockerfile": "Dockerfile", + "args": { + "WORKSPACE": "${containerWorkspaceFolder}" + }, + "context": ".." + }, + "runArgs": [ + "--env", "LC_ALL=C" + ], + "overrideCommand": false, + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.profiles.linux": { + "bash": { + "path": "/bin/bash", + "args": [ + "--login" + ] + } + }, + "terminal.integrated.defaultProfile.linux": "bash" + }, + + "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)