marmelab / greenframe-cli

Estimate the carbon footprint of a user scenario on a web application
https://greenframe.io
Other
229 stars 11 forks source link

Build a docker image with greenframe-cli #19

Open vpeltot opened 1 year ago

vpeltot commented 1 year ago

Closes #18

fzaninotto commented 1 year ago

Awesome! Your PR is in Draft, what's left to finish it?

vpeltot commented 1 year ago

I just pushed a new commit with

vpeltot commented 1 year ago

@fzaninotto Can you set the environment variables DOCKER_REGISTRY_USER and DOCKER_REGISTRY_PASS values with your docker hub credentials?

floo51 commented 1 year ago

Hello Vincent,

I've checked out locally and tried to run a greenframe analyze using the provided Dockerfile:

# from project root
docker build -t greenframe-docker-in-docker-test .
docker run -v $(pwd)/:/app greenframe-docker-in-docker-test analyze -C ./.greenframe.e2e.yml

I'm getting an error about being unable to connect to the Docker daemon:

❌ main scenario failed
This scenario fail during the execution:
Command failed: docker create --tty --name greenframe-runner --rm -e HOSTIP=172.17.0.3 --add-host localhost:172.17.0.3  mcr.microsoft.com/playwright:v1.28.1-focal
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

I thought this was dind based but now realize it might be dood (Docker outside of Docker), do we have to map the docker sock from host to container for it to work?

If yes, we need to document it, and we could use an alpine based image so that the final image is lighter, I worked on a dood alpine image so it might come handy.

npotier commented 1 year ago

Hello. First of all I would like to thank you for this project.

Juste my 2 cents here. We have created a small and simple Docker image in order to run greenframe-cli : https://github.com/acseo/docker-greenframe-cli

You cans use it to test a remote or a local website :

$ docker run -it -v /var/run/docker.sock:/var/run/docker.sock acseo/greenframe-cli \ 
    greenframe analyze https://www.acseo.fr
$ docker run -it \
    -e "DEBUG=*" \
    --network="host" \
    -v $(pwd)/greeframe.yml:/app/greenframe.yml \
    -v $(pwd)/scenario.js:/app/scenario.js \
    -v /var/run/docker.sock:/var/run/docker.sock \
    acseo/greenframe-cli greenframe analyze -C /app/greenframe.yml http://my-app.local /app/greenframe.js

Maybe it will be useful for someone 😃