Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework devcontainer to use proxygen server #1107

Merged
merged 4 commits into from
Nov 5, 2021
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
4 changes: 1 addition & 3 deletions .deploy/built-site.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# 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

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
22 changes: 5 additions & 17 deletions .deploy/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +5 to 8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.dockerenv does not exist on buildkit but the cgroup approach should work.

See https://stackoverflow.com/a/69860299/955091


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

Expand Down
39 changes: 39 additions & 0 deletions .deploy/system-init.sh
Original file line number Diff line number Diff line change
@@ -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"
30 changes: 0 additions & 30 deletions .devcontainer.json

This file was deleted.

9 changes: 9 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "docs.hhvm.com",
"runArgs": [
"--init"
],
"build": {
"dockerfile": "Dockerfile",
"args": {
"WORKSPACE": "${containerWorkspaceFolder}"
},
"context": ".."
},
"runArgs": [
"--env", "LC_ALL=C"
],
Atry marked this conversation as resolved.
Show resolved Hide resolved
"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"
}
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