Skip to content

Commit

Permalink
Put installation of virtualbox and vagrant on test dockerfile behind …
Browse files Browse the repository at this point in the history
…a flag
  • Loading branch information
alopezz committed Apr 10, 2024
1 parent 7d2bf61 commit 50d03e7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ To get the available versions of the integrations, see the integration-specific

### Dockerized environment

To build a Docker environment, use the files under `docker_test_env`:
To build a Docker environment with which to run kitchen tests, use the files under `docker_test_env`:

```
cd docker_test_env
Expand All @@ -393,11 +393,18 @@ docker build -t chef-datadog-container .
To run the container use:
```
docker run -d -v /dev/vboxdrv:/dev/vboxdrv --privileged=true chef-datadog-container
docker run -d -v /var/run/docker.sock:/var/run/docker.sock chef-datadog-container
```
Then attach a console to the container or use the VS Code remote-container feature to develop inside the container.
To run kitchen-docker tests from within the container:
```
# Note: Also set KITCHEN_DOCKER_HOSTNAME=host.docker.internal if on MacOS or Windows
# Run this under a login shell (otherwise `bundle` won't be found)
KITCHEN_LOCAL_YAML=kitchen.docker.yml bundle exec rake circle
```
[1]: https://github.com/DataDog/chef-datadog/blob/master/attributes/default.rb
[2]: https://github.com/DataDog/chef-datadog/releases/tag/v2.18.0
Expand Down
11 changes: 7 additions & 4 deletions docker_test_env/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# docker run --rm -it -v /dev/vboxdrv:/dev/vboxdrv
ARG BASE_IMAGE=ubuntu:20.04
FROM $BASE_IMAGE
ARG TZ=America/New_York
Expand All @@ -9,7 +8,7 @@ ENV RUBY_VERSION=$RUBY_VERSION
ENV DEBIAN_FRONTEND=noninteractive

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && apt-get install -y wget virtualbox git zlib1g-dev curl
RUN apt-get update && apt-get install -y wget git zlib1g-dev curl gpg

# RVM
RUN gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
Expand All @@ -21,8 +20,12 @@ RUN /bin/bash -l -c "gem install bundler:2.3.26 --no-document"

RUN /bin/bash -l -c "gem install nori:2.6.0 test-kitchen:2.7.2 octokit:4.18.0 semverse:3.0.0 chef:14.10.9 berkshelf:7.0.10 kitchen-vagrant:1.7.0 kitchen-docker:2.3.0"


RUN wget https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.deb && dpkg -i vagrant_2.2.9_x86_64.deb && rm vagrant_2.2.9_x86_64.deb
# build with --build-arg INSTALL_VAGRANT=1 to get vagrant support (not needed for kitchen-docker-tests)
# requires `-v /dev/vboxdrv:/dev/vboxdrv` when running
ARG INSTALL_VAGRANT
RUN if [ -n "${INSTALL_VAGRANT}" ]; then \
apt-get install -y virtualbox && wget https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.deb && dpkg -i vagrant_2.2.9_x86_64.deb && rm vagrant_2.2.9_x86_64.deb \
; fi

# Install docker. Requires `-v /var/run/docker.sock:/var/run/docker.sock` when running to use the host's docker daemon
RUN \
Expand Down

0 comments on commit 50d03e7

Please sign in to comment.