Skip to content

Commit

Permalink
Prepare release to Docker Hub
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranron committed Oct 9, 2019
1 parent 3b8836a commit 546e388
Show file tree
Hide file tree
Showing 9 changed files with 191 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/.idea/
*.iml
/*.iml
.DS_Store

/node_modules/
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ services:
- docker

before_script:
- make image VERSION=test
- make image tag=test
- make deps.bats

script:
- make test VERSION=test
- make test tag=test

notifications:
email:
Expand Down
68 changes: 44 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,51 @@
FROM debian:stretch-slim
# https://hub.docker.com/_/debian
FROM debian:buster-slim

ARG firefox_ver=69.0
ARG geckodriver_ver=v0.25.0
ARG geckodriver_ver=0.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 \
# Provide MPLv2.0 license
&& mkdir -p /usr/share/doc/mpl \
&& wget -O /usr/share/doc/mpl/MPLv2.0.html https://www.mozilla.org/en-US/MPL/2.0/ \
# Cleanup unnecessary stuff
&& apt-get purge -y --auto-remove \
-o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*

ENTRYPOINT ["geckodriver", "-b", "/opt/firefox/firefox", "--log", "debug", "--host", "0.0.0.0"]
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends --no-install-suggests \
ca-certificates \
&& update-ca-certificates \
\
# Install tools for building
&& toolDeps=" \
curl bzip2 \
" \
&& apt-get install -y --no-install-recommends --no-install-suggests \
$toolDeps \
\
# Install dependencies for Firefox
&& apt-get install -y --no-install-recommends --no-install-suggests \
`apt-cache depends firefox-esr | awk '/Depends:/{print$2}'` \
\
# Download and install Firefox
&& curl -fL -o /tmp/firefox.tar.bz2 \
https://ftp.mozilla.org/pub/firefox/releases/${firefox_ver}/linux-x86_64/en-GB/firefox-${firefox_ver}.tar.bz2 \
&& tar -xjf /tmp/firefox.tar.bz2 -C /tmp/ \
&& mv /tmp/firefox /opt/firefox \
\
# Download and install geckodriver
&& curl -fL -o /tmp/geckodriver.tar.gz \
https://github.com/mozilla/geckodriver/releases/download/v${geckodriver_ver}/geckodriver-v${geckodriver_ver}-linux64.tar.gz \
&& tar -xzf /tmp/geckodriver.tar.gz -C /tmp/ \
&& chmod +x /tmp/geckodriver \
&& mv /tmp/geckodriver /usr/local/bin/ \
\
# Cleanup unnecessary stuff
&& apt-get purge -y --auto-remove \
-o APT::AutoRemove::RecommendsImportant=false \
$toolDeps \
&& rm -rf /var/lib/apt/lists/* \
/tmp/*

EXPOSE 4444

ENTRYPOINT ["geckodriver"]

CMD ["--binary=/opt/firefox/firefox", "--log=debug", "--host=0.0.0.0"]



36 changes: 20 additions & 16 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
The MIT License (MIT)
=====================

Copyright (c) 2018 Instrumentisto Team, <https://github.com/instrumentisto>
Copyright © 2019 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:
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 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.
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.
84 changes: 57 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,57 @@
# 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)

FIREFOX_VER ?= 69.0
GECKODRIVER_VER ?= 0.25.0

IMAGE_NAME := instrumentisto/geckodriver
TAGS ?= $(FIREFOX_VER)-driver$(GECKODRIVER_VER)-debian-buster \
$(FIREFOX_VER)-driver$(GECKODRIVER_VER)-debian \
$(FIREFOX_VER)-driver$(GECKODRIVER_VER) \
$(FIREFOX_VER)-debian-buster \
$(FIREFOX_VER)-debian \
$(FIREFOX_VER) \
debian-buster \
debian \
latest
VERSION ?= $(word 1,$(subst $(comma), ,$(TAGS)))



# Build Docker image.
#
# Usage:
# make image [VERSION=<image-version>] [no-cache=(no|yes)]
# make image [tag=($(VERSION)|<docker-tag>)] [no-cache=(no|yes)]
# [FIREFOX_VER=<firefox-version>]
# [GECKODRIVER_VER=<geckodriver-version>]

image-tag = $(if $(call eq,$(tag),),$(VERSION),$(tag))

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) .
--build-arg firefox_ver=$(FIREFOX_VER) \
--build-arg geckodriver_ver=$(GECKODRIVER_VER) \
-t $(IMAGE_NAME):$(image-tag) .



# Tag Docker image with given tags.
#
# Usage:
# make tags [VERSION=<image-version>]
# [TAGS=<docker-tag-1>[,<docker-tag-2>...]]
# make tags [for=($(VERSION)|<docker-tag>)]
# [tags=($(TAGS)|<docker-tag-1>[,<docker-tag-2>...])]

tags-for = $(if $(call eq,$(for),),$(VERSION),$(for))
tags-tags = $(if $(call eq,$(tags),),$(TAGS),$(tags))

tags:
$(foreach tag, $(subst $(comma), ,$(TAGS)),\
$(call docker.tag.do,$(VERSION),$(tag)))
$(foreach tag, $(subst $(comma), ,$(tags-tags)),\
$(call tags.do,$(tags-for),$(tag)))
define tags.do
$(eval from := $(strip $(1)))
$(eval to := $(strip $(2)))
Expand All @@ -58,11 +73,13 @@ endef
# Manually push Docker images to Docker Hub.
#
# Usage:
# make push [TAGS=<docker-tag-1>[,<docker-tag-2>...]]
# make push [tags=($(TAGS)|<docker-tag-1>[,<docker-tag-2>...])]

push-tags = $(if $(call eq,$(tags),),$(TAGS),$(tags))

push:
$(foreach tag, $(subst $(comma), ,$(TAGS)),\
$(call docker.push.do, $(tag)))
$(foreach tag, $(subst $(comma), ,$(push-tags)),\
$(call push.do, $(tag)))
define push.do
$(eval tag := $(strip $(1)))
docker push $(IMAGE_NAME):$(tag)
Expand All @@ -73,10 +90,17 @@ 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>...]]
# make release [tag=($(VERSION)|<docker-tag>)] [no-cache=(no|yes)]
# [tags=($(TAGS)|<docker-tag-1>[,<docker-tag-2>...])]
# [FIREFOX_VER=<firefox-version>]
# [GECKODRIVER_VER=<geckodriver-version>]

release: | image tags push
release:
@make image tag=$(tag) no-cache=$(no-cache) \
FIREFOX_VER=$(FIREFOX_VER) \
GECKODRIVER_VER=$(GECKODRIVER_VER)
@make tags for=$(tag) tags=$(tags)
@make push tags=$(tags)



Expand All @@ -89,14 +113,17 @@ release: | image tags push
# http://windsock.io/automated-docker-image-builds-with-multiple-tags
#
# Usage:
# make post-push-hook [TAGS=<docker-tag-1>[,<docker-tag-2>...]]
# make post-push-hook [tags=($(TAGS)|<docker-tag-1>[,<docker-tag-2>...])]
# [out=(hooks/post_push|<file-path>)]

post-push-hook-tags = $(if $(call eq,$(tags),),$(TAGS),$(tags))

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
--image_tags='$(post-push-hook-tags)' \
> $(if $(call eq,$(out),),hooks/post_push,$(out))



Expand All @@ -106,13 +133,16 @@ post-push-hook:
# https://github.com/bats-core/bats-core
#
# Usage:
# make test [VERSION=<image-version>]
# make test [tag=($(VERSION)|<docker-tag>)]

test-tag = $(if $(call eq,$(tag),),$(VERSION),$(tag))

test:
ifeq ($(wildcard node_modules/.bin/bats),)
@make deps.bats
endif
IMAGE=$(IMAGE_NAME):$(VERSION) node_modules/.bin/bats test/suite.bats
IMAGE=$(IMAGE_NAME):$(test-tag) \
node_modules/.bin/bats test/suite.bats



Expand All @@ -122,7 +152,7 @@ endif
# make deps.bats

deps.bats:
docker run --rm -v "$(PWD)":/app -w /app \
docker run --rm --network=host -v "$(PWD)":/app -w /app \
node:alpine \
yarn install --non-interactive --no-progress

Expand Down
54 changes: 37 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
Geckodriver Docker image
===============================
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/geckodriver.svg)](https://hub.docker.com/r/instrumentisto/geckodriver)
[![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/geckodriver.svg)](https://hub.docker.com/r/instrumentisto/geckodriver)




## What is Geckodriver Docker image?
## Supported tags and respective `Dockerfile` links

- `69.0-driver0.25.0-debian-buster`, `69.0-driver0.25.0-debian`, `69.0-driver0.25.0`, `69.0-debian-buster`, `69.0-debian`, `69.0`, `debian-buster`, `debian`, `latest` [(Dockerfile)][101]




## What is geckodriver?

[geckodriver] is a proxy for using W3C [WebDriver] compatible clients to interact with Gecko-based browsers.

This program provides the HTTP API described by the [WebDriver protocol] to communicate with Gecko browsers, such as [Firefox]. It translates calls into the [Marionette remote protocol] by acting as a proxy between the local and remote ends.

This image bundles [geckodriver] with [Firefox] and is suitable for running headless tests.

[Marionette remote protocol]: https://firefox-source-docs.mozilla.org/testing/marionette
[WebDriver]: https://developer.mozilla.org/en-US/docs/Web/WebDriver
[WebDriver protocol]: https://w3c.github.io/webdriver/#protocol

> [firefox-source-docs.mozilla.org/testing/geckodriver](https://firefox-source-docs.mozilla.org/testing/geckodriver)

This image bundles Geckodriver with Firefox and is suitable for running headless tests.


## How to use this image
Expand All @@ -17,25 +36,20 @@ This image bundles Geckodriver with Firefox and is suitable for running headless
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.
After that you can connect to [geckodriver] that is listening on `127.0.0.1:4444`. Only headless mode is supported.

Consider using `--network=host` option for running image if you want to run tests on local server.

## Image versions

Image version corresponds to Firefox version used.
Consider to increase shared memory size (`--shm-size 2g` option), otherwise you may experience unexpected [Firefox] crashes.




## License

Firefox and Geckodriver are licensed under [Mozilla Public License][91].
[Firefox] and [geckodriver] are licensed under [Mozilla Public License].

Geckodriver Docker image is licensed under [MIT license][92].
[geckodriver] Docker image is licensed under [MIT license][2].



Expand All @@ -49,6 +63,12 @@ If you have any problems with or questions about this image, please contact us t




[Firefox]: https://www.mozilla.org/firefox
[geckodriver]: https://github.com/mozilla/geckodriver
[Mozilla Public License]: https://www.mozilla.org/en-US/MPL/2.0

[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
[2]: https://github.com/instrumentisto/geckodriver-docker-image/blob/master/LICENSE.md

[101]: https://github.com/instrumentisto/geckodriver-docker-image/blob/master/Dockerfile
2 changes: 1 addition & 1 deletion hooks/post_push
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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
for tag in {69.0-driver0.25.0-debian-buster,69.0-driver0.25.0-debian,69.0-driver0.25.0,69.0-debian-buster,69.0-debian,69.0,debian-buster,debian,latest}; do
docker tag $IMAGE_NAME ${repoName}:${tag}
docker push ${repoName}:${tag}
done
Loading

0 comments on commit 546e388

Please sign in to comment.