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

Conversation

fredemmott
Copy link
Contributor

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/init.sh Outdated
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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

vscode executes stuff a bit differently, including implicitly copying locale around. Installing the locales package will fail if the locale is set to en_US.UTF-8 before we have ran locale-gen en_US.UTF-8... which we can't do earlier as it's provided by the locales package.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind including the comment into the shall script, please?

Copy link
Contributor

@Atry Atry Nov 5, 2021

Choose a reason for hiding this comment

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

Shall we move apt-get install into the Dockerfile, to allow docker caching across Codespaces?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This script is used by a few different dockerfiles at the moment, though it's probalby worth splitting the stuff that doesn't require a copy of the source into a separate script which can then be called from the dockerfile and cache

Copy link
Contributor Author

Choose a reason for hiding this comment

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

... which won't work as that script isn't available until the source is mounted.

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.
@fredemmott
Copy link
Contributor Author

microsoft/vscode-remote-release#4093 and microsoft/vscode-remote-release#3034 are the primary design constraints leading to this solution :(

Copy link
Contributor

@Atry Atry left a comment

Choose a reason for hiding this comment

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

Overall looks good with some minor questions. See comments.

.deploy/init.sh Outdated
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
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind including the comment into the shall script, please?

"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" ],
Copy link
Contributor

Choose a reason for hiding this comment

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

Weird spacing

.devcontainer/devcontainer.json Show resolved Hide resolved

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a standard way to detect if it's in a container? For example: https://stackoverflow.com/questions/20010199/how-to-determine-if-a-process-runs-inside-lxc-docker

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like it could use /.dockerenv nowadays

Copy link
Contributor Author

@fredemmott fredemmott Nov 5, 2021

Choose a reason for hiding this comment

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

Going to make it a dotfile, but stick with touching this. The methods in that stackoverflow post are valid when running, but not when building.

.deploy/init.sh Outdated
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
Copy link
Contributor

@Atry Atry Nov 5, 2021

Choose a reason for hiding this comment

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

Shall we move apt-get install into the Dockerfile, to allow docker caching across Codespaces?

@Atry
Copy link
Contributor

Atry commented Nov 5, 2021

By the way, shall we add a step in the Github Actions to test the devcontainer?

For example: https://github.com/stuartleeks/devcontainer-build-run

@fredemmott
Copy link
Contributor Author

Either fixed or responded, except for:

By the way, shall we add a step in the Github Actions to test the devcontainer?

For example: https://github.com/stuartleeks/devcontainer-build-run

Given that this is re-using our existing testing container scripts where possible, I don't think it adds much, especially as it's a third-party 'pet project' - and it limits experimentation with a better compose-based. Definitely worth adding if GitHub introduce a more complete official one in the future.

@fredemmott fredemmott merged commit cd2c2de into hhvm:main Nov 5, 2021
@fredemmott fredemmott deleted the devcontainer-proxygen branch November 5, 2021 23:27
Comment on lines +5 to 8
if ! [ -e /.docker_build ]; then
echo "This script should only be ran from a Dockerfile"
exit 1
fi
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants