-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 408a6b3
Showing
12 changed files
with
373 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
max_line_length = 80 | ||
|
||
[*.md] | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = false | ||
|
||
[Dockerfile] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[Makefile] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[{*.bats,*.sh,post_push,post_push.tmpl.php}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.{json,yml,yaml}] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/.idea/ | ||
*.iml | ||
.DS_Store | ||
|
||
/node_modules/ | ||
/yarn.lock | ||
/yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
language: bash | ||
|
||
sudo: false | ||
|
||
services: | ||
- docker | ||
|
||
before_script: | ||
- make image VERSION=test | ||
- make deps.bats | ||
|
||
script: | ||
- make test VERSION=test | ||
|
||
notifications: | ||
email: | ||
on_success: never | ||
on_failure: always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM debian:stretch-slim | ||
|
||
ARG firefox_ver=69.0 | ||
ARG geckodriver_ver=v0.25.0 | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y \ | ||
wget tar bzip2 \ | ||
# Install dependencies for firefox binary | ||
`apt-cache depends firefox-esr | awk '/Depends:/{print$2}'` \ | ||
# Install firefox | ||
&& wget -O FirefoxSetup.tar.bz2 "https://ftp.mozilla.org/pub/firefox/releases/${firefox_ver}/linux-x86_64/en-GB/firefox-${firefox_ver}.tar.bz2" \ | ||
&& tar xjf FirefoxSetup.tar.bz2 \ | ||
&& mv firefox /opt/firefox \ | ||
# Install geckodriver | ||
&& wget https://github.com/mozilla/geckodriver/releases/download/v${geckodriver_ver}/geckodriver-v${geckodriver_ver}-linux64.tar.gz \ | ||
&& tar -xvzf geckodriver* \ | ||
&& chmod +x geckodriver \ | ||
&& mv geckodriver /usr/bin | ||
|
||
ENTRYPOINT ["geckodriver", "-b", "/opt/firefox/firefox", "--log", "debug", "--host", "0.0.0.0"] | ||
|
||
EXPOSE 4444 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2018 Instrumentisto Team, <https://github.com/instrumentisto> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# This Makefile automates possible operations of this project. | ||
# | ||
# Images and description on Docker Hub will be automatically rebuilt on | ||
# pushes to `master` branch of this repo and on updates of parent image. | ||
# | ||
# Note! Docker Hub `post_push` hook must be always up-to-date with default | ||
# values of current Makefile. To update it just use: | ||
# make post-push-hook | ||
# | ||
# It's still possible to build, tag and push images manually. Just use: | ||
# make release | ||
|
||
|
||
IMAGE_NAME := instrumentisto/geckodriver | ||
VERSION ?= 69.0 | ||
FIREFOX_VERSION ?= 69.0 | ||
GECKODRIVER_VERSION ?= 0.25.0 | ||
TAGS ?= 69.0,latest | ||
|
||
|
||
comma := , | ||
eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\ | ||
$(findstring $(2),$(1))),1) | ||
|
||
|
||
|
||
# Build Docker image. | ||
# | ||
# Usage: | ||
# make image [VERSION=<image-version>] [no-cache=(no|yes)] | ||
|
||
image: | ||
docker build --network=host --force-rm \ | ||
--build-arg firefox_ver=$(FIREFOX_VERSION) \ | ||
--build-arg geckodriver_ver=$(GECKODRIVER_VERSION) \ | ||
$(if $(call eq,$(no-cache),yes),--no-cache --pull,) \ | ||
-t $(IMAGE_NAME):$(VERSION) . | ||
|
||
|
||
|
||
# Tag Docker image with given tags. | ||
# | ||
# Usage: | ||
# make tags [VERSION=<image-version>] | ||
# [TAGS=<docker-tag-1>[,<docker-tag-2>...]] | ||
|
||
tags: | ||
$(foreach tag, $(subst $(comma), ,$(TAGS)),\ | ||
$(call docker.tag.do,$(VERSION),$(tag))) | ||
define tags.do | ||
$(eval from := $(strip $(1))) | ||
$(eval to := $(strip $(2))) | ||
docker tag $(IMAGE_NAME):$(from) $(IMAGE_NAME):$(to) | ||
endef | ||
|
||
|
||
|
||
# Manually push Docker images to Docker Hub. | ||
# | ||
# Usage: | ||
# make push [TAGS=<docker-tag-1>[,<docker-tag-2>...]] | ||
|
||
push: | ||
$(foreach tag, $(subst $(comma), ,$(TAGS)),\ | ||
$(call docker.push.do, $(tag))) | ||
define push.do | ||
$(eval tag := $(strip $(1))) | ||
docker push $(IMAGE_NAME):$(tag) | ||
endef | ||
|
||
|
||
|
||
# Make manual release of Docker images to Docker Hub. | ||
# | ||
# Usage: | ||
# make release [VERSION=<image-version>] [no-cache=(no|yes)] | ||
# [TAGS=<docker-tag-1>[,<docker-tag-2>...]] | ||
|
||
release: | image tags push | ||
|
||
|
||
|
||
# Create `post_push` Docker Hub hook. | ||
# | ||
# When Docker Hub triggers automated build all the tags defined in `post_push` | ||
# hook will be assigned to built image. It allows to link the same image with | ||
# different tags, and not to build identical image for each tag separately. | ||
# See details: | ||
# http://windsock.io/automated-docker-image-builds-with-multiple-tags | ||
# | ||
# Usage: | ||
# make post-push-hook [TAGS=<docker-tag-1>[,<docker-tag-2>...]] | ||
|
||
post-push-hook: | ||
@mkdir -p hooks/ | ||
docker run --rm -i -v "$(PWD)/post_push.tmpl.php":/post_push.php:ro \ | ||
php:alpine php -f /post_push.php -- \ | ||
--image_tags='$(TAGS)' \ | ||
> hooks/post_push | ||
|
||
|
||
|
||
# Run Bats tests for Docker image. | ||
# | ||
# Documentation of Bats: | ||
# https://github.com/bats-core/bats-core | ||
# | ||
# Usage: | ||
# make test [VERSION=<image-version>] | ||
|
||
test: | ||
ifeq ($(wildcard node_modules/.bin/bats),) | ||
@make deps.bats | ||
endif | ||
IMAGE=$(IMAGE_NAME):$(VERSION) node_modules/.bin/bats test/suite.bats | ||
|
||
|
||
|
||
# Resolve project dependencies for running tests with Yarn. | ||
# | ||
# Usage: | ||
# make deps.bats | ||
|
||
deps.bats: | ||
docker run --rm -v "$(PWD)":/app -w /app \ | ||
node:alpine \ | ||
yarn install --non-interactive --no-progress | ||
|
||
|
||
|
||
.PHONY: image tags push release post-push-hook test deps.bats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
Geckodriver Docker image | ||
=============================== | ||
|
||
[![GitHub release](https://img.shields.io/github/release/instrumentisto/geckodriver-docker-image.svg)](https://hub.docker.com/r/instrumentisto/geckodriver/tags) [![Build Status](https://travis-ci.org/instrumentisto/geckodriver-docker-image.svg?branch=master)](https://travis-ci.org/instrumentisto/geckodriver-docker-image) [![Docker Pulls](https://img.shields.io/docker/pulls/instrumentisto/coturn.svg)](https://hub.docker.com/r/instrumentisto/coturn) | ||
|
||
|
||
|
||
|
||
## What is Geckodriver Docker image? | ||
|
||
This image bundles Geckodriver with Firefox and is suitable for running headless tests. | ||
|
||
|
||
## How to use this image | ||
|
||
```bash | ||
docker run -d -p 4444:4444 instrumentisto/geckodriver | ||
``` | ||
|
||
After that you can connect to Geckodriver that will be running on `127.0.0.1:4444`. Only headless mode is supported. | ||
|
||
Consider running image with `--network=host` if you want to run tests on local server. | ||
|
||
Consider running image with increased shared memory size (`--shm-size 2g`), otherwise you may experience unexpected Firefox crashes. | ||
|
||
|
||
## Image versions | ||
|
||
Image version corresponds to Firefox version used. | ||
|
||
|
||
|
||
|
||
## License | ||
|
||
Firefox and Geckodriver are licensed under [Mozilla Public License][91]. | ||
|
||
Geckodriver Docker image is licensed under [MIT license][92]. | ||
|
||
|
||
|
||
|
||
## Issues | ||
|
||
We can't notice comments in the DockerHub so don't use them for reporting issue or asking question. | ||
|
||
If you have any problems with or questions about this image, please contact us through a [GitHub issue][1]. | ||
|
||
|
||
|
||
|
||
[1]: https://github.com/instrumentisto/geckodriver-docker-image/issues | ||
[91]: https://www.mozilla.org/en-US/MPL/2.0/ | ||
[92]: https://github.com/instrumentisto/geckodriver-docker-image/blob/master/LICENSE.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
# AUTOMATICALLY GENERATED | ||
# DO NOT EDIT THIS FILE DIRECTLY, USE /post_push.tmpl.php | ||
|
||
set -e | ||
|
||
# Parse image name for repo name | ||
tagStart=$(expr index "$IMAGE_NAME" :) | ||
repoName=${IMAGE_NAME:0:tagStart-1} | ||
|
||
# Tag and push image for each additional tag | ||
for tag in {69.0,latest}; do | ||
docker tag $IMAGE_NAME ${repoName}:${tag} | ||
docker push ${repoName}:${tag} | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"devDependencies": { | ||
"bats": "^1.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<? $var = getopt('', ['image_tags:']); ?> | ||
#!/bin/bash | ||
# AUTOMATICALLY GENERATED | ||
# DO NOT EDIT THIS FILE DIRECTLY, USE /post_push.tmpl.php | ||
|
||
set -e | ||
|
||
# Parse image name for repo name | ||
tagStart=$(expr index "$IMAGE_NAME" :) | ||
repoName=${IMAGE_NAME:0:tagStart-1} | ||
|
||
# Tag and push image for each additional tag | ||
for tag in {<?= $var['image_tags']; ?>}; do | ||
docker tag $IMAGE_NAME ${repoName}:${tag} | ||
docker push ${repoName}:${tag} | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env bats | ||
|
||
|
||
@test "post_push hook is up-to-date" { | ||
run sh -c "cat Makefile | grep 'TAGS ?= ' | cut -d ' ' -f 3" | ||
[ "$status" -eq 0 ] | ||
[ ! "$output" = '' ] | ||
expected="$output" | ||
|
||
run sh -c "cat hooks/post_push | grep 'for tag in' \ | ||
| cut -d '{' -f 2 \ | ||
| cut -d '}' -f 1" | ||
[ "$status" -eq 0 ] | ||
[ ! "$output" = '' ] | ||
actual="$output" | ||
|
||
[ "$actual" = "$expected" ] | ||
} | ||
|
||
@test "Firefox has correct version" { | ||
run sh -c "cat Makefile | grep 'FIREFOX_VERSION ?= ' | cut -d ' ' -f 3" | ||
[ "$status" -eq 0 ] | ||
[ ! "$output" = '' ] | ||
expected="$output" | ||
|
||
run docker run --rm --entrypoint sh $IMAGE -c \ | ||
"/opt/firefox/firefox -v | cut -d ' ' -f3" | ||
[ "$status" -eq 0 ] | ||
[ ! "$output" = '' ] | ||
actual="$output" | ||
|
||
[ "$actual" = "$expected" ] | ||
} | ||
|
||
@test "Geckodriver has correct version" { | ||
run sh -c "cat Makefile | grep 'GECKODRIVER_VERSION ?= ' | cut -d ' ' -f 3" | ||
[ "$status" -eq 0 ] | ||
[ ! "$output" = '' ] | ||
expected="$output" | ||
|
||
echo "$expected" | ||
|
||
run docker run --rm --entrypoint sh $IMAGE -c \ | ||
"geckodriver -V | grep -m 1 geckodriver | cut -d ' ' -f2" | ||
[ "$status" -eq 0 ] | ||
[ ! "$output" = '' ] | ||
actual="$output" | ||
|
||
echo "$actual" | ||
|
||
[ "$actual" = "$expected" ] | ||
} |