-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
5 changed files
with
206 additions
and
1 deletion.
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,7 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: github-actions | ||
directory: "/.github" | ||
schedule: | ||
interval: daily | ||
open-pull-requests-limit: 99 |
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,62 @@ | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
name: Release new version | ||
|
||
jobs: | ||
create-release: | ||
runs-on: ubuntu-latest | ||
name: Release to DockerHub | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
steps: | ||
- name: Checkout master | ||
uses: actions/checkout@v2 | ||
|
||
- name: Bump version | ||
uses: anothrNick/[email protected] | ||
env: | ||
WITH_V: true | ||
|
||
- name: Get new tag | ||
id: new_tag | ||
uses: WyriHaximus/github-action-get-previous-tag@v1 | ||
with: | ||
fallback: 1.0.0 | ||
|
||
- name: Build changelog | ||
id: build_changelog | ||
uses: mikepenz/release-changelog-builder-action@v1 | ||
|
||
- name: Create release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
with: | ||
tag_name: ${{ steps.new_tag.outputs.tag }} | ||
release_name: ${{ steps.new_tag.outputs.tag }} | ||
body: ${{steps.build_changelog.outputs.changelog}} | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
tags: peavers/quarantine:latest | ||
|
||
- name: Rollback if failure | ||
if: failure() && steps.create_release.outputs.id != '' | ||
uses: author/action-rollback@stable | ||
with: | ||
id: ${{ steps.create_release.id }} | ||
tag: ${{ steps.new_tag.outputs.tag }} |
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,38 @@ | ||
HELP.md | ||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
.DS_Store |
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,43 @@ | ||
FROM openjdk:16-buster | ||
LABEL maintainer="[email protected]" | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
ENV DEBCONF_NONINTERACTIVE_SEEN true | ||
|
||
# Create a default user | ||
RUN groupadd --system automation && \ | ||
useradd --system --create-home --gid automation --groups audio,video automation && \ | ||
mkdir --parents /home/automation/reports && \ | ||
chown --recursive automation:automation /home/automation | ||
|
||
# Install dependencies | ||
RUN apt-get -yqq update && \ | ||
apt-get -yqq install gnupg2 && \ | ||
apt-get -yqq install curl unzip && \ | ||
apt-get -yqq install xvfb tinywm && \ | ||
apt-get -yqq install fonts-ipafont-gothic xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Install Chrome WebDriver | ||
RUN CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \ | ||
mkdir -p /opt/chromedriver-$CHROMEDRIVER_VERSION && \ | ||
curl -sS -o /tmp/chromedriver_linux64.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip && \ | ||
unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-$CHROMEDRIVER_VERSION && \ | ||
rm /tmp/chromedriver_linux64.zip && \ | ||
chmod +x /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver && \ | ||
ln -fs /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver /usr/local/bin/chromedriver | ||
|
||
# Install Google Chrome | ||
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \ | ||
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \ | ||
apt-get -yqq update && \ | ||
apt-get -yqq install google-chrome-stable && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Default configuration | ||
ENV DISPLAY :20.0 | ||
ENV SCREEN_GEOMETRY "1440x900x24" | ||
ENV CHROMEDRIVER_PORT 4444 | ||
ENV CHROMEDRIVER_WHITELISTED_IPS "127.0.0.1" | ||
ENV CHROMEDRIVER_URL_BASE '' | ||
ENV CHROMEDRIVER_EXTRA_ARGS '' |
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 |
---|---|---|
@@ -1 +1,56 @@ | ||
selenium-java-docker | ||
#Selenium Java & Docker | ||
This is a Dockerfile with the latest version of Google Chrome and the Google Chrome Web Driver along with the Java 16 | ||
JDK. | ||
|
||
## Why | ||
A project built in Java which requires Selenium, and a webdriver to be deployed, this is a simple way to get it done. | ||
|
||
## Example use | ||
If you wanted to use this as a multi-stage build file you'd just need to add two small sections to a Dockerfile. | ||
|
||
```dockerfile | ||
# Build the project using Gradle | ||
FROM gradle:jdk16 AS build | ||
ADD . /home/gradle/src | ||
WORKDIR /home/gradle/src | ||
RUN gradle build | ||
|
||
# Run the Jar | ||
FROM peavers/selenium-java:latest | ||
RUN mkdir /app | ||
COPY --from=build /home/gradle/src/build/libs/spring-boot-application.jar /app/spring-boot-application.jar | ||
ENTRYPOINT ["java", "-jar", "/app/spring-boot-application.jar"] | ||
``` | ||
|
||
## Configure your application | ||
The web driver is ready and accessible at `/usr/local/bin/chromedriver` so however you configure the driver path in | ||
your application, point it there. | ||
|
||
If you're running the Java Selenium library through Springboot, here is an example configuration class: | ||
```java | ||
@Configuration | ||
public class WebDriverConfig { | ||
|
||
@Bean | ||
public WebDriver webDriver() { | ||
|
||
final var options = new ChromeOptions(); | ||
|
||
// Overwrite the values set in the Dockerfile. | ||
System.setProperty("webdriver.chrome.whitelistedIps", ""); | ||
System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver"); | ||
|
||
// Set custom options for the webdriver. | ||
options.addArguments("--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 11_4) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/91.0.4472.124 Safari/537.36"); | ||
options.addArguments("--lang=en_US"); | ||
options.addArguments("--window-size=3840,2160"); | ||
options.addArguments("--disable-extensions"); | ||
options.addArguments("--disable-dev-shm-usage"); | ||
options.addArguments("--no-sandbox"); | ||
options.addArguments("--disable-gpu"); | ||
options.addArguments("--headless"); | ||
|
||
return new ChromeDriver(options); | ||
} | ||
} | ||
``` |